Esempio n. 1
0
 static HostSpec parseHostSpec( JSON::Entity const &entity )
 {
   HostSpec result;
   if ( entity.isString() )
     result.push_back( entity.stringToStdString() );
   else if ( entity.isArray() )
   {
     JSON::ArrayDecoder arrayDecoder( entity );
     JSON::Entity elementEntity;
     while ( arrayDecoder.getNext( elementEntity ) )
     {
       try
       {
         elementEntity.requireString();
         result.push_back( elementEntity.stringToStdString() );
       }
       catch ( Exception e )
       {
         arrayDecoder.rethrow( e );
       }
     }
   }
   else
     throw Exception( "must be a string or an array" );
   return result;
 }
Esempio n. 2
0
 static void parseHostStrings( JSON::Entity const &entity, HostStrings &result )
 {
   if ( entity.isString() )
   {
     HostSpec hostSpec;
     hostSpec.push_back( "*" );
     result.insert( HostStrings::value_type( entity.stringToStdString(), hostSpec ) );
   }
   else if ( entity.isObject() )
   {
     JSON::ObjectDecoder objectDecoder( entity );
     JSON::Entity keyString, valueEntity;
     while ( objectDecoder.getNext( keyString, valueEntity ) )
     {
       try
       {
         HostSpec hostSpec = parseHostSpec( valueEntity );
         result.insert( HostStrings::value_type( keyString.stringToStdString(), hostSpec ) );
       }
       catch ( Exception e )
       {
         objectDecoder.rethrow( e );
       }
     }
   }
   else throw Exception( "must be a string or an object" );
 }
Esempio n. 3
0
 void ResourceLoadNode::jsonExecCreate(
   JSON::Entity const &arg,
   RC::Handle<Context> const &context,
   JSON::ArrayEncoder &resultArrayEncoder
   )
 {
   arg.requireString();
   Create( arg.stringToStdString(), context );
 }
Esempio n. 4
0
 void parseMethods( JSON::Entity const &methodsArray, std::vector<std::string> &methods )
 {
   JSON::ArrayDecoder methodArrayDecoder( methodsArray );
   JSON::Entity methodEntity;
   while ( methodArrayDecoder.getNext( methodEntity ) )
   {
     try
     {
       methodEntity.requireString();
       methods.push_back( methodEntity.stringToStdString() );
     }
     catch ( Exception e )
     {
       methodArrayDecoder.rethrow( e );
     }
   }
 }