/* ---------------------------------------------------------------- */
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;
}
Пример #2
0
bool StreamWriterBuilder::validate(Json::Value* invalid) const
{
    Json::Value my_invalid;
    if (!invalid) invalid = &my_invalid;  // so we do not need to test for NULL
    Json::Value& inv = *invalid;
    std::set<std::string> valid_keys;
    getValidWriterKeys(&valid_keys);
    Value::Members keys = settings_.getMemberNames();
    size_t n = keys.size();
    for (size_t i = 0; i < n; ++i) {
        std::string const& key = keys[i];
        if (valid_keys.find(key) == valid_keys.end()) {
            inv[key] = settings_[key];
        }
    }
    return 0u == inv.size();
}
Пример #3
0
  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();
      }
  }
Пример #4
0
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;
    }
    }
}
Пример #5
0
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;
    }
}
Пример #6
0
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;
}