Search code examples
c++boostboost-propertytree

Boost PTree used just for reading file or for storing the values too?


I have a configuration file, that is a json. I have created a class (ConfigFile) that reads that file and store the values (using boost parser and ptree). I am wandering is it a good practice to use the ptree as a member of the ConfigFile class, or I shall use it just for reading the json and store the values in a map member?


Solution

  • I'd say what matters is the ConfigFile's interface. If you can keep it consistent with either version, it shouldn't be a problem to just choose one and switch to the other if you feel the need without breaking anything.

    Keep property tree out of the header. The latter can also be fixed with the pimpl idiom.

    @sehe's comment makes a lot of sense here as well and is something to remember.