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


C++ idStr::Length方法代码示例

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


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

示例1: AddPathToTree

/*
================
CPathTreeCtrl::AddPathToTree

Adds a new item to the tree.
Assumes new paths after the current stack path do not yet exist.
================
*/
HTREEITEM CPathTreeCtrl::AddPathToTree( const idStr &pathName, const int id, idPathTreeStack &stack ) {
	int lastSlash;
	idStr itemName, tmpPath;
	HTREEITEM item;

	lastSlash = pathName.Last( '/' );

	while( stack.Num() > 1 ) {
		if ( pathName.Icmpn( stack.TopName(), stack.TopNameLength() ) == 0 ) {
			break;
		}
		stack.Pop();
	}

	while( lastSlash > stack.TopNameLength() ) {
		pathName.Mid( stack.TopNameLength(), pathName.Length(), tmpPath );
		tmpPath.Left( tmpPath.Find( '/' ), itemName );
		item = InsertItem( itemName, stack.TopItem() );
		stack.Push( item, itemName );
	}

	pathName.Mid( stack.TopNameLength(), pathName.Length(), itemName );
	item = InsertItem( itemName, stack.TopItem() );
	SetItemData( item, id );

	return item;
}
开发者ID:BielBdeLuna,项目名称:StormEngine2,代码行数:35,代码来源:CPathTreeCtrl.cpp

示例2: InsertPathIntoTree

/*
================
CPathTreeCtrl::InsertPathIntoTree

Inserts a new item going from the root down the tree only creating paths where necessary.
This is slow and should only be used to insert single items.
================
*/
HTREEITEM CPathTreeCtrl::InsertPathIntoTree( const idStr &pathName, const int id ) {
	int lastSlash;
	idStr path, tmpPath, itemName;
	HTREEITEM item, parentItem;

	parentItem = NULL;
	item = GetRootItem();

	lastSlash = pathName.Last( '/' );

	while( item && lastSlash > path.Length() ) {
		itemName = GetItemText( item );
		tmpPath = path + itemName;
		if ( pathName.Icmpn( tmpPath, tmpPath.Length() ) == 0 ) {
			parentItem = item;
			item = GetChildItem( item );
			path = tmpPath + "/";
		} else {
			item = GetNextSiblingItem( item );
		}
	}

	while( lastSlash > path.Length() ) {
		pathName.Mid( path.Length(), pathName.Length(), tmpPath );
		tmpPath.Left( tmpPath.Find( '/' ), itemName );
		parentItem = InsertItem( itemName, parentItem );
		path += itemName + "/";
	}

	pathName.Mid( path.Length(), pathName.Length(), itemName );
	item = InsertItem( itemName, parentItem, TVI_SORT );
	SetItemData( item, id );

	return item;
}
开发者ID:BielBdeLuna,项目名称:StormEngine2,代码行数:43,代码来源:CPathTreeCtrl.cpp

示例3: GetLastWhiteSpace

/*
================
idLexer::GetLastWhiteSpace
================
*/
int idLexer::GetLastWhiteSpace( idStr &whiteSpace ) const {
	whiteSpace.Clear();
	for ( const char *p = whiteSpaceStart_p; p < whiteSpaceEnd_p; p++ ) {
		whiteSpace.Append( *p );
	}
	return whiteSpace.Length();
}
开发者ID:c4tnt,项目名称:DLR,代码行数:12,代码来源:Lexer.cpp

示例4: GetMissionTitles

void CModInfo::GetMissionTitles(idStr missionTitles)
{
	if (modName.IsEmpty())
	{
		return;
	}

	int startIndex = 0;
	idStr start = "Mission 1 Title: ";
	idStr end   = "Mission 2 Title: ";
	int endIndex = missionTitles.Find(end.c_str(), true); // grayman #3733
	bool finished = false;
	for ( int i = 1 ; ; i++ )
	{
		idStr title = idStr(missionTitles, startIndex, endIndex); // grayman #3733
		Strip(start.c_str(), title);
		_missionTitles.Append(title);
		start = end;
		startIndex = endIndex;
		if (finished)
		{
			break;
		}
		end = va("Mission %d Title: ",i+2);
		endIndex = missionTitles.Find(end.c_str(), true, startIndex); // grayman #3733
		if (endIndex < 0)
		{
			endIndex = missionTitles.Length();
			finished = true;
		}
	}
}
开发者ID:jaredmitch,项目名称:executable,代码行数:32,代码来源:ModInfo.cpp

示例5: ParseTemplateArguments

/*
================
idTypeInfoTools::ParseTemplateArguments
================
*/
bool idTypeInfoTools::ParseTemplateArguments( idLexer &src, idStr &arguments ) {
	int indent;
	idToken token;

	arguments = "";

	if ( !src.ExpectTokenString( "<" ) ) {
		return false;
	}

	indent = 1;
	while( indent ) {
		if ( !src.ReadToken( &token ) ) {
			break;
		}
		if ( token == "<" ) {
			indent++;
		} else if ( token == ">" ) {
			indent--;
		} else {
			if ( arguments.Length() ) {
				arguments += " ";
			}
			arguments += token;
		}
	}
	return true;
}
开发者ID:,项目名称:,代码行数:33,代码来源:

示例6: TestDecl

/*
================
DialogDeclEditor::TestDecl
================
*/
bool DialogDeclEditor::TestDecl(const idStr &declText)
{
	idLexer src(LEXFL_NOSTRINGCONCAT);
	idToken token;
	int indent;

	src.LoadMemory(declText, declText.Length(), "decl text");

	indent = 0;

	while (src.ReadToken(&token)) {
		if (token == "{") {
			indent++;
		} else if (token == "}") {
			indent--;
		}
	}

	if (indent < 0) {
		MessageBox("Missing opening brace!", va("Error saving %s", decl->GetFileName()), MB_OK | MB_ICONERROR);
		return false;
	}

	if (indent > 0) {
		MessageBox("Missing closing brace!", va("Error saving %s", decl->GetFileName()), MB_OK | MB_ICONERROR);
		return false;
	}

	return true;
}
开发者ID:AreaScout,项目名称:dante-doom3-odroid,代码行数:35,代码来源:DialogDeclEditor.cpp

示例7:

/*
================
Sys_DefaultBasePath

Get the default base path
- binary image path
- current directory
- hardcoded
Try to be intelligent: if there is no BASE_GAMEDIR, try the next path
================
*/
const char *Sys_DefaultBasePath( void ) {
	struct stat st;
	idStr testbase;
	basepath = Sys_EXEPath();
	if( basepath.Length() ) {
		basepath.StripFilename();
		testbase = basepath;
		testbase += "/";
		testbase += BASE_GAMEDIR;
		if( stat( testbase.c_str(), &st ) != -1 && S_ISDIR( st.st_mode ) ) {
			return basepath.c_str();
		} else {
			common->Printf( "no '%s' directory in exe path %s, skipping\n", BASE_GAMEDIR, basepath.c_str() );
		}
	}
	if( basepath != Posix_Cwd() ) {
		basepath = Posix_Cwd();
		testbase = basepath;
		testbase += "/";
		testbase += BASE_GAMEDIR;
		if( stat( testbase.c_str(), &st ) != -1 && S_ISDIR( st.st_mode ) ) {
			return basepath.c_str();
		} else {
			common->Printf( "no '%s' directory in cwd path %s, skipping\n", BASE_GAMEDIR, basepath.c_str() );
		}
	}
	common->Printf( "WARNING: using hardcoded default base path\n" );
	return LINUX_DEFAULT_PATH;
}
开发者ID:revelator,项目名称:Revelation,代码行数:40,代码来源:main.cpp

示例8: setCustomModel

void idGLDrawableView::setCustomModel( const idStr modelName ) {

	if ( modelName.Length() ) {
		objectId = -1;
	} else {
		objectId = 0;
	}

	customModelName = modelName;

	UpdateModel();
}
开发者ID:0culus,项目名称:Doom3-for-MacOSX-,代码行数:12,代码来源:MaterialPreviewView.cpp

示例9: Update

/*
============
idInternalCVar::Update
============
*/
void idInternalCVar::Update( const idCVar *cvar )
{

    // if this is a statically declared variable
    if ( cvar->GetFlags() & CVAR_STATIC )
    {

        if ( flags & CVAR_STATIC )
        {

            // the code has more than one static declaration of the same variable, make sure they have the same properties
            if ( resetString.Icmp( cvar->GetString() ) != 0 )
            {
                common->Warning( "CVar '%s' declared multiple times with different initial value", nameString.c_str() );
            }
            if ( ( flags & (CVAR_BOOL|CVAR_INTEGER|CVAR_FLOAT) ) != ( cvar->GetFlags() & (CVAR_BOOL|CVAR_INTEGER|CVAR_FLOAT) ) )
            {
                common->Warning( "CVar '%s' declared multiple times with different type", nameString.c_str() );
            }
            if ( valueMin != cvar->GetMinValue() || valueMax != cvar->GetMaxValue() )
            {
                common->Warning( "CVar '%s' declared multiple times with different minimum/maximum", nameString.c_str() );
            }

        }

        // the code is now specifying a variable that the user already set a value for, take the new value as the reset value
        resetString = cvar->GetString();
        descriptionString = cvar->GetDescription();
        description = descriptionString.c_str();
        valueMin = cvar->GetMinValue();
        valueMax = cvar->GetMaxValue();
        Mem_Free( valueStrings );
        valueStrings = CopyValueStrings( cvar->GetValueStrings() );
        valueCompletion = cvar->GetValueCompletion();
        UpdateValue();
        cvarSystem->SetModifiedFlags( cvar->GetFlags() );
    }

    flags |= cvar->GetFlags();

    UpdateCheat();

    // only allow one non-empty reset string without a warning
    if ( resetString.Length() == 0 )
    {
        resetString = cvar->GetString();
    }
    else if ( cvar->GetString()[0] && resetString.Cmp( cvar->GetString() ) != 0 )
    {
        common->Warning( "cvar \"%s\" given initial values: \"%s\" and \"%s\"\n", nameString.c_str(), resetString.c_str(), cvar->GetString() );
    }
}
开发者ID:revelator,项目名称:Revelator-Doom3,代码行数:58,代码来源:CVarSystem.cpp

示例10: Sym_GetFuncInfo

/*
==================
Sym_GetFuncInfo
==================
*/
void Sym_GetFuncInfo( long addr, idStr &module, idStr &funcName )
{
    MEMORY_BASIC_INFORMATION mbi;
    module_t *m;
    symbol_t *s;

    VirtualQuery( (void*)addr, &mbi, sizeof(mbi) );

    for ( m = modules; m != NULL; m = m->next )
    {
        if ( m->address == (int) mbi.AllocationBase )
        {
            break;
        }
    }
    if ( !m )
    {
        Sym_Init( addr );
        m = modules;
    }

    for ( s = m->symbols; s != NULL; s = s->next )
    {
        if ( s->address == addr )
        {

            char undName[MAX_STRING_CHARS];
            if ( UnDecorateSymbolName( s->name, undName, sizeof(undName), UNDECORATE_FLAGS ) )
            {
                funcName = undName;
            }
            else
            {
                funcName = s->name;
            }
            for ( int i = 0; i < funcName.Length(); i++ )
            {
                if ( funcName[i] == '(' )
                {
                    funcName.CapLength( i );
                    break;
                }
            }
            module = m->name;
            return;
        }
    }

    sprintf( funcName, "0x%08x", addr );
    module = "";
}
开发者ID:revelator,项目名称:Revelator-Doom3,代码行数:56,代码来源:win_shared.cpp

示例11: ExecuteCommand

void CConsoleDlg::ExecuteCommand ( const idStr& cmd ) {
	CString str;
	if ( cmd.Length() > 0 ) {
		str = cmd;
	}
	else {
		editInput.GetWindowText(str);
	}

	if ( str != "" ) {			
		editInput.SetWindowText("");
		common->Printf("%s\n", str.GetBuffer(0));		

		//avoid adding multiple identical commands in a row
		int index = consoleHistory.Num ();

		if ( index == 0 || str.GetBuffer(0) != consoleHistory[index-1]) {					
			//keep the history to 16 commands, removing the oldest command
			if ( consoleHistory.Num () > 16 ) {
				consoleHistory.RemoveIndex ( 0 );
			}
			currentHistoryPosition = consoleHistory.Append ( str.GetBuffer (0) );    
		}
		else {
			currentHistoryPosition = consoleHistory.Num () - 1;
		}

		currentCommand.Clear ();

		bool propogateCommand = true;

		//process some of our own special commands
		if ( str.CompareNoCase ( "clear" ) == 0) {
			editConsole.SetSel ( 0 , -1 );
			editConsole.Clear ();
		}
		else if ( str.CompareNoCase ( "edit" ) == 0) {
			propogateCommand = false;
		}
		if ( propogateCommand ) {
			cmdSystem->BufferCommandText( CMD_EXEC_NOW, str );
		}

		Sys_UpdateWindows(W_ALL);
	}
}
开发者ID:,项目名称:,代码行数:46,代码来源:

示例12: ParseTimeString

TimerValue CStimResponseTimer::ParseTimeString( idStr &str ) {
	TimerValue v;
	int h, m, s, ms;
	idStr source = str;
	v.Time.Flags = TIMER_UNDEFINED;
	if( str.Length() == 0 ) {
		goto Quit;
	}
	h = m = s = ms = 0;
	// Get the first few characters that define the hours
	h = atoi( source.Left( source.Find( ":" ) ).c_str() );
	// Strip the first few numbers plus the colon from the source string
	source = source.Right( source.Length() - source.Find( ":" ) - 1 );
	// Parse the minutes
	m = atoi( source.Left( source.Find( ":" ) ).c_str() );
	if( !( m >= 0 && m <= 59 ) ) {
		DM_LOG( LC_STIM_RESPONSE, LT_ERROR )LOGSTRING( "Invalid minute string [%s]\r", str.c_str() );
		goto Quit;
	}
	// Strip the first few numbers plus the colon from the source string
	source = source.Right( source.Length() - source.Find( ":" ) - 1 );
	// Parse the seconds
	s = atoi( source.Left( source.Find( ":" ) ).c_str() );
	if( !( s >= 0 && s <= 59 ) ) {
		DM_LOG( LC_STIM_RESPONSE, LT_ERROR )LOGSTRING( "Invalid second string [%s]\r", str.c_str() );
		goto Quit;
	}
	// Parse the milliseconds, this is the remaining part of the string
	ms = atoi( source.Right( source.Length() - source.Find( ":" ) - 1 ).c_str() );
	if( !( ms >= 0 && ms <= 999 ) ) {
		DM_LOG( LC_STIM_RESPONSE, LT_ERROR )LOGSTRING( "Invalid millisecond string [%s]\r", str.c_str() );
		goto Quit;
	}
	DM_LOG( LC_STIM_RESPONSE, LT_DEBUG )LOGSTRING( "Parsed timer string: [%s] to %d:%d:%d:%d\r", str.c_str(), h, m, s, ms );
	v.Time.Hour = h;
	v.Time.Minute = m;
	v.Time.Second = s;
	v.Time.Millisecond = ms;
Quit:
	return v;
}
开发者ID:SL987654,项目名称:The-Darkmod-Experimental,代码行数:41,代码来源:StimResponseTimer.cpp

示例13: ApplySourceModify

/**
* Applies any source changes to the edit representation of the material.
*/
void MaterialDoc::ApplySourceModify(idStr& text) {
	
	if(sourceModify) {
		
		//Changes in the source need to clear any undo redo buffer because we have no idea what has changed
		manager->ClearUndo();
		manager->ClearRedo();

		ClearEditMaterial();

		idLexer		src;
		src.LoadMemory(text, text.Length(), "Material");

		src.SetFlags( 
			LEXFL_NOSTRINGCONCAT |			// multiple strings seperated by whitespaces are not concatenated
			LEXFL_NOSTRINGESCAPECHARS |		// no escape characters inside strings
			LEXFL_ALLOWPATHNAMES |			// allow path seperators in names
			LEXFL_ALLOWMULTICHARLITERALS |	// allow multi character literals
			LEXFL_ALLOWBACKSLASHSTRINGCONCAT |	// allow multiple strings seperated by '\' to be concatenated
			LEXFL_NOFATALERRORS				// just set a flag instead of fatal erroring
			);

		idToken token;
		if(!src.ReadToken(&token)) {
			src.Warning( "Missing decl name" );
			return;
		}
		
		ParseMaterial(&src);
		sourceModify = false;

		//Check to see if the name has changed
		if(token.Icmp(name)) {
			SetMaterialName(token, false);
		}
	}
}
开发者ID:Deepfreeze32,项目名称:taken,代码行数:40,代码来源:MaterialDoc.cpp

示例14: UpdateValue

/*
============
idInternalCVar::UpdateValue
============
*/
void idInternalCVar::UpdateValue( void ) {
	bool clamped = false;

	if ( flags & CVAR_BOOL ) {
		integerValue = ( atoi( value ) != 0 );
		floatValue = integerValue;
		if ( idStr::Icmp( value, "0" ) != 0 && idStr::Icmp( value, "1" ) != 0 ) {
			valueString = idStr( (bool)( integerValue != 0 ) );
			value = valueString.c_str();
		}
	} else if ( flags & CVAR_INTEGER ) {
		integerValue = (int)atoi( value );
		if ( valueMin < valueMax ) {
			if ( integerValue < valueMin ) {
				integerValue = (int)valueMin;
				clamped = true;
			} else if ( integerValue > valueMax ) {
				integerValue = (int)valueMax;
				clamped = true;
			}
		}
		if ( clamped || !idStr::IsNumeric( value ) || idStr::FindChar( value, '.' ) ) {
			valueString = idStr( integerValue );
			value = valueString.c_str();
		}
		floatValue = (float)integerValue;
	} else if ( flags & CVAR_FLOAT ) {
		floatValue = (float)atof( value );
		if ( valueMin < valueMax ) {
			if ( floatValue < valueMin ) {
				floatValue = valueMin;
				clamped = true;
			} else if ( floatValue > valueMax ) {
				floatValue = valueMax;
				clamped = true;
			}
		}
		if ( clamped || !idStr::IsNumeric( value ) ) {
			valueString = idStr( floatValue );
			value = valueString.c_str();
		}
		integerValue = (int)floatValue;
	} else {
		if ( valueStrings && valueStrings[0] ) {
			integerValue = 0;
			for ( int i = 0; valueStrings[i]; i++ ) {
				if ( valueString.Icmp( valueStrings[i] ) == 0 ) {
					integerValue = i;
					break;
				}
			}
			valueString = valueStrings[integerValue];
			value = valueString.c_str();
			floatValue = (float)integerValue;
		} else if ( valueString.Length() < 32 ) {
			floatValue = (float)atof( value );
			integerValue = (int)floatValue;
		} else {
			floatValue = 0.0f;
			integerValue = 0;
		}
	}
}
开发者ID:AndreiBarsan,项目名称:doom3.gpl,代码行数:68,代码来源:CVarSystem.cpp

示例15: ConvertCG2GLSL

/*
========================
ConvertCG2GLSL
========================
*/
idStr ConvertCG2GLSL( const idStr & in, const char * name, bool isVertexProgram, idStr & uniforms ) {
	idStr program;
	program.ReAllocate( in.Length() * 2, false );

	idList< inOutVariable_t, TAG_RENDERPROG > varsIn;
	idList< inOutVariable_t, TAG_RENDERPROG > varsOut;
	idList< idStr > uniformList;

	idLexer src( LEXFL_NOFATALERRORS );
	src.LoadMemory( in.c_str(), in.Length(), name );

	bool inMain = false;
	const char * uniformArrayName = isVertexProgram ? VERTEX_UNIFORM_ARRAY_NAME : FRAGMENT_UNIFORM_ARRAY_NAME;
	char newline[128] = { "\n" };

	idToken token;
	while ( src.ReadToken( &token ) ) {

		// check for uniforms
		while ( token == "uniform" && src.CheckTokenString( "float4" ) ) {
			src.ReadToken( &token );
			uniformList.Append( token );

			// strip ': register()' from uniforms
			if ( src.CheckTokenString( ":" ) ) {
				if ( src.CheckTokenString( "register" ) ) {
					src.SkipUntilString( ";" );
				}
			}

			src.ReadToken( & token );
		}

		// convert the in/out structs
		if ( token == "struct" ) {
			if ( src.CheckTokenString( "VS_IN" ) ) {
				ParseInOutStruct( src, AT_VS_IN, varsIn );
				program += "\n\n";
				for ( int i = 0; i < varsIn.Num(); i++ ) {
					if ( varsIn[i].declareInOut ) {
						program += "in " + varsIn[i].type + " " + varsIn[i].nameGLSL + ";\n";
					}
				}
				continue;
			} else if ( src.CheckTokenString( "VS_OUT" ) ) {
				ParseInOutStruct( src, AT_VS_OUT, varsOut );
				program += "\n";
				for ( int i = 0; i < varsOut.Num(); i++ ) {
					if ( varsOut[i].declareInOut ) {
						program += "out " + varsOut[i].type + " " + varsOut[i].nameGLSL + ";\n";
					}
				}
				continue;
			} else if ( src.CheckTokenString( "PS_IN" ) ) {
				ParseInOutStruct( src, AT_PS_IN, varsIn );
				program += "\n\n";
				for ( int i = 0; i < varsIn.Num(); i++ ) {
					if ( varsIn[i].declareInOut ) {
						program += "in " + varsIn[i].type + " " + varsIn[i].nameGLSL + ";\n";
					}
				}
				inOutVariable_t var;
				var.type = "vec4";
				var.nameCg = "position";
				var.nameGLSL = "gl_FragCoord";
				varsIn.Append( var );
				continue;
			} else if ( src.CheckTokenString( "PS_OUT" ) ) {
				ParseInOutStruct( src, AT_PS_OUT, varsOut );
				program += "\n";
				for ( int i = 0; i < varsOut.Num(); i++ ) {
					if ( varsOut[i].declareInOut ) {
						program += "out " + varsOut[i].type + " " + varsOut[i].nameGLSL + ";\n";
					}
				}
				continue;
			}
		}

		// strip 'static'
		if ( token == "static" ) {
			program += ( token.linesCrossed > 0 ) ? newline : ( token.WhiteSpaceBeforeToken() > 0 ? " " : "" );
			src.SkipWhiteSpace( true ); // remove white space between 'static' and the next token
			continue;
		}

		// strip ': register()' from uniforms
		if ( token == ":" ) {
			if ( src.CheckTokenString( "register" ) ) {
				src.SkipUntilString( ";" );
				program += ";";
				continue;
			}
		}

//.........这里部分代码省略.........
开发者ID:MWisBest,项目名称:idTech4Prime,代码行数:101,代码来源:RenderProgs_GLSL.cpp


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