本文整理汇总了C++中strings::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ strings::push_back方法的具体用法?C++ strings::push_back怎么用?C++ strings::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类strings
的用法示例。
在下文中一共展示了strings::push_back方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: evReset
void HttpInterface::evReset(HttpRequest* req, strings& args)
{
for (NodesMap::iterator descIt = nodes.begin();
descIt != nodes.end(); ++descIt)
{
bool ok;
nodeId = getNodeId(descIt->second.name, 0, &ok);
if (!ok)
continue;
string nodeName = WStringToUTF8(descIt->second.name);
Reset(nodeId).serialize(asebaStream); // reset node
asebaStream->flush();
Run(nodeId).serialize(asebaStream); // re-run node
asebaStream->flush();
if (nodeName.find("thymio-II") == 0)
{
strings args;
args.push_back("motor.left.target");
args.push_back("0");
sendSetVariable(nodeName, args);
args[0] = "motor.right.target";
sendSetVariable(nodeName, args);
}
size_t eventPos;
if (commonDefinitions.events.contains(UTF8ToWString("reset"), &eventPos))
{
strings data;
data.push_back("reset");
sendEvent(nodeName,data);
}
finishResponse(req, 200, "");
}
}
示例2: listOggfiles
void GUIPlayer::listOggfiles(const string& dirPath, strings& oggFiles)
{
DIR* dir;
if ((dir = opendir(dirPath.data())) == NULL)
{
return;
}
struct dirent* entry;
while ((entry = readdir(dir)) != NULL)
{
string name = entry->d_name;
if (StringHelper::endsWith(upperCase(name), ".OGG"))
{
name = "/" + name;
name = dirPath + name;
oggFiles.push_back(name);
}
}
// hack
// we hope startup.ogg to be the first.
reverse(oggFiles.begin(), oggFiles.end());
closedir(dir);
}
示例3: getDirectoryContent
int getDirectoryContent(const std::string& dir, strings &files, bool recursive)
{
DIR *dp;
struct dirent *dirp;
strings todo;
if((dp = opendir(dir.c_str())) == NULL)
{
return errno;
}
while ((dirp = readdir(dp)) != NULL)
{
if (dirp->d_type == DT_REG)
{
files.push_back(dir + "/" + std::string(dirp->d_name));
}
else if (recursive && dirp->d_type == DT_DIR)
{
if (dirp->d_name[0] != '.')
{
todo.push_back(dir + "/" + dirp->d_name);
}
}
}
closedir(dp);
for (size_t u = 0; u < todo.size(); u++)
{
getDirectoryContent(todo[u], files, recursive);
}
return 0;
}
示例4: listRegKeys
void Tpresets::listRegKeys(strings &l)
{
l.clear();
HKEY hKey;
char_t rkey[MAX_PATH];
tsnprintf_s(rkey, countof(rkey), _TRUNCATE, FFDSHOW_REG_PARENT _l("\\%s"), reg_child);
RegOpenKeyEx(HKEY_CURRENT_USER,rkey,0,KEY_READ,&hKey);
for (int i=0,retCode=ERROR_SUCCESS; retCode==ERROR_SUCCESS; i++) {
char_t keyName[256];
DWORD keyNameSize=255;
FILETIME ftLastWriteTime;
retCode = RegEnumKeyEx(hKey,
i,
keyName,
&keyNameSize,
NULL,
NULL,
NULL,
&ftLastWriteTime
);
if (retCode==ERROR_SUCCESS) {
l.push_back(ffstring(keyName));
} else {
break;
}
}
RegCloseKey(hKey);
}
示例5: str2argv
void str2argv(const string src, strings &argv) {
string arg;
enum state {
SYMBOL,
SKIP,
SKIP_UNTIL
} s = SYMBOL;
for (string::const_iterator i = src.begin(); i != src.end(); ++i) {
switch (*i) {
case '\\':
s = SKIP;
break;
case '"':
if (s == SKIP_UNTIL)
s = SYMBOL;
else
s = SKIP_UNTIL;
break;
case ' ':
switch (s) {
case SKIP:
s = SYMBOL;
arg += *i;
break;
case SKIP_UNTIL:
arg += *i;
break;
default:
argv.push_back(arg);
arg.clear();
break;
}
break;
default:
if (s == SKIP)
s = SYMBOL;
arg += *i;
break;
}
}
if (!arg.empty())
argv.push_back(arg);
}
示例6: runCmd
bool nsUtils::runCmd(const string& cmd,
const strings& input,
strings& output)
{
int childStdIn[2]; // child read 0, parent write 1
int childStdOut[2]; // parent read 0, child write 1
if (pipe(childStdIn) != 0) {
std::cerr << "Failed to create pipe 1\n";
return false;
}
if (pipe(childStdOut) != 0) {
std::cerr << "Failed to create pipe 2\n";
return false;
}
pid_t child(fork());
if (child == -1) {
std::cerr << "Failed to fork\n";
close(childStdIn[0]);
close(childStdIn[1]);
close(childStdOut[0]);
close(childStdOut[1]);
return false;
}
if (child == 0) {
// child
close(childStdIn[1]);
close(childStdOut[0]);
dup2(childStdIn[0], 0);
dup2(childStdOut[1], 1);
execl(cmd.c_str(), cmd.c_str(), NULL);
exit(1);
}
// parent
close(childStdIn[0]);
close(childStdOut[1]);
char lineEnd('\n');
for (size_t i = 0; i < input.size(); ++i) {
write(childStdIn[1], input[i].c_str(), input[i].length());
write(childStdIn[1], &lineEnd, 1);
}
close(childStdIn[1]);
ssize_t readCount;
const int bufferSize(512);
char buffer[bufferSize + 1];
while ((readCount = read(childStdOut[0], buffer, bufferSize)) > 0) {
buffer[readCount] = '\0';
if (buffer[readCount - 1] == '\n') {
buffer[readCount - 1] = '\0';
}
output.push_back(string(buffer));
}
close(childStdOut[0]);
wait(NULL);
return true;
}
示例7: findPossibleSubtitles
void TsubtitlesFile::findPossibleSubtitles(const char_t *dir, strings &files)
{
char_t autosubmask[MAX_PATH];
_makepath_s(autosubmask, MAX_PATH, NULL, dir,/*name*/_l("*"), _l("*"));
strings files0;
findFiles(autosubmask, files0);
for (strings::iterator f = files0.begin(); f != files0.end(); f++)
if (extMatch(f->c_str())) {
files.push_back(*f);
}
std::sort(files.begin(), files.end(), ffstring_iless());
}
示例8: Extract
bool CExeUnpackPkg::Extract( LPCTSTR szfile, LPCTSTR szpath, strings &files )
{
USES_CONVERSION;
Files filelist;
if ( EE_SUCCESS == ExtractOfficePackage(szfile, szpath, filelist) )
{
for (int i=0; i<filelist.size(); i++)
{
std::string str = CT2CA(filelist[i].GetString());
files.push_back(str);
}
return true;
}
return false;
}
示例9: split
void
split (const std::string& str, strings& strs, char separator)
{
if (str.size ())
{
std::string::size_type start = 0;
std::string::size_type end = 0;
while (start != std::string::npos)
{
end = str.find_first_of (separator, start);
if (end == std::string::npos)
end = str.size ();
strs.push_back (str.substr (start, end - start));
start = str.find_first_not_of (separator, end);
}
}
}
示例10: listOggfiles
static void listOggfiles(const char* dirPath, strings& oggFiles)
{
DIR* dir;
if ((dir = opendir(dirPath)) == NULL)
{
return;
}
struct dirent* entry;
while ((entry = readdir(dir)) != NULL)
{
string name = entry->d_name;
if (StringHelper::endsWith(name, ".OGG"))
{
name = "/" + name;
name = dirPath + name;
oggFiles.push_back(name);
}
}
closedir(dir);
}
示例11: parse_json_form
// Utility: extract argument values from JSON request body
void HttpInterface::parse_json_form(std::string content, strings& values)
{
std::string buffer = content;
buffer.erase(std::remove_if(buffer.begin(), buffer.end(), ::isspace), buffer.end());
std::stringstream ss(buffer);
if (ss.get() == '[')
{
int i;
while (ss >> i)
{
// values.push_back(std::to_string(short(i)));
std::stringstream valss;
valss << short(i);
values.push_back(valss.str());
if (ss.peek() == ']')
break;
else if (ss.peek() == ',')
ss.ignore();
}
if (ss.get() != ']')
values.erase(values.begin(),values.end());
}
示例12: ss
const strings
split (strings& se,
const std::string& s,
char delimiter,
bool strip_quotes,
bool strip_whitespace,
bool empty)
{
std::stringstream ss(s);
std::string e;
se.clear ();
while (std::getline (ss, e, delimiter))
{
if (strip_whitespace)
e = trim (e);
if (strip_quotes)
e = dequote (e);
if (empty || !e.empty ())
{
se.push_back (e);
}
}
return se;
}
示例13: addFlowEst
void addFlowEst(string& key, int2s& bigNonCounts, long2s& timeCounts, strings& overBigKeys )
{
// generate a random number, if >= 1, do nothing
int v1 = rand() % 1000; // v1 in the range 0 to 99
if(v1 >29)
return;
// time++ and find maximum value
long nRow = timeCounts.size();
int nCol = timeCounts[0].size();
long xMax = 0;
int yMax = 0;
long tMax = timeCounts[0][0];
long cMax = bigNonCounts[0][0];
for(int i = 0; i < nRow; i++)
{
for(int j = 0; j < nCol; j++)
{
if(timeCounts[i][j] != 0)
{
timeCounts[i][j] ++;
}
if(timeCounts[i][j]>tMax)
{
xMax = i;
yMax = j;
cMax = bigNonCounts[i][j];
}
if(timeCounts[i][j]==tMax && bigNonCounts[i][j]>cMax)
{
xMax = i;
yMax = j;
cMax = bigNonCounts[i][j];
}
}
}
// if inside cuckooFIlterFlowEst, count++, return
long posx;
int posy;
if(cuckooFilterFlowEst.LookUpKeyBack(key,posx,posy))
{
bigNonCounts[posx][posy] ++;
//cout<<"* FLOW_EST_COUNT: "<<FLOW_EST_COUNT<<endl;
// if count==7, feedback and delete the item
if(bigNonCounts[posx][posy] == 2)
{
// feedback to blackkey
overBigKeys.push_back(key);
// delete the item
cuckooFilterFlowEst.RemoveKey(key);
bigNonCounts[posx][posy] = 0;
timeCounts[posx][posy] = 0;
FLOW_EST_COUNT --;
}
return;
}
// if not overflow, insert
if(FLOW_EST_COUNT<FLOW_EST_SIZE)
{
FLOW_EST_COUNT++;
cuckooFilterFlowEst.AddKey(key,0);
if(cuckooFilterFlowEst.LookUpKeyBack(key,posx,posy))
{
bigNonCounts[posx][posy] = 1;
timeCounts[posx][posy] = 1;
FLOW_EST_COUNT ++;
}
return;
}
// if overflow, delete one, and insert
if(FLOW_EST_COUNT>=FLOW_EST_SIZE)
{
//cout<<"* FLOW_EST_COUNT>=FLOW_EST_SIZE!"<<FLOW_EST_COUNT<<endl<<endl;
// delete one, find the one with maximum timeCounts and minimum value
cuckooFilterFlowEst.RemovePos(xMax,yMax);
bigNonCounts[xMax][yMax] = 0;
timeCounts[xMax][yMax] = 0;
// insert one
cuckooFilterFlowEst.AddKey(key,0);
if(cuckooFilterFlowEst.LookUpKeyBack(key,posx,posy))
{
bigNonCounts[posx][posy] = 1;
timeCounts[posx][posy] = 1;
}
return;
}
}