Skip to content

Instantly share code, notes, and snippets.

@huahsin68
Last active September 21, 2018 03:32
BackupUtil - Write content into XML with Boost Property Tree
Configuration::Configuration()
{
try {
boost::property_tree::read_xml(filesystem::current_path().string() + GENERIC_PATH_SEPARATOR + INDEX_FILENAME, backupConfig);
}
catch( const boost::property_tree::ptree_error &e ) {
cout << e.what() << endl;
}
}
class Configuration
{
private:
Configuration();
public:
static Configuration* getInstance()
{
if( !instance )
instance = new Configuration();
return instance;
}
inline void updateConfiguration(string configPath)
{
boost::property_tree::write_xml(configPath, backupConfig);
}
boost::property_tree::ptree readConfigFile();
boost::property_tree::ptree readConfigFile(string configPath);
public:
boost::property_tree::ptree getBackupConfig() const { return backupConfig; }
private:
static Configuration *instance;
boost::property_tree::ptree backupConfig;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment