4 #ifndef FIRE_RESOURCES_PROPERTIES_HPP_INCLUDED
5 #define FIRE_RESOURCES_PROPERTIES_HPP_INCLUDED
7 #include <boost/filesystem.hpp>
8 #include <boost/smart_ptr/shared_ptr.hpp>
9 #include <boost/property_tree/ptree.hpp>
10 #include <boost/property_tree/json_parser.hpp>
18 #include "fire/export.hpp"
20 #include "fire/Object.hpp"
42 boost::filesystem::path path;
47 boost::shared_ptr< boost::property_tree::ptree > tree;
77 T
get(
const std::string& key) {
81 value = this->tree->get< T >(key);
82 }
catch (
const std::exception&) {
83 boost::property_tree::ptree tree;
84 tree = this->tree->get_child(key);
85 std::stringstream stringStream;
86 boost::property_tree::write_json(stringStream, tree,
false);
87 stringStream >> value;
89 }
catch (
const std::exception& exception) {
111 T
get(
const std::string& key,
const T& defaultValue) {
115 value = this->tree->get< T >(key, defaultValue);
116 }
catch (
const std::exception& exception) {
117 boost::property_tree::ptree tree;
118 tree = this->tree->get_child(key);
119 std::stringstream stringStream;
120 boost::property_tree::write_json(stringStream, tree,
false);
121 stringStream >> value;
123 }
catch (
const std::exception& exception) {
142 void put(
const std::string& key,
const T& value) {
145 boost::property_tree::ptree tree;
146 std::stringstream stream;
148 boost::property_tree::read_json(stream, tree);
149 this->tree->put_child(key, tree);
150 }
catch (
const std::exception& exception) {
151 this->tree->put< T >(key, value);
153 }
catch (
const std::exception& exception) {
164 void update(
bool pretty =
true);
Classe per la gestione di un oggetto.
Definition: Object.hpp:29
Classe per la gestione delle proprietà contenute in una risorsa.
Definition: Properties.hpp:36
void put(const std::string &key, const T &value)
Inserisce un valore di una proprietà
Definition: Properties.hpp:142