本文整理汇总了C++中VStr类的典型用法代码示例。如果您正苦于以下问题:C++ VStr类的具体用法?C++ VStr怎么用?C++ VStr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VStr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}