Esempio n. 1
0
bool CGPGroup::Parse(char **dataPtr, CTextPool **textPool)
{
	char		*token;
	char		lastToken[MAX_TOKEN_SIZE];
	CGPGroup	*newSubGroup;
	CGPValue	*newPair;

	while(1)
	{
		token = GetToken(dataPtr, true);

		if (!token[0])
		{	// end of data - error!
			if (mParent)
			{
				return false;
			}
			else
			{
				break;
			}
		}
		else if (strcmpi(token, "}") == 0)
		{	// ending brace for this group
			break;
		}

		strcpy(lastToken, token);

		// read ahead to see what we are doing
		token = GetToken(dataPtr, true, true);
		if (strcmpi(token, "{") == 0)
		{	// new sub group
			newSubGroup = AddGroup(lastToken, textPool);
			newSubGroup->SetWriteable(mWriteable);
			if (!newSubGroup->Parse(dataPtr, textPool))
			{
				return false;
			}
		}
		else if (strcmpi(token, "[") == 0)
		{	// new pair list
			newPair = AddPair(lastToken, 0, textPool);
			if (!newPair->Parse(dataPtr, textPool))
			{
				return false;
			}
		}
		else
		{	// new pair
			AddPair(lastToken, token, textPool);
		}
	}

	return true;
}
Esempio n. 2
0
void CGPGroup::Parse(char **dataPtr, CTextPool **textPool)
{
	char		*token;
	char		lastToken[MAX_TOKEN_SIZE];
	CGPGroup	*newSubGroup;
	CGPValue	*newPair;
	char		*name, *value;

	while(1)
	{
		token = GetToken(dataPtr, true);

		if (!token[0])
		{	// end of data - error!
			break;
		}
		else if (Q_strcmpi(token, "}") == 0)
		{	// ending brace for this group
			break;
		}

		strcpy(lastToken, token);

		// read ahead to see what we are doing
		token = GetToken(dataPtr, true, true);
		if (Q_strcmpi(token, "{") == 0)
		{	// new sub group
			name = (*textPool)->AllocText(lastToken, true, textPool);
			newSubGroup = AddGroup(name);
			newSubGroup->SetWriteable(mWriteable);
			newSubGroup->Parse(dataPtr, textPool);
		}
		else if (Q_strcmpi(token, "[") == 0)
		{	// new pair list
			name = (*textPool)->AllocText(lastToken, true, textPool);
			newPair = AddPair(name, 0);
			newPair->Parse(dataPtr, textPool);
		}
		else
		{	// new pair
			name = (*textPool)->AllocText(lastToken, true, textPool);
			value = (*textPool)->AllocText(token, true, textPool);
			AddPair(name, value);
		}
	}
}