Example #1
0
bool CzString::SplitVarIndex(CzString& var, int& index, CzString& vindex)
{
	char* pData = Data;
	index = -1;

	FindReset();

	// Split string at colon char and return value after colon
	for (int t = 0; t < Length; t++)
	{
		if (*pData++ == ':')
		{
			var.setString(Data, t);
			vindex.Copy(pData, 0, Length - t - 1);
			if (CzString::IsNumber(*pData))
				index = vindex.getAsInt();
			return true;
		}
	}

	// No split found so just copy this string to output
	var = *this;

	return true;
}
Example #2
0
bool CzString::SplitFilename(CzString& filename, CzString& ext)
{
	int index = 0;
	
	// Find the dot
	for (int t = getLength() - 1; t != 0; t--)
	{
		if (*(Data + t) == '.')
		{
			index = t;
			break;
		}
	}
	if (index == 0) return false;
	
	filename.Copy(Data, 0, index);
	ext.Copy(Data, index + 1, getLength() - index - 1);
	
	return true;
}
Example #3
0
CzStringList* CzXmlAttribute::getValueAsList()
{
	CzStringList* pList = new CzStringList;
	
	// Separate Value by commas
	int			len = Value.getLength();
	const char* text = Value.c_str();
	char		c;
	
	while ((c = *text) != 0)
	{
		// Find a none white space
		if (c != ' ' && c != '\t' && c != '\n' && c != ',')
		{
			int count = 0;
			const char* found = text;
			
			// Find end of string
			while (count++ < 63)
			{
				c = *text;
				if (c == '\n' || c == ',' || c == 0)
					break;
				text++;
			}
			int len = text - found;
			if (len > 0)
			{
				CzString *pString = new CzString();
				pString->Copy((char*)found, 0, len);
			
				pList->push_back(pString);
			}
			if (c == 0) break;
		}
		text++;
	}

	return pList;
}
Example #4
0
bool CzString::SplitPropVarIndex(CzString& prop, CzString& var, int& index, CzString& vindex)
{
	char* pData = Data;
	index = -1;

	FindReset();

	// Get property
	int pos = StepFindIndexNoneWhiteSpace();
	if (pos < 0)
		return false;
	int start_pos = 0;
	int len = GetNextMarkedString('[', ']', start_pos);
	if (len >= 0)
		prop.setString(Data + start_pos, len);
	if (StepFindIndex(1) == Length)
		return false;

	// Split string at colon char and return value after colon
	pData += FindIndex;
	for (int t = 0; t < Length - FindIndex; t++)
	{
		if (*pData++ == ':')
		{
			var.setString(Data + FindIndex, t);
			vindex.Copy(pData, 0, Length - t - 1);
			if (CzString::IsNumber(*pData))
				index = vindex.getAsInt();

			return true;
		}
	}

	// No split found so just copy out the var
	var.setString(Data + FindIndex, Length - FindIndex);

	return true;
}