3#include <boost/shared_ptr.hpp>
4#include <libxml++/libxml++.h>
16 std::string parent_name, std::string indent) {
22 string newindent = indent +
" ";
24 for (
int n = 0; n < members.size(); ++n) {
26 if (node[name].isNull()) {
27 ss << indent <<
"<" << name <<
"/>\n";
30 indent_child = node[name].
isObject();
31 if (!indent_child && node[name].isArray())
33 ss << indent <<
"<" << name <<
">";
39 ss <<
"</" << name <<
">\n";
43 std::string newindent = indent;
44 indent = indent.substr(0, indent.size() - 2);
45 int nchildren = node.
size();
46 for (
int n = 0; n < nchildren; ++n) {
47 if (node[n].isNull()) {
48 ss << indent <<
"<" << parent_name <<
"/>\n";
53 ss << indent <<
"<" << parent_name <<
">";
58 if (n < nchildren - 1) {
61 ss <<
"</" << parent_name <<
">\n";
66 }
else if (node.
isInt()) {
68 }
else if (node.
isUInt()) {
72 }
else if (node.
isBool()) {
83 using std::stringstream;
91 bool parsed = reader.
parse(s, root,
false);
93 string msg =
"Failed to parse JSON file into XML:\n" + \
108 if (node[key].isArray()) {
111 Value keynode = node[key];
113 keynode.append(node[key]);
123 std::string parent_name) {
127 for (
int i = 0; i < n; ++i) {
148 using std::stringstream;
151 boost::shared_ptr<XMLParser> parser = boost::shared_ptr<XMLParser>(
156 string rootname = parser->Document()->get_root_node()->get_name();
161 return writer.
write(jroot);
Writes a Value in JSON format with custom formatting.
virtual std::string write(const Value &root)
Unserialize a JSON document into a Value.
std::string getFormattedErrorMessages() const
Returns a user friendly string that list errors in the parsed document.
bool parse(const std::string &document, Value &root, bool collectComments=true)
Read a Value from a JSON document.
ArrayIndex size() const
Number of values in array or object.
Members getMemberNames() const
Return a list of the member names.
Value & append(const Value &value)
Append value to array at the end.
std::string asString() const
bool isMember(const char *key) const
Return true if the object has a member named key.
A class for extracting information from a given XML parser.
virtual std::string GetElementName(int index=0)
investigates the current status and returns a string representing the name of a given index
InfileTree * SubTree(std::string query, int index=0)
populates a child infile based on a query and index
virtual std::string GetString(std::string query, int index=0)
investigates the current status and returns a string representing the content of a query at a given i...
For validating files received via IO.
For values that are too big, too small, etc.
A helper class to hold xml file data and provide automatic validation.
@ arrayValue
array value (ordered list)
@ objectValue
object value (collection of name/value pairs).
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or....