Exemplo n.º 1
0
bool hatch::RegistryParser::Parse( Registry& registry )
{
	if( !SkipEndLines() )
		return false;

	bool process = true;
	do
	{
		if( m_tokenizer.IsWord() )
		{
			const char* key = m_tokenizer.GetWord();
			if( Cmp( "new_version", key ) )
			{
				if( !ParseStringValue( registry.newVersion ) )
				{
					m_errorMessage << "for new_version";
					return false;
				}
			}
			else if( Cmp( "old_version", key ) )
			{
				if( !ParseStringValue( registry.oldVersion ) )
				{
					m_errorMessage << "for old_version";
					return false;
				}
			}
			else if( Cmp( "file", key ) )
			{
				if( !SkipEndLines() || !m_tokenizer.IsSymbol() || m_tokenizer.GetSymbol() != '{' )
				{
					m_errorMessage << "'{' expected after 'file'";
					return false;
				}

				RegistryAction* pAction = SCARAB_NEW RegistryAction;
				registry.actions.push_back( pAction );

				if( !ParseFile( registry, *pAction ) )
					return false;
			}
		}

		if( !m_tokenizer.ParseNext() )
			process = false;
	} while( process );

	return true;
}
Exemplo n.º 2
0
//------------------------------------------------------------------------------
bool TcopsVHFAscii::ParseDataBlock()
{
   bool retval = false;

   for (UnsignedInt i = 0; i < supportedFields.size(); ++i)
   {
      std::string theField = supportedFields[i];
      if (readAllSupportedFields || (find(selectedFields.begin(),
            selectedFields.end(), theField) != selectedFields.end()))
      {
         // Read the data block looking for a file string match
         for (UnsignedInt i = 0; i < dataBuffer.size(); ++i)
         {
            if (dataBuffer[i].find(fileStringMap[theField])!=std::string::npos)
            {
               switch (dataType[theField])
               {
               case READER_REAL:
                  if (ParseRealValue(i, theField))
                     retval = true;;
                  break;

               case READER_RVECTOR6:
                  {
                     // Set up for the Cartesian State scan
                     StringArray theIds;
                     theIds.push_back("X ");   // ' ' to distinguish from XDOT,
                     theIds.push_back("Y ");   // YDOT, and ZDOT
                     theIds.push_back("Z ");
                     theIds.push_back("XDOT");
                     theIds.push_back("YDOT");
                     theIds.push_back("ZDOT");
                     // And find it
                     if (ParseRvector6Value(i, theField, theIds))
                        retval = true;
                  }
                  break;

               case READER_STRING:
               case READER_TIMESTRING:
                  if (ParseStringValue(i, theField))
                  {
                     if (dataType[theField] == READER_TIMESTRING)
                        ParseTime(theField);
                     retval = true;
                  }
                  break;

               default:
                  // Skip the other types (basically the subtypes)
                  break;
               }
            }
         }
      }
   }

   return retval;
}
Exemplo n.º 3
0
bool hatch::RegistryParser::ParseFile( Registry& registry, RegistryAction& action )
{
	if( !SkipEndLines() )
	{
		m_errorMessage << "Parameters expected after 'file {'";
		return false;
	}

	bool process = true;
	do
	{
		if( m_tokenizer.IsWord() )
		{
			const char* key = m_tokenizer.GetWord();
			if( Cmp( "action", key ) )
			{
				String_t value;
				if( !ParseWordValue( value ) )
				{
					m_errorMessage << "for action";
					return false;
				}

				if( !dung::StringToAction( value.c_str(), action.action ) )
				{
					m_errorMessage << _T("Unknown action ") << value;
					return false;
				}
			}
			else if( Cmp( "diff_path", key ) )
			{
				if( !ParseStringValue( action.diff_path ) )
				{
					m_errorMessage << _T("for diff_path");
					return false;
				}
			}
			else if( Cmp( "old_path", key ) )
			{
				if( !ParseStringValue( action.old_path ) )
				{
					m_errorMessage << _T("for old_path");
					return false;
				}
			}
			else if( Cmp( "new_path", key ) )
			{
				if( !ParseStringValue( action.new_path ) )
				{
					m_errorMessage << "for new_path";
					return false;
				}
			}
			else if( Cmp( "diff_method", key ) )
			{
				if( !ParseWordValue( action.diff_method ) )
				{
					m_errorMessage << "for diff_method";
					return false;
				}
			}
			else if( Cmp( "old_sha1", key ) )
			{
				String_t value;
				if( !ParseStringValue( value ) )
				{
					m_errorMessage << "for old_sha1";
					return false;
				}

				if( !dung::StringToSHA1( value.c_str(), action.oldSha1 ))
				{
					m_errorMessage << "Can't convert " << value << " to old_sha1";
					return false;
				}

				SCARAB_ASSERT( dung::SHA1_TO_TSTRING( action.oldSha1 ) == value );
			}
			else if( Cmp( "new_sha1", key ) )
			{
				String_t value;
				if( !ParseStringValue( value ) )
				{
					m_errorMessage << "for new_sha1";
					return false;
				}

				if( !dung::StringToSHA1( value.c_str(), action.newSha1 ))
				{
					m_errorMessage << "Can't convert " << value << " to new_sha1";
					return false;
				}

				SCARAB_ASSERT( dung::SHA1_TO_TSTRING( action.newSha1 ) == value );
			}
			else if( Cmp( "old_size", key ) )
			{
				String_t value;
				if( !ParseNumValue( value ) )
				{
					m_errorMessage << "for old_size";
					return false;
				}
				action.oldSize = _tchar_to_long( value.c_str() );
			}
			else if( Cmp( "new_size", key ) )
			{
				String_t value;
				if( !ParseNumValue( value ) )
				{
					m_errorMessage << "for new_size";
					return false;
				}
				action.newSize = _tchar_to_long( value.c_str() );
			}
		}
		else if( m_tokenizer.IsSymbol() && m_tokenizer.GetSymbol() == '}' )
			return true;

		if( !m_tokenizer.ParseNext() )
		{
			m_errorMessage << "'}' expected for 'file'";
			process = false;
		}
	} while( process );

	return false;
}