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::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;
}
Example #3
0
void CzString::Split(char split_char, CzSlotArray<CzString*>* strings)
{
	char* pData = Data;

	FindReset();
	strings->clear();
	int start = 0, len = 0;
	for (int t = 0; t < Length + 1; t++)
	{
		char c = *pData++;
		if (c == split_char || c == 0)
		{
			CzString* s = new CzString();
			s->setString(Data + start, t - start);
			start = t + 1;
			strings->add(s);
		}
	}
}
Example #4
0
int CzString::GetNextMarkedStringAfterString(const char* search_string, char start_mark, char end_mark, CzString& out_string)
{
	int pos = FindNext(search_string);
	if (pos >= 0)
	{
		// Get the text label
		int offset;
		StepFindIndex(strlen(search_string));
		int len = GetNextMarkedString(start_mark, end_mark, offset);
		if (len > 0)
		{
			out_string.setString(getString() + offset, len);
			return pos;
		}
		
		return -1;
	}

	return -1;
}
Example #5
0
bool CzAds::ExtractAdAdFonic(CzAd& ad, CzString& ad_body)
{
	// We dont use a full on XML parser to parse the returned XML, instead we just search for the required info
	int pos, offset, len;

	ad.isHtml = false;
	ad.isText = false;
	ad.ImageURI = "";
	ad.LinkURI = "";
	ad.Text = "";
	ad.AdTime = PLATFORM_SYS->getTimeInMs();

	// Get Error Response
	ad_body.FindReset();
	pos = ad_body.FindNext("<status");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('>', '<', offset);
		if (len > 0)
		{
			ErrorString.setString(ad_body.getString() + offset, len);
			if (ErrorString == "error")
			{
				Error = ErrorInternalError;
				return false;
			}
			else
				Error = ErrorNone;
		}
	}

	// Get Ad format
	pos = ad_body.FindNext("<format");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('>', '<', offset);
		if (len > 0)
		{
			CzString format;
			format.setString(ad_body.getString() + offset, len);
			if (format == "banner")
				ad.isText = false;
			else
				ad.isText = true;

#if defined(_DEBUG)
			CzDebug::Log(CZ_DEBUG_CHANNEL_INFO, "Ad Format: ", ad.Text.c_str());
#endif	// _DEBUG
		}
	}

	// Get Ad text
	pos = ad_body.FindNext("<![CDATA[");
	if (pos >= 0)
	{
		int end_pos = ad_body.FindNext("]]>");
		if (end_pos > 0)
		{
			ad.Text.setString(ad_body.getString() + pos + 9, end_pos - pos - 9);
#if defined(_DEBUG)
			CzDebug::Log(CZ_DEBUG_CHANNEL_INFO, "Ad Text: ", ad.Text.c_str());
#endif	// _DEBUG
			ad.isHtml = true;
		}
	}
	ad_body.FindReset();

	// Get Ad link
	pos = ad_body.FindNext("url=");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('"', '"', offset);
		if (len > 0)
		{
			ad.LinkURI.setString(ad_body.getString() + offset, len);
#if defined(_DEBUG)
			CzDebug::Log(CZ_DEBUG_CHANNEL_INFO, "Ad Click URL: ", ad.LinkURI.c_str());
#endif	// _DEBUG
		}
	}

	// Get Ad image
	pos = ad_body.FindNext("src=");
	if (pos >= 0)
	{
		len = ad_body.GetNextMarkedString('"', '"', offset);
		if (len > 0)
		{
			ad.ImageURI.setString(ad_body.getString() + offset, len);
#if defined(_DEBUG)
			CzDebug::Log(CZ_DEBUG_CHANNEL_INFO, "Ad Image URL: ", ad.ImageURI.c_str());
#endif	// _DEBUG
		}
	}

	return true;
}