本文整理汇总了C++中STRINGLIST类的典型用法代码示例。如果您正苦于以下问题:C++ STRINGLIST类的具体用法?C++ STRINGLIST怎么用?C++ STRINGLIST使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了STRINGLIST类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddLine
void QuestActionContainer :: AddLine(const char *statement)
{
STRINGLIST commands;
Util::Split(statement, ";", commands);
for(size_t i = 0; i < commands.size(); i++)
AddCommand(commands[i]);
}
示例2: PlaySound
void AINutPlayer::PlaySound(const char *name) {
STRINGLIST sub;
Util::Split(name, "|", sub);
while (sub.size() < 2) {
sub.push_back("");
}
attachedCreature->SendPlaySound(sub[0].c_str(), sub[1].c_str());
}
示例3: InitCommand
bool ExtendedQuestAction :: InitCommand(const STRINGLIST &tokenList)
{
if(tokenList.size() < 1)
return false;
const QuestScriptCommandDef *cmd = GetCommandDef(tokenList[0]);
if(cmd == 0)
{
g_Logs.data->warn("Quest command not recognized [%v]", tokenList[0].c_str());
return false;
}
size_t tokenCount = tokenList.size();
if(tokenCount != cmd->numParams + 1) //First token is command itself
{
g_Logs.data->warn("Expected [%v] arguments for command [%v]", cmd->numParams, cmd->name);
return false;
}
opCode = cmd->opCode;
for(int i = 0; i < cmd->numParams; i++)
{
bool valid = false;
int result = 0;
valid = ResolveOperand(tokenList[1 + i], cmd->paramType[i], result);
if(valid == false)
return false;
param[i] = result;
}
return true;
/*
int opCode = GetCondition(tokenList[0]);
size_t tokenCount = tokenList.size();
int p1 = 0;
int p2 = 0;
int p3 = 0;
switch(opCode)
{
case CONDITION_HASSTAT:
if(ExpectTokens(tokenCount, 4) == false) return false;
p1 = GetStatIDByName(tokenList[1]);
p2 = GetComparator(tokenList[2]);
p3 = Util::GetFloat(tokenList[3]);
if(p1 == -1 || p2 == COMP_NONE)
return false;
break;
case CONDITION_HASITEM:
if(ExpectTokens(tokenCount, 3) == false) return false;
p1 = Util::GetInteger(tokenList[1]);
p2 = Util::GetInteger(tokenList[2]);
break;
}
commandType = opCode;
param1 = p1;
param2 = p2;
param3 = p3;
return true;
*/
}
示例4: EnumCategoryList
void IGFManager :: EnumCategoryList(int parentID, MULTISTRING &output)
{
STRINGLIST entry;
CATEGORYPAGE::iterator it;
IGFCategoryPage::CATEGORYENTRY::iterator eit;
for(it = mCategoryPages.begin(); it != mCategoryPages.end(); ++it)
{
for(eit = it->second.mEntries.begin(); eit != it->second.mEntries.end(); ++eit)
{
if(eit->second.mParentCategory == parentID)
{
entry.push_back(ConvertInteger(TYPE_CATEGORY));
entry.push_back(ConvertInteger(eit->second.mID));
entry.push_back(ConvertInteger(eit->second.mLocked));
entry.push_back(ConvertInteger(0)); //Stickied. Categories don't have this.
entry.push_back(eit->second.mTitle);
entry.push_back(ConvertInteger(eit->second.mThreadList.size()));
entry.push_back(ConvertInteger(GetTimeOffset(eit->second.mLastUpdateTime)));
output.push_back(entry);
entry.clear();
}
}
}
}
示例5: d
const char * Platform::Filename(const char *path)
{
STRINGLIST v;
const std::string p = path;
const std::string d(1, PLATFORM_FOLDERVALID);
Util::Split(p, d.c_str(), v);
if(v.size() == 0)
return "";
else
return v[v.size() - 1].c_str();
}
示例6: AssignFloatArrayFromStringSplit
//Break a comma-delimited string into tokens, then loading the converted values into a raw array of floats.
void AssignFloatArrayFromStringSplit(float *arrayDest, size_t arraySize, const std::string &strData)
{
STRINGLIST strArray;
Split(strData, ",", strArray);
for(size_t i = 0; i < strArray.size(); i++)
{
if(i >= arraySize)
return;
arrayDest[i] = static_cast<float>(atof(strArray[i].c_str()));
}
}
示例7: if
const char * Platform::Extension(const char *path)
{
STRINGLIST v;
const std::string p = Filename(path);
const std::string d(1, PLATFORM_FOLDERVALID);
Util::Split(p, ".", v);
if(v.size() == 0)
return "";
else if(v.size() == 1)
return v[0].c_str();
else
return v[v.size() - 1].c_str();
}
示例8: EnumThreadList
void IGFManager :: EnumThreadList(int parentID, MULTISTRING &output)
{
IGFCategory* category = GetPagedCategoryPtr(parentID);
if(category == NULL)
return;
//Pregenerate a list of threads
std::vector<IGFThread*> results;
for(size_t i = 0; i < category->mThreadList.size(); i++)
{
IGFThread* thread = GetPagedThreadPtr(category->mThreadList[i]);
if(thread != NULL)
results.push_back(thread);
}
if(category->mFlags.hasFlag(IGFFlags::FLAG_SORTALPHABETICAL))
std::sort(results.begin(), results.end(), ThreadSortAlphabetical);
STRINGLIST entry;
for(size_t i = 0; i < results.size(); i++)
{
IGFThread* thread = results[i];
entry.push_back(ConvertInteger(TYPE_THREAD));
entry.push_back(ConvertInteger(thread->mID));
entry.push_back(ConvertInteger(thread->mLocked));
entry.push_back(ConvertInteger(thread->mStickied));
entry.push_back(thread->mTitle);
entry.push_back(ConvertInteger(thread->mPostList.size()));
entry.push_back(ConvertInteger(GetTimeOffset(thread->mLastUpdateTime)));
output.push_back(entry);
entry.clear();
}
}
示例9: CleanPriorityMap
void CServerDefinitions::LoadDFNCategory( DEFINITIONCATEGORIES toLoad )
{
CleanPriorityMap();
defaultPriority = 0;
UI08 wasPriod = 2;
BuildPriorityMap( toLoad, wasPriod );
cDirectoryListing fileList( toLoad, defExt );
fileList.Flatten( true );
STRINGLIST *shortListing = fileList.FlattenedShortList();
STRINGLIST *longListing = fileList.FlattenedList();
std::vector< PrioScan > mSort;
for( size_t i = 0; i < shortListing->size(); ++i )
{
mSort.push_back( PrioScan( (*longListing)[i].c_str(), GetPriority( (*shortListing)[i].c_str() ) ) );
}
if( !mSort.empty() )
{
std::sort( mSort.begin(), mSort.end() );
Console.Print( "Section %20s : %6i", dirnames[toLoad].c_str(), 0 );
size_t iTotal = 0;
Console.TurnYellow();
std::vector< PrioScan >::const_iterator mIter;
for( mIter = mSort.begin(); mIter != mSort.end(); ++mIter )
{
Console.Print( "\b\b\b\b\b\b" );
ScriptListings[toLoad].push_back( new Script( (*mIter).filename, toLoad, false ) );
iTotal += ScriptListings[toLoad].back()->NumEntries();
Console.Print( "%6i", iTotal );
}
Console.Print( "\b\b\b\b\b\b%6i", CountOfEntries( toLoad ) );
Console.TurnNormal();
Console.Print( " entries" );
switch( wasPriod )
{
case 0: Console.PrintSpecial( CGREEN, "prioritized" ); break; // prioritized
case 1:
Console.PrintSpecial( CGREEN, "done" );
break; // file exist, no section
default:
case 2:
Console.PrintSpecial( CBLUE, "done" );
break; // no file
};
}
}
示例10: Filename
const char * Platform::Basename(const char *path)
{
STRINGLIST v;
const std::string p = Filename(path);
const std::string d(1, PLATFORM_FOLDERVALID);
Util::Split(p, ".", v);
if(v.size() == 0)
return "";
else {
std::string t;
v.erase(v.end() - 1);
Util::Join(v, d.c_str(), t);
return t.c_str();
}
}
示例11: GetCategory
void IGFManager :: GetCategory(int id, MULTISTRING &output)
{
IGFCategory *category = GetPagedCategoryPtr(id);
if(category == NULL)
return;
STRINGLIST header;
header.push_back(ConvertInteger(id));
header.push_back(category->mTitle);
output.push_back(header);
EnumCategoryList(id, output);
EnumThreadList(id, output);
}
示例12: priorityFile
void CServerDefinitions::BuildPriorityMap( DEFINITIONCATEGORIES category, UI08& wasPrioritized )
{
cDirectoryListing priorityFile( category, "priority.nfo", false );
STRINGLIST *longList = priorityFile.List();
if( longList->size() > 0 )
{
std::string filename = (*longList)[0];
// Do we have any priority informat?
if( FileExists( filename ) ) // the file exists, so perhaps we do
{
Script *prio = new Script( filename, category, false ); // generate a script for it
if( prio != NULL ) // successfully made a script
{
UString tag;
UString data;
ScriptSection *prioInfo = prio->FindEntry( "PRIORITY" ); // find the priority entry
if( prioInfo != NULL )
{
for( tag = prioInfo->First(); !prioInfo->AtEnd(); tag = prioInfo->Next() ) // keep grabbing priority info
{
data = prioInfo->GrabData();
if( tag.upper() == "DEFAULTPRIORITY" )
defaultPriority = data.toShort();
else
{
std::string filenametemp = tag.lower();
priorityMap[filenametemp] = data.toShort();
}
}
wasPrioritized = 0;
}
else
wasPrioritized = 1;
delete prio; // remove script
prio = NULL;
}
else
wasPrioritized = 2;
return;
}
}
#if defined( UOX_DEBUG_MODE )
// Console.Warning( "Failed to open priority.nfo for reading in %s DFN", dirnames[category].c_str() );
#endif
wasPrioritized = 2;
}
示例13: TokenizeByWhitespace
// Tokenize a string using whitespace as separators, but including string quotations.
void TokenizeByWhitespace(const std::string &input, STRINGLIST &output)
{
std::string str = input;
output.clear();
size_t len = str.size();
int first = -1;
int last = -1;
bool quote = false;
bool terminate = false;
for(size_t i = 0; i < len; i++)
{
switch(input[i])
{
case '"':
terminate = true; //Treat opening quote as a block start
quote = !quote;
break;
case ' ':
case '\t':
case '\n':
case '\r':
if(quote == false)
terminate = true;
break;
default:
if(first == -1)
first = i;
last = i;
}
if(terminate == true)
{
if(first >= 0 && last >= 0)
{
std::string t = str.substr(first, last - first + 1);
output.push_back(str.substr(first, last - first + 1));
first = -1;
last = -1;
}
terminate = false;
}
}
if(first != -1 && first < (int)len)
output.push_back(str.substr(first, len - first + 1));
}
示例14: AddCommand
void QuestActionContainer :: AddCommand(const std::string &command)
{
STRINGLIST tokens;
//Util::Split(command, " ", tokens);
Util::TokenizeByWhitespace(command, tokens);
if(tokens.size() == 0)
{
g_Logs.data->warn("No tokens in command.");
return;
}
ExtendedQuestAction inst;
if(inst.InitCommand(tokens) == true)
{
//Debug disassembly
//g_Log.AddMessageFormat("%s = [%d]=%d,%d,%d", command.c_str(), inst.opCode, inst.param[0], inst.param[1], inst.param[2]);
mInstList.push_back(inst);
}
}
示例15: OpenCategory
void IGFManager :: OpenCategory(int type, int id, MULTISTRING &output)
{
//Expand an object. If it's a category, enumerate a list of subcategories.
if(type == TYPE_CATEGORY)
{
IGFCategory *category = GetPagedCategoryPtr(id);
if(category != NULL)
{
STRINGLIST header;
header.push_back(ConvertInteger(id));
header.push_back(category->mTitle);
output.push_back(header);
int searchID = category->mID;
EnumCategoryList(searchID, output);
EnumThreadList(searchID, output);
}
}
}