Beispiel #1
0
/*
	static
*/
void VValueBag::GetKeysFromPath( const VString& inPath, StKeyPath& outKeys)
{
	VFromUnicodeConverter_UTF8 converter;

	char buffer[256];
	VIndex charsConsumed;
	VSize bytesProduced;
	const UniChar *begin = inPath.GetCPointer();
	const UniChar *end = begin + inPath.GetLength();
	for( const UniChar *pos = begin ; pos != end ; ++pos)
	{
		if (*pos == '/')
		{
			bool ok = converter.Convert( begin, (VIndex) (pos - begin), &charsConsumed, buffer, sizeof( buffer), &bytesProduced);
			if (ok)
			{
				outKeys.push_back( StKey( buffer, bytesProduced));
			}
			begin = pos + 1;
		}
	}
	if (begin != end)
	{
		bool ok = converter.Convert( begin, (VIndex) (end - begin), &charsConsumed, buffer, sizeof( buffer), &bytesProduced);
		if (ok)
		{
			outKeys.push_back( StKey( buffer, bytesProduced));
		}
	}
}
// Note that the caller is responsible for freeing the memory
static char *CreateUTF8String( const VString &inSource )
{
	VFromUnicodeConverter_UTF8 converter;
	VIndex charsConsumed;
	VSize bytesProduced;
	char *ret = NULL;
	if (converter.Convert( inSource.GetCPointer(), inSource.GetLength() + 1, &charsConsumed, NULL, MaxLongInt, &bytesProduced )) {
		ret = new char[ bytesProduced ];
		converter.Convert( inSource.GetCPointer(), inSource.GetLength() + 1, &charsConsumed, ret, bytesProduced, &bytesProduced );
	}
	return ret;
}