예제 #1
0
파일: actions.cpp 프로젝트: AzyxWare/ryzom
static bool getParam (CBaseAction::CParameter::TType type, ucstring &paramName, ucstring &paramValue, const std::string &argu, uint paramId)
{
	const string separator = "|";
	const string equal_separator = "=";

	// Go to param start
	uint index = 0;
	string::size_type pos = 0;
	while (index != paramId)
	{
		// Not found ?
		pos = argu.find_first_of(separator, pos);
		if (pos == string::npos)
			return false;

		pos++;
		index++;
	}

	// Pos is valid ?
	if (pos < argu.size ())
	{
		// End
		string::size_type end = argu.find_first_of(separator, pos);
		if (end == string::npos)
			end = argu.size();

		// Look for a '='
		string::size_type equal = argu.find_first_of(equal_separator, pos);
		if ((equal != string::npos) && (equal >= end))
			equal = string::npos;

		// Equal is present ?
		if (equal != string::npos)
		{
			// Extract parameter name
			paramName = argu.substr(pos, equal-pos);
			pos = equal+1;
		}

		// Value ?
		if(type==CBaseAction::CParameter::User || type==CBaseAction::CParameter::UserName)
			paramValue.fromUtf8(argu.substr(pos, end-pos));
		else
			paramValue = argu.substr(pos, end-pos);

		// Ok
		return true;
	}
	return false;
}
예제 #2
0
파일: i_xml.cpp 프로젝트: sythaeryn/pndrpg
void CIXml::serial(ucstring &b)
{
	nlassert( isReading() );

	if (_BinaryStream)
	{
		_BinaryStream->serial(b);
	}
	else
	{
		// Serial a simple string
		string tmp;

		// Serial this string
		serial (tmp);

		// Return a ucstring
		b.fromUtf8(tmp);
	}
}