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


C++ CStr::TrimLeft方法代码示例

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


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

示例1: wcslen

int
CIniFile::Split( const CStr &source, LPCTSTR sep, CStrArray &dest, BOOL trim /* = TRUE */ )
{
	int pos = source.Find( sep );
	int startPos = 0;
	CStr elem;
	int sepLen = wcslen( sep );

	dest.RemoveAll();
	while( pos != -1 )
	{
		elem = source.Mid( startPos, pos-startPos );
        if ( trim ) { elem.TrimLeft(); elem.TrimRight(); }
		dest.Add( elem );

		startPos = pos+sepLen;
		pos      = source.Find( sep, startPos );
	}
	elem = source.Mid( startPos );
    if ( trim ) { elem.TrimLeft(); elem.TrimRight(); }
	dest.Add( elem );

	return dest.GetSize();
}
开发者ID:grainrigi,项目名称:jscripts,代码行数:24,代码来源:IniFile.cpp

示例2: if

CValue *GetVariable( CStr &var, BOOL create, int *position, BOOL local )
{
	int     pos, startPos;
	bool	oldStyle = false, reference = false, isPtr = false;
	CStr entryName;
	CMapStrToValue *map = NULL;
	CValue  *value;
	CValue *dummy;

	pos = 0;
	if ( !local )
	{
		if ( LocalVariables != NULL && LocalVariables->Lookup( L"%AUTOLOCAL%", dummy ) )
			local = TRUE;
	}

	// Skip spaces
	while ( pos < var.GetLength() && GetCharacterType( var[pos] ) == CInterpreter::CHAR_WHITESPACE ) pos++;
	
	if ( pos < var.GetLength() && var[pos] == L'%' )
	{
		oldStyle = true;
		pos++;
		while ( pos < var.GetLength() && GetCharacterType( var[pos] ) == CInterpreter::CHAR_WHITESPACE ) pos++;
	}
	
	if ( create && pos < var.GetLength() && var[pos] == L'[' )
	{
		reference = true;
		pos++;
		while ( pos < var.GetLength() && GetCharacterType( var[pos] ) == CInterpreter::CHAR_WHITESPACE ) pos++;
	}

	startPos = pos;
	// Skip all valid variable name characters
	while (    pos < var.GetLength()
		    && (   GetCharacterType( var[pos] ) == CInterpreter::CHAR_ALPHA
			    || GetCharacterType( var[pos] ) == CInterpreter::CHAR_DIGIT
				|| GetCharacterType( var[pos] ) == CInterpreter::CHAR_UNDERSCORE
				|| (var[pos] == L':' && (pos == startPos || pos == startPos + 1 ))
			)
		  ) pos++;
	// Skip Regex variable name characters
	if ((var[pos]==L'$') && (pos+1<var.GetLength())){
		if (   var[pos+1] == L'&' 
			|| var[pos+1] == L'`' 
			|| var[pos+1] == L'\'' 
			|| var[pos+1] == L'+' 
			|| var[pos+1] == L'_'
			)pos +=2;
		else{
			int i=0;
			for (i=1;i<=3;i++){
				if ( pos+i<var.GetLength() && var[pos+i] >=L'0' && var[pos+i]<=L'9') { /* do nothing */ }else break;
			}
			pos+=i;
		}
	}
	
	// Skip spaces
	while ( pos < var.GetLength() && GetCharacterType( var[pos] ) == CInterpreter::CHAR_WHITESPACE ) pos++;

	//jwz:add for Global Variable
	if (var[startPos]==L':' && var[startPos+1]==L':'){
		local = FALSE;
		startPos +=2;
	}

	// No array index?
	if ( pos == -1 || pos >= var.GetLength() || var[pos] != L'[' )
	{
		entryName = var;

		if ( pos != -1 && pos <= var.GetLength() )
			entryName = var.Mid( startPos, pos-startPos );


		entryName.TrimLeft();
		entryName.TrimRight();

		if ( position != NULL ) 
			*position = pos;

		if ( entryName.IsEmpty())
		{
			VarError = L"Empty variable name not allowed";
			if ( position != NULL ) *position = -1;
			return NULL;
		}

		entryName.MakeUpper();

		if ( local && LocalVariables != NULL && LocalVariables->Lookup( L"%GL_" + entryName + L"%", dummy ) ) //predefined GLOBAL declare variable
		{
			local = FALSE;
		}

		if ( local && LocalVariables != NULL && LocalVariables->Lookup( entryName, value ) ) {}
		else if ( local == FALSE && Variables.Lookup( entryName, value ) ) {}
		else
//.........这里部分代码省略.........
开发者ID:grainrigi,项目名称:jscripts,代码行数:101,代码来源:variables.cpp

示例3: CMapStrToString

void
CIniFile::Parse( LPCTSTR cont )
{
	CStr content = cont;
	CStr sectionName, key, value;
    CMapStrToString *section = NULL;
	BOOL hasEmptySection = FALSE;

	Sections.RemoveAll();

	while ( content.GetLength() > 0 )
	{
		CStr line;
		int pos = content.Find( _T("\n") );
		if ( pos != -1 )
		{
			line    = content.Left( pos );
			content = content.Mid( pos+1 );
		}
		else
		{
			line = content;
			content = _T("");
		}
		line.TrimLeft(); line.TrimRight();

		if ( line.GetLength() > 0 && line.GetAt(0) != '#' && line.GetAt(0) != ';' )
		{
			if ( line.GetAt(0) == '[' && line.Right(1) == L"]" )
			{
				sectionName = line.Mid( 1, line.GetLength()-2 );
                sectionName.MakeLower();
                section = new CMapStrToString();
                Sections.SetAt( sectionName, section );
			}
			else
			{
				int eqPos = line.Find( '=' );
				if ( eqPos != -1 )
				{
					key   = line.Left( eqPos );
					key.TrimLeft(); key.TrimRight();
					value = line.Mid( eqPos+1 );
					value.TrimLeft(); value.TrimRight();
					if ( value.Left(1) == L"\"" && value.Right(1) == L"\"" )
					{
						value = value.Mid( 1, value.GetLength()-2 );
					}
					key.MakeLower();
					if ( section == NULL && hasEmptySection == FALSE )
					{
						section = new CMapStrToString();
						Sections.SetAt( L"", section );
						hasEmptySection = TRUE;
					}
					section->SetAt( key, value );
				}
			}
		}
	}
}
开发者ID:grainrigi,项目名称:jscripts,代码行数:61,代码来源:IniFile.cpp


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