Example #1
0
CParser::values CParser::ParseString(nstring input)
{
	CParser::values result;
	while(true)
	{
		found = input.find("  ");
		if(found == nstring::npos)
			break;
		input.replace(found, 2, " ");
	}

	while(input[0] == ' ') 
		input.erase(input.begin());
	while(input[input.length() - 1] == ' ') 
		input.erase(input.end()-1);

	while(true)
	{
		found = input.find(' ');
		parstr.clear();
		memset(value, 0, LINE_LENGTH);
		if(found != nstring::npos)
		{
			input.copy(value, found);
			input.erase(0, found+1);
			parstr.append(value);
			result.push_back(parstr);
		}
		else if(found == nstring::npos)
		{
			result.push_back(input);
			break;
		}
	}


	return result;
}
Example #2
0
nInt32 CParser::ParseStringRecurse(nstring input, CParser::values & result)
{
	if(input.empty())
		return 0;

	while(input[0] == ' ') {
		input.erase(input.begin());
		if(input.empty())
			return 0;
	}
	while(input[input.length() - 1] == ' ') {
		input.erase(input.end()-1);
		if(input.empty())
			return 0;
	}

	found = input.find(' ');
	parstr.clear();
	memset(value, 0, LINE_LENGTH);
	if(found != nstring::npos)
	{
		input.copy(value, found);
		input.erase(0, found+1);
		parstr.append(value);
		result.push_back(parstr);
	}
	else if(found == nstring::npos)
	{
		result.push_back(input);
		input.clear();
	}

	if(!input.empty())
		return ParseStringRecurse(input, result);

	return E_SUCCESS;
}