• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ VStr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Join

Str Join(double** str, int len1, int len2) {
  VStr tmp;
  for (int i = 0; i < len1; i++) {
    tmp.push_back(Join(str[i], len2));
  }
  return Join(tmp, "\n");
}
开发者ID:lijiankou,项目名称:mllib-1,代码行数:7,代码来源:join.cpp


示例2: StrSplit

VStr StrSplit(string theString, char dlim){
	istringstream iss(theString);
	VStr result;
	string tmp;
	while(!iss.eof() ){
		getline(iss , tmp, dlim );
		result.push_back(tmp);
	}
	return result;
}
开发者ID:onionys,项目名称:ns4c,代码行数:10,代码来源:StrProc.cpp


示例3: newVStrFromFile

VStr * newVStrFromFile(fstream &infile){
	VStr *allLine = new VStr;

	while(! infile.eof() ){
		string tmp;
		getline(infile,tmp,'\n');
		allLine->push_back(tmp);
	}
//	infile.close();
	return allLine;
}
开发者ID:onionys,项目名称:ns4c,代码行数:11,代码来源:StrProc.cpp


示例4: Info_RemoveKey

void Info_RemoveKey(VStr& s, const VStr& key)
{
    guard(Info_RemoveKey);
    if (s.IsEmpty())
    {
        return;
    }
    if (s.Length() >= MAX_INFO_STRING)
    {
        Host_Error("Info_RemoveKey: oversize infostring");
    }

    if (strchr(*key, '\\'))
    {
        GCon->Log("Can't use a key with a \\");
        return;
    }

    int i = 0;
    while (1)
    {
        int start = i;
        if (s[i] == '\\')
            i++;
        int KeyStart = i;
        while (s[i] != '\\')
        {
            if (!s[i])
                return;
            i++;
        }
        VStr pkey(s, KeyStart, i - KeyStart);
        i++;

        int ValStart = i;
        while (s[i] != '\\' && s[i])
        {
            i++;
        }
        VStr value(s, ValStart, i - ValStart);

        if (!key.Cmp(pkey))
        {
            s = VStr(s, 0, start) + VStr(s, i, s.Length() - i);	// remove this part
            return;
        }

        if (!s[i])
            return;
    }
    unguard;
}
开发者ID:JoshEngebretson,项目名称:Mongrel,代码行数:52,代码来源:infostr.cpp


示例5: DumpXMLIndentation

void VValueBag::DumpXMLIndentation(VString& ioDump, sLONG inIndentLevel)
{
	sLONG level = Min<sLONG>(100L, inIndentLevel);

	VStr<100>	indent;
	UniChar* ptr = indent.GetCPointerForWrite();
//	ptr[0] = 13;
	for (sLONG i = 0 ; i < level ; ++i)
		ptr[i] = CHAR_CONTROL_0009;	// tab
	indent.Validate(level);

	ioDump += indent;
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:13,代码来源:VValueBag.cpp


示例6: Info_SetValueForKey

void Info_SetValueForKey(VStr& s, const VStr& key, const VStr& value)
{
    guard(Info_SetValueForKey);
    if (s.Length() >= MAX_INFO_STRING)
    {
        Host_Error("Info_SetValueForKey: oversize infostring");
    }

    if (strchr(*key, '\\') || strchr(*value, '\\'))
    {
        GCon->Log("Can't use keys or values with a \\");
        return;
    }

    if (strchr(*key, '\"') || strchr(*value, '\"'))
    {
        GCon->Log("Can't use keys or values with a \"");
        return;
    }

    // this next line is kinda trippy
    VStr v = Info_ValueForKey(s, key);
    if (v.IsNotEmpty())
    {
        //	Key exists, make sure we have enough room for new value, if we
        // don't, don't change it!
        if (value.Length() - v.Length() + s.Length() > MAX_INFO_STRING)
        {
            GCon->Log("Info string length exceeded");
            return;
        }
    }

    Info_RemoveKey(s, key);
    if (value.IsEmpty())
        return;

    VStr newi = VStr("\\") + key + "\\" +  value;

    if (newi.Length() + s.Length() > MAX_INFO_STRING)
    {
        GCon->Log("Info string length exceeded");
        return;
    }

    s = s + newi;
    unguard;
}
开发者ID:JoshEngebretson,项目名称:Mongrel,代码行数:48,代码来源:infostr.cpp


示例7: FindMainWad

static VStr FindMainWad(VStr MainWad)
{
	//	First check in IWAD directories.
	for (int i = 0; i < IWadDirs.Num(); i++)
	{
		if (Sys_FileExists(IWadDirs[i] + "/" + MainWad))
		{
			return IWadDirs[i] + "/" + MainWad;
		}
	}

	//	Then look in the save directory.
	if (fl_savedir.IsNotEmpty() && Sys_FileExists(fl_savedir + "/" + MainWad))
	{
		return fl_savedir + "/" + MainWad;
	}

	//	Finally in base directory.
	if (Sys_FileExists(fl_basedir + "/" + MainWad))
	{
		return fl_basedir + "/" + MainWad;
	}

	return VStr();
}
开发者ID:JoshEngebretson,项目名称:Mongrel,代码行数:25,代码来源:files.cpp


示例8: Name

VCvar::VCvar(const char* AName, const VStr& ADefault, int AFlags)
: Name(AName)
, Flags(AFlags | CVAR_Delete)
{
	guard(VCvar::VCvar);
	char* Tmp = new char[ADefault.Length() + 1];
	VStr::Cpy(Tmp, *ADefault);
	DefaultString = Tmp;

	VCvar *prev = NULL;
	for (VCvar *var = Variables; var; var = var->Next)
	{
		if (VStr::ICmp(var->Name, Name) < 0)
		{
			prev = var;
		}
	}

	if (prev)
	{
		Next = prev->Next;
		prev->Next = this;
	}
	else
	{
		Next = Variables;
		Variables = this;
	}

	check(Initialised);
	Register();
	unguard;
}
开发者ID:JoshEngebretson,项目名称:Mongrel,代码行数:33,代码来源:cvar.cpp


示例9: FL_CreatePath

void FL_CreatePath(const VStr& Path)
{
	guard(FL_CreatePath);
	VStr Temp = Path;
	for (size_t i = 3; i <= Temp.Length(); i++)
	{
		if (Temp[i] == '/' || Temp[i] == '\\' || Temp[i] == 0)
		{
			char Save = Temp[i];
			Temp[i] = 0;
			if (!Sys_DirExists(Temp))
				Sys_CreateDirectory(Temp);
			Temp[i] = Save;
		}
	}
	unguard;
}
开发者ID:JoshEngebretson,项目名称:Mongrel,代码行数:17,代码来源:files.cpp


示例10: StrSplitBy2Space

// split string by dlim == '  ' (two space)
VStr StrSplitBy2Space(string str){
	string ttmp= str;
	VStr res;
	string ts("\n\n");
	for(int i = 0 ;i < ttmp.size()-1;i++ ){
		if (ttmp.c_str()[i] == ' ' && ttmp.c_str()[i+1] == ' ')
			ttmp.replace(i,2,ts);
	}
	istringstream iss(ttmp);
	while(!iss.eof() ){
		string tmp;
		getline(iss,tmp );
		if(tmp.size() == 0) continue;
		res.push_back(tmp);
	}
	return res;
}
开发者ID:onionys,项目名称:ns4c,代码行数:18,代码来源:StrProc.cpp


示例11: FL_OpenFileWrite

VStream* FL_OpenFileWrite(const VStr& Name)
{
	guard(FL_OpenFileWrite);
	VStr TmpName;

	if (fl_savedir.IsNotEmpty())
		TmpName = fl_savedir + "/" + fl_gamedir + "/" + Name;
	else
		TmpName = fl_basedir + "/" + fl_gamedir + "/" + Name;
	FL_CreatePath(TmpName.ExtractFilePath());
	FILE *File = fopen(*TmpName, "wb");
	if (!File)
	{
		return NULL;
	}
	return new VStreamFileWriter(File, GCon);
	unguard;
}
开发者ID:JoshEngebretson,项目名称:Mongrel,代码行数:18,代码来源:files.cpp


示例12: Info_ValueForKey

VStr Info_ValueForKey(const VStr& s, const VStr& key)
{
    guard(Info_ValueForKey);
    if (s.IsEmpty() || key.IsEmpty())
    {
        return VStr();
    }

    if (s.Length() >= MAX_INFO_STRING)
    {
        Host_Error("Info_ValueForKey: oversize infostring");
    }

    int i = 0;
    if (s[i] == '\\')
        i++;
    while (1)
    {
        int Start = i;
        while (s[i] != '\\')
        {
            if (!s[i])
                return VStr();
            i++;
        }
        VStr pkey(s, Start, i - Start);
        i++;

        Start = i;
        while (s[i] != '\\' && s[i])
        {
            i++;
        }

        if (!key.ICmp(pkey))
            return VStr(s, Start, i - Start);

        if (!s[i])
            return VStr();
        i++;
    }
    unguard;
}
开发者ID:JoshEngebretson,项目名称:Mongrel,代码行数:43,代码来源:infostr.cpp


示例13: AddGameDir

static void AddGameDir(const VStr& dir)
{
	guard(AddGameDir);
	AddGameDir(fl_basedir, dir);
	if (fl_savedir.IsNotEmpty())
	{
		AddGameDir(fl_savedir, dir);
	}
	fl_gamedir = dir;
	unguard;
}
开发者ID:JoshEngebretson,项目名称:Mongrel,代码行数:11,代码来源:files.cpp


示例14: guard

bool VZipFile::FileExists(const VStr& FName)
{
	guard(VZipFile::FileExists);
	VStr CheckName = FName.ToLower();
	for (int i = 0; i < NumFiles; i++)
	{
		if (Files[i].Name == CheckName)
		{
			return true;
		}
	}
	return false;
	unguard;
}
开发者ID:JoshEngebretson,项目名称:Mongrel,代码行数:14,代码来源:fs_zip.cpp


示例15: GetNthAttribute

void VValueBag::DumpXMLCData( VString& ioDump, VIndex inCDataAttributeIndex) const
{
	VStr<1000> cdata;

	GetNthAttribute( inCDataAttributeIndex, NULL)->GetString( cdata);

	if (NeedsEscapeSequence( cdata, sXMLEscapeChars_Contents, sXMLEscapeChars_Contents + sizeof(sXMLEscapeChars_Contents)/sizeof(UniChar)))
	{
		ioDump += CVSTR( "<![CDATA[");

		// see if there's a "]]>" for which we need to split
		// someting like: hello ]]> world
		// becomes: <![CDATA[hello ]]>]]<![CDATA[> world]]>
		
		VIndex pos = 1;
		while( pos <= cdata.GetLength())
		{
			VIndex endTag = cdata.Find( CVSTR( "]]>"), pos, true);
			if (endTag > 0)
			{
				// add everything including ]]>
				ioDump.AppendBlock( cdata.GetCPointer() + pos - 1, (endTag - pos + 3) * sizeof( UniChar), VTC_UTF_16);
				// add ]] outside CDATA section
				ioDump.AppendString( CVSTR( "]]"));
				// open a new CDATA section and add remaining >
				ioDump += CVSTR( "<![CDATA[>");
				pos = endTag + 3;
			}
			else
			{
				// add everything left
				ioDump.AppendBlock( cdata.GetCPointer() + pos - 1, (cdata.GetLength() - pos + 1) * sizeof( UniChar), VTC_UTF_16);
				break;
			}
		}
		ioDump += CVSTR( "]]>");
	}
	else
	{
		VString toInsert;
		for (sLONG i = 0, n = cdata.GetLength(); i < n; i++)
		{
			UniChar c = cdata[ i ];
			if (c != 13 && c != 10 && c != 9)
			{
				toInsert += c;
			}
		}
		if ( ! toInsert.IsEmpty() )
			ioDump += toInsert;
	}
}
开发者ID:StephaneH,项目名称:core-XToolbox,代码行数:52,代码来源:VValueBag.cpp


示例16: saveVStrToFilename

int saveVStrToFilename(VStr _strs, string _savefile){
	ofstream outfile;
	outfile.open(_savefile.c_str());
	if(outfile.is_open() != true  ){
		printf("open file %s error",_savefile.c_str());
		return -1;
	}

	for(int i = 0 ;i < _strs.size() ;i++ ){
		outfile << _strs[i] << "\n";
	}

	outfile.close();
	return 1;
}
开发者ID:onionys,项目名称:ns4c,代码行数:15,代码来源:StrProc.cpp


示例17: guard

void VMemberBase::StaticSplitStateLabel(const VStr& LabelName,
                                        TArray<VName>& Parts)
{
    guard(VMemberBase::StaticSplitStateLabel);
    TArray<VStr> StrParts;
    LabelName.Split(".", StrParts);
    Parts.Clear();
    //	Remap old death state labels to proper names.
    if (StrParts[0] == "XDeath")
    {
        Parts.Append("Death");
        Parts.Append("Extreme");
    }
    else if (StrParts[0] == "Burn")
    {
        Parts.Append("Death");
        Parts.Append("Fire");
    }
    else if (StrParts[0] == "Ice")
    {
        Parts.Append("Death");
        Parts.Append("Ice");
    }
    else if (StrParts[0] == "Disintegrate")
    {
        Parts.Append("Death");
        Parts.Append("Disintegrate");
    }
    else
    {
        Parts.Append(*StrParts[0]);
    }
    for (int i = 1; i < StrParts.Num(); i++)
    {
        Parts.Append(*StrParts[i]);
    }
    unguard;
}
开发者ID:JoshEngebretson,项目名称:Mongrel,代码行数:38,代码来源:vc_member.cpp


示例18: ParseBase

static void ParseBase(const VStr& name)
{
	guard(ParseBase);
	TArray<version_t>	games;
	bool				select_game;
	VStr				UseName;

	if (fl_savedir.IsNotEmpty() && Sys_FileExists(fl_savedir + "/" + name))
	{
		UseName = fl_savedir + "/" + name;
	}
	else if (Sys_FileExists(fl_basedir + "/" + name))
	{
		UseName = fl_basedir + "/" + name;
	}
	else
	{
		return;
	}

	select_game = false;
	VScriptParser* sc = new VScriptParser(UseName, FL_OpenSysFileRead(UseName));
	while (!sc->AtEnd())
	{
		version_t &dst = games.Alloc();
		dst.ParmFound = 0;
		dst.FixVoices = false;
		sc->Expect("game");
		sc->ExpectString();
		dst.GameDir = sc->String;
		if (sc->Check("iwad"))
		{
			sc->ExpectString();
			dst.MainWad = sc->String;
		}
		while (sc->Check("addfile"))
		{
			sc->ExpectString();
			dst.AddFiles.Append(sc->String);
		}
		if (sc->Check("param"))
		{
			sc->ExpectString();
			dst.ParmFound = GArgs.CheckParm(*sc->String);
			if (dst.ParmFound)
			{
				select_game = true;
			}
		}
		if (sc->Check("fixvoices"))
		{
			dst.FixVoices = true;
		}
		sc->Expect("end");
	}
	delete sc;
	sc = NULL;

	for (int gi = games.Num() - 1; gi >= 0; gi--)
	{
		version_t& G = games[gi];
		if (select_game && !G.ParmFound)
		{
			continue;
		}
		if (fl_mainwad.IsNotEmpty())
		{
			if (G.MainWad.IsEmpty() || G.MainWad == fl_mainwad || select_game)
			{
				if (!bIwadAdded)
				{
					IWadIndex = SearchPaths.Num();
					VStr MainWadPath = FindMainWad(fl_mainwad);
					W_AddFile(MainWadPath, fl_savedir, G.FixVoices);
					bIwadAdded = true;
				}
				for (int j = 0; j < G.AddFiles.Num(); j++)
				{
					W_AddFile(fl_basedir + "/" + G.AddFiles[j], fl_savedir,
						false);
				}
				SetupGameDir(G.GameDir);
				return;
			}
			continue;
		}
		if (G.MainWad.IsEmpty())
		{
			continue;
		}

		//	Look for the main wad file.
		VStr MainWadPath = FindMainWad(G.MainWad);
		if (MainWadPath.IsNotEmpty())
		{
			fl_mainwad = G.MainWad;
			if (!bIwadAdded)
			{
				IWadIndex = SearchPaths.Num();
				W_AddFile(MainWadPath, fl_savedir, G.FixVoices);
//.........这里部分代码省略.........
开发者ID:JoshEngebretson,项目名称:Mongrel,代码行数:101,代码来源:files.cpp


示例19: C_Responder

bool C_Responder(event_t* ev)
{
	const char*	cp;
	VStr		str;
	int			i;
	bool		eat;

	//  Respond to events only when console is active
	if (!C_Active())
		return false;

	//	We are iterested only in key down events
	if (ev->type != ev_keydown)
		return false;

	switch (ev->data1)
	{
	// Close console
	case K_ESCAPE:
		if (consolestate != cons_open)
			return false;

	case '`':
		if (consolestate == cons_closing)
			C_Start();
		else
			C_Stop();
		return true;

	// Execute entered command
	case K_ENTER:
	case K_PADENTER:
		//	Print it
		GCon->Logf(">%s", c_iline.Data);

		//	Add to history
		c_history_last = (MAXHISTORY + c_history_last - 1) % MAXHISTORY;
		if (c_history_size < MAXHISTORY)
			c_history_size++;
		VStr::Cpy(c_history[c_history_last], c_iline.Data);
		c_history_current = -1;

		//	Add to command buffer
		GCmdBuf << c_iline.Data << "\n";

		//	Clear line
		c_iline.Init();
		c_autocompleteIndex = -1;
		return true;

	// Scroll lines up
	case K_PAGEUP:
		for (i = 0; i < (GInput->ShiftDown ? 1 : 5); i++)
		{
			if (last_line > 1)
			{
				last_line--;
			}
		}
		return true;

	// Scroll lines down
	case K_PAGEDOWN:
		for (i = 0; i < (GInput->ShiftDown ? 1 : 5); i++)
		{
			if (last_line < num_lines)
			{
				last_line++;
			}
		}
		return true;

	// Go to first line
	case K_HOME:
		last_line = 1;
		return true;

	// Go to last line
	case K_END:
		last_line = num_lines;
		return true;

	// Command history up
	case K_UPARROW:
		c_history_current++;
		c_iline.Init();
		if (c_history_current >= c_history_size)
		{
			c_history_current = c_history_size;
		}
		else
		{
			cp = c_history[(c_history_last +
				c_history_current) % MAXHISTORY];
			while (*cp) c_iline.AddChar(*cp++);
		}
		c_autocompleteIndex = -1;
		return true;

	// Command history down
//.........这里部分代码省略.........
开发者ID:JoshEngebretson,项目名称:Mongrel,代码行数:101,代码来源:console.cpp


示例20: guard

void VInvocation::CheckDecorateParams(VEmitContext& ec)
{
	guard(VInvocation::CheckDecorateParams);
	int max_params;
	int num_needed_params = Func->NumParams;
	if (Func->Flags & FUNC_VarArgs)
	{
		max_params = VMethod::MAX_PARAMS - 1;
	}
	else
	{
		max_params = Func->NumParams;
	}
	if (NumArgs > max_params)
	{
		ParseError(Loc, "Incorrect number of arguments, need %d, got %d.", max_params, NumArgs);
	}

	for (int i = 0; i < NumArgs; i++)
	{
		if (i >= num_needed_params)
		{
			continue;
		}
		if (!Args[i])
		{
			continue;
		}
		switch (Func->ParamTypes[i].Type)
		{
		case TYPE_Name:
			if (Args[i]->IsDecorateSingleName())
			{
				VDecorateSingleName* E = (VDecorateSingleName*)Args[i];
				Args[i] = new VNameLiteral(*E->Name, E->Loc);
				delete E;
				E = NULL;
			}
			else if (Args[i]->IsStrConst())
			{
				VStr Val = Args[i]->GetStrConst(ec.Package);
				TLocation ALoc = Args[i]->Loc;
				delete Args[i];
				Args[i] = NULL;
				Args[i] = new VNameLiteral(*Val, ALoc);
			}
			break;

		case TYPE_String:
			if (Args[i]->IsDecorateSingleName())
			{
				VDecorateSingleName* E = (VDecorateSingleName*)Args[i];
				Args[i] = new VStringLiteral(ec.Package->FindString(*E->Name), E->Loc);
				delete E;
				E = NULL;
			}
			break;

		case TYPE_Class:
			if (Args[i]->IsDecorateSingleName())
			{
				VDecorateSingleName* E = (VDecorateSingleName*)Args[i];
				Args[i] = new VStringLiteral(ec.Package->FindString(*E->Name), E->Loc);
				delete E;
				E = NULL;
			}
			if (Args[i]->IsStrConst())
			{
				VStr CName = Args[i]->GetStrConst(ec.Package);
				TLocation ALoc = Args[i]->Loc;
				VClass* Cls = VClass::FindClassNoCase(*CName);
				if (!Cls)
				{
					ParseWarning(ALoc, "No such class %s", *CName);
					delete Args[i];
					Args[i] = NULL;
					Args[i] = new VNoneLiteral(ALoc);
				}
				else if (Func->ParamTypes[i].Class &&
					!Cls->IsChildOf(Func->ParamTypes[i].Class))
				{
					ParseWarning(ALoc, "Class %s is not a descendant of %s",
						*CName, Func->ParamTypes[i].Class->GetName());
					delete Args[i];
					Args[i] = NULL;
					Args[i] = new VNoneLiteral(ALoc);
				}
				else
				{
					delete Args[i];
					Args[i] = NULL;
					Args[i] = new VClassConstant(Cls, ALoc);
				}
			}
			break;

		case TYPE_State:
			if (Args[i]->IsIntConst())
			{
				int Offs = Args[i]->GetIntConst();
//.........这里部分代码省略.........
开发者ID:JoshEngebretson,项目名称:Mongrel,代码行数:101,代码来源:vc_expr_invoke.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ VString类代码示例发布时间:2022-05-31
下一篇:
C++ VSocket类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap