本文整理汇总了C++中behaviac::vector::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ vector::push_back方法的具体用法?C++ vector::push_back怎么用?C++ vector::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类behaviac::vector
的用法示例。
在下文中一共展示了vector::push_back方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvertTextBufferAsStringArray
void ConvertTextBufferAsStringArray(const char* buffer, behaviac::vector<behaviac::string>& stringArray)
{
BEHAVIAC_ASSERT(buffer);
const char* lineBuffer = buffer;
while (*lineBuffer != '\0')
{
const char* currentPos = lineBuffer;
while (*currentPos != '\n' && *currentPos != '\r' && *currentPos != '\0')
{
currentPos++;
}
behaviac::string line;
line.assign(lineBuffer, currentPos - lineBuffer);
stringArray.push_back(line);
while (*currentPos == '\n' || *currentPos == '\r')
{
currentPos++;
}
lineBuffer = currentPos;
}
}
示例2: EndCall
void CScriptSystem::EndCall(behaviac::vector<behaviac::string>& array)
{
if (m_nTempArg == -1)
{
return;
}
if (ExecuteFunction(m_pLS, m_nTempArg, 1))
{
if (lua_istable(m_pLS, -1))
{
int top = lua_gettop(m_pLS);
lua_pushnil(m_pLS); // first key
while (lua_next(m_pLS, top) != 0)
{
// `key' is at index -2 and `value' at index -1
const char* value = lua_tostring(m_pLS, -1);
array.push_back(value);
lua_pop(m_pLS, 1); // pop value, leave index.
}
}
lua_pop(m_pLS, 1);
}
// Check for LUA stack corruption
CheckStackOnEndCall();
}
示例3: ParseForParams
//suppose params are seprated by ','
static void ParseForParams(const behaviac::string& tsrc, behaviac::vector<behaviac::string>& params)
{
int tsrcLen = (int)tsrc.size();
int startIndex = 0;
int index = 0;
int quoteDepth = 0;
for (; index < tsrcLen; ++index)
{
if (tsrc[index] == '"')
{
quoteDepth++;
//if (quoteDepth == 1)
//{
// startIndex = index;
//}
if ((quoteDepth & 0x1) == 0)
{
//closing quote
quoteDepth -= 2;
BEHAVIAC_ASSERT(quoteDepth >= 0);
}
}
else if (quoteDepth == 0 && tsrc[index] == ',')
{
//skip ',' inside quotes, like "count, count"
int lengthTemp = index - startIndex;
behaviac::string strTemp = tsrc.substr(startIndex, lengthTemp);
params.push_back(strTemp);
startIndex = index + 1;
}
}//end for
// the last param
int lengthTemp = index - startIndex;
if (lengthTemp > 0)
{
behaviac::string strTemp = tsrc.substr(startIndex, lengthTemp);
params.push_back(strTemp);
//params.push_back(strTemp);
}
}
示例4: ListFiles_android
void ListFiles_android(behaviac::vector<behaviac::string>& files, const char* szDirName, bool bRecurrsive)
{
AAssetManager* mgr = behaviac::CFileManager::GetInstance()->GetAssetManager();
if (mgr != NULL)
{
const char* validDir = szDirName;
//skip "assets:/"
if (behaviac::StringUtils::StartsWith(validDir, "assets:/"))
{
validDir = validDir + 8;
}
AAssetDir* dir = AAssetManager_openDir(mgr, validDir);
if (dir != NULL)
{
bool bEndsWithSlash = behaviac::StringUtils::EndsWith(szDirName, "/");
if (!bEndsWithSlash)
{
bEndsWithSlash = behaviac::StringUtils::EndsWith(szDirName, "\\");
}
while (true)
{
const char* fileName = AAssetDir_getNextFileName(dir);
if (fileName == NULL)
{
break;
}
if (bEndsWithSlash)
{
fileName = behaviac::FormatString("%s%s", szDirName, fileName);
}
else
{
fileName = behaviac::FormatString("%s/%s", szDirName, fileName);
}
files.push_back(fileName);
}
AAssetDir_close(dir);
}
}
}
示例5: ThreadFunc
static void* ThreadFunc(void* arg)
{
bool isLock = false;
const char* path = (char*)arg;
InotifyDir inotify;
InotifyDir::Event ev;
inotify.init();
inotify.Watch(path);
while (!s_bThreadFinish)
{
if (!inotify.EventPoll(ev))
{
if (isLock)
{
isLock = false;
s_mutex.Unlock();
}
usleep(100);
continue;
}
if (!isLock)
{
isLock = true;
s_mutex.Lock();
}
if (ev.type == InotifyDir::MODIFY || ev.type == InotifyDir::ADD)
{
ev.name.erase(0, strlen(path));
s_ModifiedFiles.push_back(ev.name.c_str());
}
}
if (isLock)
{
isLock = false;
s_mutex.Unlock();
}
return NULL;
}