Saturday, January 31, 2015

Java-Style Properties Files in C++

(Originally posted Feb 28, 2008)

Need to handle Java-style properties files in C++? I've decided to post some of my own personal library of code on this blog. This is one of those occasionally useful things.

propertyutil.h
propertyutil.cpp

If you fix any bugs, extend the code or anything else, send back your changes if you don't mind. ;)

7 comments:

cosa said...

Hi Senzee,

There is a Boost library called 'Program Options', which provides some convenience in dealing with command line and config files. Unfortunately it seems that you have to specify in the code the properties the file should have in advance. It would be much more useful if you could just load any key,value pairs present in the file. If this is not true about the boost library I hope someone can correct me.

Best,

E.Z

Anonymous said...

Awesome! May we use this library in commercial code?

Thanks!

Senzee said...

@Anonymous,

Email me: psenzee yahoo com

:)

Joshua Smith said...

Thanks a lot for sharing with useful tips. It necessary to know that ipad application developer could help in your business by installing customized software solutions. Also you may turn your attention on outsourced enterprise content management software.

pharmacy said...

all those files are so important to many people like me because we can use the computer in a better way

Rob Bogie said...

The std::Exception class can not be instantiated directly on unix systems. It has to be extended by some other class before it is usefull. I made a PropertyException inside the header, which I then used.

You can find the changes on the link I provided with my name

glywk said...

Hi Senzee,

Your code is interesting, but some part of the java properties syntax are not treated during the key parsing:

- Continuation line
- Escape sequence (like "\ ")
- Unicode escape sequence

To have an exhaustive example, you may have a look to https://github.com/glywk/cpp_properties

Regards,