Esempio n. 1
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. 2
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;
 }