当前位置: 首页>>代码示例>>C++>>正文


C++ TString::GetLength方法代码示例

本文整理汇总了C++中TString::GetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ TString::GetLength方法的具体用法?C++ TString::GetLength怎么用?C++ TString::GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TString的用法示例。


在下文中一共展示了TString::GetLength方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetFestivalClass

int VAISNAVADAY::GetFestivalClass(TString &str)
{
	int i, j, val;

	i = str.Find("[c");

	if (i >= 0)
	{
//		i += 2;
		if ((i + 2) < str.GetLength())
		{
			val = int(str.GetAt(i+2) - '0');
			j = str.Find("]", i);
			if (j >= str.GetLength())
				j = str.GetLength();
			if (j > i)
			{
				str.Delete(i, j - i + 1);
			}
			if (val < 0 || val > 6)
				return -1;
			return val;
		}
		else
			return -1;
	}
	else
	{
		return -1;
	}

}
开发者ID:gopa810,项目名称:SamskaraTimes,代码行数:32,代码来源:GCVaisnavaDay.cpp

示例2: ReadNextFloatArray

//--------------------------------------------------------
//	
//--------------------------------------------------------
Bool TLString::ReadNextFloatArray(const TString& String,u32& CharIndex,float* pFloats,u32 FloatSize,Bool ReturnInvalidFloatZero)
{
	//	loop through parsing seperators and floats
	u32 FloatIndex = 0;
	while ( FloatIndex < FloatSize )
	{
		//	step over whitespace
		s32 NonWhitespaceIndex = String.GetCharIndexNonWhitespace( CharIndex );

		//	no more non-whitespace? no more floats then
		if ( NonWhitespaceIndex == -1 )
			return FALSE;

		//	move char past whitespace
		CharIndex = (u32)NonWhitespaceIndex;

		s32 NextComma = String.GetCharIndex(',', CharIndex);
		s32 NextWhitespace = String.GetCharIndexWhitespace( CharIndex );
		s32 NextSplit = String.GetLength();

		if ( NextComma != -1 && NextComma < NextSplit )
			NextSplit = NextComma;
		if ( NextWhitespace != -1 && NextWhitespace < NextSplit )
			NextSplit = NextWhitespace;

		//	split
		TTempString Stringf;
		Stringf.Append( String, CharIndex, NextSplit-CharIndex );
		if ( !Stringf.GetFloat( pFloats[FloatIndex] ) )
		{
			//	gr: this is a work around when processing floats but encounter invalid floats in strings... say 1.1e07 (invalid floats from outputter)
			if ( ReturnInvalidFloatZero )
			{
				pFloats[FloatIndex] = 0.f;
			}
			else
			{
				TLDebug_Break("Failed to parse first float");
				return FALSE;
			}
		}

		//	next float
		FloatIndex++;

		//	move string along past split
		CharIndex = NextSplit+1;

		//	out of string
		if ( CharIndex >= String.GetLength() )
		{
			CharIndex = String.GetLength();
			break;
		}
	}

	return TRUE;
}
开发者ID:SoylentGraham,项目名称:Tootle,代码行数:61,代码来源:TLFile.cpp

示例3: jsBotSay

static enum v7_err jsBotSay(struct v7 *v7, v7_val_t *res) {
	long argc = v7_argc(v7);
	if (argc == 0) {
		return V7_OK;
	}
	v7_val_t v = v7_arg(v7, 0);
	if (!v7_is_string(v)) {
		return V7_OK;
	}
	TString str = (const char*)v7_to_cstring(v7, &v);
	TString font;
	if (argc >= 2) {
		v7_val_t fontt = v7_arg(v7, 1);
		if (!v7_is_null(fontt) && !v7_is_undefined(fontt)) font = (const char*)v7_to_cstring(v7, &fontt);
	}
	int size = 0;
	if (argc >= 3) {
		v7_val_t sizee = v7_arg(v7, 2);
		if (v7_is_number(sizee)) size = floor(v7_to_number(sizee));
		if (size < 10) size = 10;
	}
	TString col;
	if (argc >= 4) {
		v7_val_t coll = v7_arg(v7, 3);
		if (v7_is_string(coll)) col = (const char*)v7_to_cstring(v7, &coll);
		if (col.GetAt(0) != L'#' || col.GetLength() != 7) col = L"";
	}
	_activeBot->say(str, font, size, col);
	return V7_OK;
}
开发者ID:slashbmp,项目名称:bmpbot-v7,代码行数:30,代码来源:Bot.cpp

示例4: ReadString

int TFile::ReadString(TString &str)
{
	int rp;

	if (feof(m_fHandle))
		return 0;

	str = "";

	while(rp = fgetc(m_fHandle), !feof(m_fHandle))
	{
		if (rp == 0x0a || rp == 0x0d)
		{
			if (m_cend == -1)
				m_cend = rp;
			if (m_cend == rp)
				break;
		}
		else
		{
			str += char(rp);
		}
	}

	if (feof(m_fHandle))
		return 0;

	return str.GetLength();
}
开发者ID:gopa810,项目名称:gcal-cpp,代码行数:29,代码来源:TFile.cpp

示例5: GetFastingSubject

void VAISNAVADAY::GetFastingSubject(TString &strFest, int &nFast, TString &strFastSubj)
{
	int nf, nf2;

	// default values
	nFast = 0;
	strFastSubj.Empty();

	// finding fast subject
	nf = strFest.Find("[f:");
	if (nf >= 0 && nf < strFest.GetLength())
	{
		// ziskava typ postu
		nFast = strFest.GetAt(nf+3) - '0';
		nf2 = strFest.Find("]", nf);
		if (nf2 >= 0)
		{
			strFest.Mid(nf + 5, nf2 - nf - 5, strFastSubj);
		}
		strFest.Delete(nf, strFest.GetLength() - nf);
	}
}
开发者ID:gopa810,项目名称:SamskaraTimes,代码行数:22,代码来源:GCVaisnavaDay.cpp

示例6: ReadNextInteger

//--------------------------------------------------------
//	
//--------------------------------------------------------
Bool TLString::ReadNextInteger(const TString& String,u32& CharIndex,s32& Integer)
{
	//	step over whitespace
	s32 NonWhitespaceIndex = String.GetCharIndexNonWhitespace( CharIndex );

	//	no more non-whitespace? no more data then
	if ( NonWhitespaceIndex == -1 )
		return FALSE;

	//	move char past whitespace
	CharIndex = (u32)NonWhitespaceIndex;

	s32 NextComma = String.GetCharIndex(',', CharIndex);
	s32 NextWhitespace = String.GetCharIndexWhitespace( CharIndex );
	s32 NextSplit = String.GetLength();

	if ( NextComma != -1 && NextComma < NextSplit )
		NextSplit = NextComma;
	if ( NextWhitespace != -1 && NextWhitespace < NextSplit )
		NextSplit = NextWhitespace;

	//	split
	TTempString StringValue;
	StringValue.Append( String, CharIndex, NextSplit-CharIndex );
	if ( !StringValue.GetInteger( Integer ) )
	{
		TLDebug_Break("Failed to parse integer from string");
		return FALSE;
	}

	//	move string along past split
	CharIndex = NextSplit+1;

	//	out of string
	if ( CharIndex >= String.GetLength() )
		CharIndex = String.GetLength();

	return TRUE;
}
开发者ID:SoylentGraham,项目名称:Tootle,代码行数:42,代码来源:TLFile.cpp

示例7: GetCol

DWORD GetCol(const wchar_t* str) {
	int i = 0;
	TString strChk = str;
	if (strChk.GetLength() < 6) return 0;
	if (strChk.GetAt(i) == L'#') i++;
	wchar_t r[2], g[2], b[2];
	r[0] = strChk.GetAt(i++);
	r[1] = strChk.GetAt(i++);
	g[0] = strChk.GetAt(i++);
	g[1] = strChk.GetAt(i++);
	b[0] = strChk.GetAt(i++);
	b[1] = strChk.GetAt(i);
	int rr = h2a2(r);
	int gg = h2a2(g);
	int bb = h2a2(b);
	return RGB(rr, gg, bb);
}
开发者ID:slashbmp,项目名称:bmpbot-v7,代码行数:17,代码来源:Bot.cpp

示例8: setFontStyle

void Bot::setFontStyle(TString& fontName, int fontSize, COLORREF fontColor) {
	if (!fontName.IsEQ(L"")) memcpy(_charset.font, fontName.GetAsChar(), fontName.GetLength() * sizeof(char));
	if (fontSize != NULL) _charset.size = fontSize;
	if (fontColor != NULL) _charset.color = fontColor;
}
开发者ID:slashbmp,项目名称:bmpbot-v7,代码行数:5,代码来源:Bot.cpp

示例9: ImportBinaryData


//.........这里部分代码省略.........
	case TLBinary_TypeRef(TColour32):
	{
		Type4<s32> Colours;
		if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.x ) )		return SyncFalse;
		if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.y ) )		return SyncFalse;
		if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.z ) )		return SyncFalse;
		if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.w ) )		return SyncFalse;
		
		//	check range
		//	gr: use TLDebug_CheckInRange() ?
		if ( Colours.x > 255 || Colours.x < 0 ||
			Colours.y > 255 || Colours.y < 0 ||
			Colours.z > 255 || Colours.z < 0 ||
			Colours.w > 255 || Colours.w < 0 )
		{
			if ( !TLDebug_Break( TString("Colour32 type has components out of range (0..255); %d,%d,%d,%d", Colours.x, Colours.y, Colours.z, Colours.w ) ) )
				return SyncFalse;
		}

		TColour32 Colour( Colours.x, Colours.y, Colours.z, Colours.w );
		BinaryData.Write( Colour );
		return SyncTrue;
	}
	
	case TLBinary_TypeRef(TColour64):
	{
		Type4<s32> Colours;
		if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.x ) )		return SyncFalse;
		if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.y ) )		return SyncFalse;
		if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.z ) )		return SyncFalse;
		if ( !TLString::ReadNextInteger( DataString, CharIndex, Colours.w ) )		return SyncFalse;
		
		//	check range
		//	gr: use TLDebug_CheckInRange() ?
		if ( Colours.x > 65535 || Colours.x < 0 ||
			Colours.y > 65535 || Colours.y < 0 ||
			Colours.z > 65535 || Colours.z < 0 ||
			Colours.w > 65535 || Colours.w < 0 )
		{
			if ( !TLDebug_Break( TString("Colour64 type has components out of range (0..65535); %d,%d,%d,%d", Colours.x, Colours.y, Colours.z, Colours.w ) ) )
				return SyncFalse;
		}

		TColour64 Colour( Colours.x, Colours.y, Colours.z, Colours.w );
		BinaryData.Write( Colour );
		return SyncTrue;
	}

	case TLBinary_TypeRef(u8):
		return ImportBinaryDataIntegerInRange<u8>( BinaryData, DataString );

	case TLBinary_TypeRef(s8):
		return ImportBinaryDataIntegerInRange<s8>( BinaryData, DataString );

	case TLBinary_TypeRef(u16):
		return ImportBinaryDataIntegerInRange<u16>( BinaryData, DataString );

	case TLBinary_TypeRef(s16):
		return ImportBinaryDataIntegerInRange<s16>( BinaryData, DataString );

	case TLBinary_TypeRef(u32):
		return ImportBinaryDataIntegerInRange<u32>( BinaryData, DataString );

	case TLBinary_TypeRef(s32):
		return ImportBinaryDataIntegerInRange<s32>( BinaryData, DataString );

	case TLBinary_TypeRef(Bool):
	{
		//	read first char, we can work out true/false/0/1 from that
		if ( DataString.GetLength() == 0 )
			return SyncFalse;
		const TChar& BoolChar = DataString.GetCharAt(0);
		if ( BoolChar == 't' || BoolChar == 'T' || BoolChar == '1' )
		{
			BinaryData.Write( (Bool)TRUE );
			return SyncTrue;
		}
		else if ( BoolChar == 'f' || BoolChar == 'F' || BoolChar == '0' )
		{
			BinaryData.Write( (Bool)FALSE );
			return SyncTrue;
		}
		else
		{
			TLDebug_Break("Bool data is not True,False,0 or 1");
			return SyncFalse;
		}
	}

	default:
		break;
	};
	

	TDebugString Debug_String;
	Debug_String << "Unsupported/todo data type " << DataType << ". Data string: [" << DataString << "]";
	TLDebug_Break( Debug_String );

	return SyncFalse;
}
开发者ID:SoylentGraham,项目名称:Tootle,代码行数:101,代码来源:TLFile.cpp


注:本文中的TString::GetLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。