20 #include <boost/property_tree/ptree.hpp>
21 #include <boost/property_tree/xml_parser.hpp>
22 #include <boost/algorithm/string/replace.hpp>
24 #include "json_parser.h"
25 #include "../core/model/repo_node_utils.h"
43 const std::string &label,
44 const std::vector<PropertyTree> &value)
46 boost::property_tree::ptree arraytree;
47 for (
size_t i = 0; i < value.size(); ++i)
49 arraytree.push_back(std::make_pair(
"", value[i].tree));
52 tree.add_child(label, arraytree);
68 const std::string &label,
69 const std::string &attribute,
89 const std::string &label,
90 const std::string &attribute,
91 const std::vector<T> &value,
92 const bool &useDelimiter =
true
96 for (uint32_t i = 0; i < value.size(); ++i)
99 if (useDelimiter && i != value.size() - 1)
106 std::string val = ss.str();
118 template <
typename T>
120 const std::string &label,
124 tree.put(label, value);
126 tree.add(label, value);
129 template <std::
size_t N>
131 const std::string &label,
132 const char(&value)[N])
144 template <
typename T>
146 const std::string &label,
147 const std::vector<T> &value,
148 const bool &join =
true)
152 boost::property_tree::ptree arrayTree;
153 for (
const auto &child : value)
157 arrayTree.push_back(std::make_pair(
"", childTree.tree));
160 tree.add_child(label, arrayTree);
164 std::stringstream ss;
165 for (
size_t i = 0; i < value.size(); ++i)
167 ss << boost::lexical_cast<std::string>(value[i]);
168 if (i != value.size() - 1)
172 std::string valueInStr = ss.str();
197 const std::string &label,
200 tree.add_child(label, subTree.tree);
208 std::iostream &stream
211 boost::property_tree::write_json(stream, tree,
false);
219 std::iostream &stream
222 std::stringstream ss;
223 boost::property_tree::write_xml(ss, tree);
224 std::string stringxml = ss.str();
226 boost::replace_all(stringxml,
"	",
"\t");
227 boost::replace_all(stringxml,
" ",
"\n");
233 boost::property_tree::ptree tree;
241 std::string sanitizeStr(
const std::string &value);
249 int findSpecialWords(
250 const std::string &value,
254 const std::string &value,
259 void PropertyTree::addToTree<repo_vector_t>(
260 const std::string &label,
264 void PropertyTree::addToTree<std::string>(
265 const std::string &label,
266 const std::string &value);
269 void PropertyTree::addToTree<repoUUID>(
270 const std::string &label,
271 const repoUUID &value);
275 const std::string &label,
276 const std::vector<PropertyTree> &value,
281 const std::string &label,
282 const std::string &attribute,
283 const std::string &value
288 const std::string &label,
289 const std::string &attribute,
void addFieldAttribute(const std::string &label, const std::string &attribute, const T &value)
Definition: repo_property_tree.h:67
void addToTree(const std::string &label, const std::vector< T > &value, const bool &join=true)
Definition: repo_property_tree.h:145
void write_json(std::iostream &stream) const
Definition: repo_property_tree.h:207
Definition: repo_connection_pool_mongo.h:32
Definition: repo_property_tree.h:29
Definition: repo_node_utils.h:67
void mergeSubTree(const std::string &label, const PropertyTree &subTree)
Definition: repo_property_tree.h:196
void write_xml(std::iostream &stream) const
Definition: repo_property_tree.h:218
void addArrayObjects(const std::string &label, const std::vector< PropertyTree > &value)
Definition: repo_property_tree.h:42
void addToTree(const std::string &label, const T &value)
Definition: repo_property_tree.h:119
void addFieldAttribute(const std::string &label, const std::string &attribute, const std::vector< T > &value, const bool &useDelimiter=true)
Definition: repo_property_tree.h:88
void disableJSONWorkaround()
Definition: repo_property_tree.h:186