/* ---------------------------------------------------------------- */ void diplayRemotes() { Value::Members members = jsonRoot.getMemberNames(); for (std::vector<string>::iterator it = members.begin(); it != members.end(); ++it) if (string::npos != (*it).find("remote_")) cout << " " << *it << endl; }
void read() { using namespace Json; std::string filename = get.getPath("ratings.json"); Value v; try { v = readJson(filename); } // A missing file is normal, just ignore it. catch(...) {} // Convert json value into std::map Value::Members keys = v.getMemberNames(); Value::Members::iterator it; for(it = keys.begin(); it != keys.end(); it++) { ratings[*it] = v[*it].asInt(); } }
void write_value (write_t write, Value const& value) { switch (value.type()) { case nullValue: write("null", 4); break; case intValue: write_string(write, valueToString(value.asInt())); break; case uintValue: write_string(write, valueToString(value.asUInt())); break; case realValue: write_string(write, valueToString(value.asDouble())); break; case stringValue: write_string(write, valueToQuotedString(value.asCString())); break; case booleanValue: write_string(write, valueToString(value.asBool())); break; case arrayValue: { write("[", 1); int const size = value.size(); for (int index = 0; index < size; ++index) { if (index > 0) write(",", 1); write_value(write, value[index]); } write("]", 1); break; } case objectValue: { Value::Members const members = value.getMemberNames(); write("{", 1); for (auto it = members.begin(); it != members.end(); ++it) { std::string const& name = *it; if (it != members.begin()) write(",", 1); write_string(write, valueToQuotedString(name.c_str())); write(":", 1); write_value(write, value[name]); } write("}", 1); break; } } }
void StyledStreamWriter::writeValue ( const Value& value ) { switch ( value.type () ) { case nullValue: pushValue ( "null" ); break; case intValue: pushValue ( valueToString ( value.asInt () ) ); break; case uintValue: pushValue ( valueToString ( value.asUInt () ) ); break; case realValue: pushValue ( valueToString ( value.asDouble () ) ); break; case stringValue: pushValue ( valueToQuotedString ( value.asCString () ) ); break; case booleanValue: pushValue ( valueToString ( value.asBool () ) ); break; case arrayValue: writeArrayValue ( value); break; case objectValue: { Value::Members members ( value.getMemberNames () ); if ( members.empty () ) pushValue ( "{}" ); else { writeWithIndent ( "{" ); indent (); Value::Members::iterator it = members.begin (); while ( true ) { std::string const& name = *it; const Value& childValue = value[name]; writeWithIndent ( valueToQuotedString ( name.c_str () ) ); *document_ << " : "; writeValue ( childValue ); if ( ++it == members.end () ) break; *document_ << ","; } unindent (); writeWithIndent ( "}" ); } } break; } }
void FastWriter::writeValue ( const Value& value ) { switch ( value.type () ) { case nullValue: document_ += "null"; break; case intValue: document_ += valueToString ( value.asInt () ); break; case uintValue: document_ += valueToString ( value.asUInt () ); break; case realValue: document_ += valueToString ( value.asDouble () ); break; case stringValue: document_ += valueToQuotedString ( value.asCString () ); break; case booleanValue: document_ += valueToString ( value.asBool () ); break; case arrayValue: { document_ += "["; int size = value.size (); for ( int index = 0; index < size; ++index ) { if ( index > 0 ) document_ += ","; writeValue ( value[index] ); } document_ += "]"; } break; case objectValue: { Value::Members members ( value.getMemberNames () ); document_ += "{"; for ( Value::Members::iterator it = members.begin (); it != members.end (); ++it ) { std::string const& name = *it; if ( it != members.begin () ) document_ += ","; document_ += valueToQuotedString ( name.c_str () ); document_ += ":"; writeValue ( value[name] ); } document_ += "}"; } break; } }
/* ---------------------------------------------------------------- */ void diplayButtonsForRemote(Value::Members & membersOfSignals) { for (std::vector<string>::iterator it = membersOfSignals.begin(); it != membersOfSignals.end(); ++it) cout << " " << *it << endl; }