Exemple #1
0
 static void parseHostStringsVector( JSON::Entity const &entity, HostStringsVector &result )
 {
   if ( entity.isArray() )
   {
     JSON::ArrayDecoder arrayDecoder( entity );
     JSON::Entity elementEntity;
     while ( !arrayDecoder.getNext( elementEntity ) )
     {
       try
       {
         HostStrings hostStrings;
         parseHostStrings( elementEntity, hostStrings );
         result.push_back( hostStrings );
       }
       catch ( Exception e )
       {
         arrayDecoder.rethrow( e );
       }
     }
   }
   else
   {
     HostStrings hostStrings;
     parseHostStrings( entity, hostStrings );
     result.push_back( hostStrings );
   }
 }
Exemple #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;
 }