Пример #1
0
char * InPlaceParser::AddHard(int &argc,const char **argv,char *foo)
{
	while ( IsHard(*foo) )
	{
		const char *hard = &mHardString[*foo*2];
		if ( argc < MAXARGS )
		{
			argv[argc++] = hard;
		}
		foo++;
	}
	return foo;
}
Пример #2
0
	//==================================================================================
	int32 InPlaceParser::ProcessLine(int32 lineno,char *line,InPlaceParserInterface *callback)
	{
		int32 ret = 0;

		const char *argv[MAXARGS];
		int32 argc = 0;

		char *foo = line;

		while ( !EOS(*foo) && argc < MAXARGS )
		{
			foo = SkipSpaces(foo); // skip any leading spaces

			if ( EOS(*foo) ) 
				break;

			if ( *foo == mQuoteChar ) // if it is an open quote
			{
				++foo;
				if ( argc < MAXARGS )
				{
					argv[argc++] = foo;
				}
				while ( !EOS(*foo) && *foo != mQuoteChar ) 
					++foo;
				if ( !EOS(*foo) )
				{
					*foo = 0; // replace close quote with zero byte EOS
					++foo;
				}
			}
			else
			{
				foo = AddHard(argc,argv,foo); // add any hard separators, skip any spaces

				if ( IsNonSeparator(*foo) )  // add non-hard argument.
				{
					bool quote  = false;
					if ( *foo == mQuoteChar )
					{
						++foo;
						quote = true;
					}

					if ( argc < MAXARGS )
					{
						argv[argc++] = foo;
					}

					if ( quote )
					{
						while (*foo && *foo != mQuoteChar ) 
							++foo;
						if ( *foo ) 
							*foo = 32;
					}

					// continue..until we hit an eos ..
					while ( !EOS(*foo) ) // until we hit EOS
					{
						if ( IsWhiteSpace(*foo) ) // if we hit a space, stomp a zero byte, and exit
						{
							*foo = 0;
							++foo;
							break;
						}
						else if ( IsHard(*foo) ) // if we hit a hard separator, stomp a zero byte and store the hard separator argument
						{
							const char *hard = &mHardString[*foo*2];
							*foo = 0;
							if ( argc < MAXARGS )
							{
								argv[argc++] = hard;
							}
							++foo;
							break;
						}
						++foo;
					} // end of while loop...
				}
			}
		}

		if ( argc )
		{
			ret = callback->ParseLine(lineno, argc, argv );
		}

		return ret;
	}
Пример #3
0
	//==================================================================================
	bool InPlaceParser::IsNonSeparator(char c)
	{
		return ( !IsHard(c) && !IsWhiteSpace(c) && c != 0 );
	}
Пример #4
0
bool InPlaceParser::IsNonSeparator(char c)
{
	if ( !IsHard(c) && !IsWhiteSpace(c) && c != 0 ) return true;
	return false;
}