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 <<
">";
34 if (indent_child) ss <<
"\n";
36 if (indent_child) ss << indent;
37 ss <<
"</" << name <<
">\n";
41 std::string newindent = indent;
42 indent = indent.substr(0, indent.size() - 2);
43 int nchildren = node.
size();
44 for (
int n = 0; n < nchildren; ++n) {
45 if (node[n].isNull()) {
46 ss << indent <<
"<" << parent_name <<
"/>\n";
51 ss << indent <<
"<" << parent_name <<
">";
52 if (indent_child) ss <<
"\n";
55 if (n < nchildren - 1) {
56 if (indent_child) ss << indent;
57 ss <<
"</" << parent_name <<
">\n";
62 }
else if (node.
isInt()) {
64 }
else if (node.
isUInt()) {
68 }
else if (node.
isBool()) {
80 using std::stringstream;
87 bool parsed = reader.
parse(s, root,
false);
89 string msg =
"Failed to parse JSON file into XML:\n" +
104 if (node[key].isArray()) {
107 Value keynode = node[key];
109 keynode.append(node[key]);
119 std::string parent_name) {
123 for (
int i = 0; i < n; ++i) {
145 using std::stringstream;
147 boost::shared_ptr<XMLParser> parser =
148 boost::shared_ptr<XMLParser>(
new XMLParser());
152 string rootname = parser->Document()->get_root_node()->get_name();
157 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....