本文整理汇总了C++中StrVec::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ StrVec::push_back方法的具体用法?C++ StrVec::push_back怎么用?C++ StrVec::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StrVec
的用法示例。
在下文中一共展示了StrVec::push_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exec
void Console::exec(std::string cmd)
{
StrVec args;
if(cmd.find(' ') != std::string::npos)
{
args.push_back(cmd.substr(cmd.find(' ') + 1, cmd.size() - cmd.find(' ')));
cmd = cmd.substr(0, cmd.find(' '));
while(args.back().find(' ') != std::string::npos)
{
args.push_back(args.back().substr(args.back().find(' ') + 1 , args.size() - args.back().find(' ')));
args.at(args.size() - 1) = args.at(args.size() - 1).substr(0, args.at(args.size() - 1).find(' ') - 1);
}
}
if(commands.find(cmd) == commands.end())
{
addString("Command '" + cmd + "' not found");
return;
}
if(!commands[cmd].exec(args)) addString("Wrong number of arguments for command '" + cmd + "'.");
}
示例2: getORBOptions
void CorbaNotifyUtils::getORBOptions(const std::string &appName,const std::string &orbOptions,
int &orbArgc,ACE_TCHAR*** orbArgv)
{
StrVec ORBOptionsVec;
size_t ini = orbOptions.find_first_not_of(" \t");
size_t end;
while(ini != std::string::npos)
{
end = orbOptions.find_first_of(" \t", ini + 1);
if(end != std::string::npos)
{
ORBOptionsVec.push_back(orbOptions.substr(ini, end - ini));
ini = orbOptions.find_first_not_of(" \t", end);
} else {
ORBOptionsVec.push_back(orbOptions.substr(ini));
ini = std::string::npos;
}
}
int i = 1;
orbArgc = ORBOptionsVec.size() + 1;
*orbArgv = new ACE_TCHAR*[orbArgc];
(*orbArgv)[0] = new ACE_TCHAR[appName.size() + 1];
strncpy((*orbArgv)[0], appName.c_str(), appName.size());
(*orbArgv)[0][appName.size()] = '\0';
for(StrVec::const_iterator it = ORBOptionsVec.begin();
it != ORBOptionsVec.end(); ++it, ++i)
{
(*orbArgv)[i] = new ACE_TCHAR[it->size() + 1];
strncpy((*orbArgv)[i], it->c_str(), it->size());
(*orbArgv)[i][it->size()] = '\0';
ACE_DEBUG((LM_INFO, "%T ORB option: %s\n", (*orbArgv)[i]));
}
}
示例3: main
int main() {
StrVec sv;
print(sv);
sv.push_back("s1"); print(sv);
sv.push_back("s2"); print(sv);
sv.push_back("s3"); print(sv);
sv.push_back("s4"); print(sv);
sv.push_back("s5"); print(sv);
{
StrVec sv2(sv); print(sv2);
sv2.push_back("s6"); print(sv); print(sv2);
sv.pop_back(); print(sv); print(sv2);
sv = sv2; print(sv); print(sv2);
}
sv.reserve(sv.capacity() / 2); print(sv);
sv.reserve(sv.capacity() * 2); print(sv);
sv.resize(sv.size() + 2); print(sv);
sv.resize(sv.size() + 2, "s7"); print(sv);
sv.resize(sv.size() - 2); print(sv);
sv.resize(sv.size() - 2, "s7"); print(sv);
return 0;
}
示例4: ParseBufVC
void ParseBufVC(char* buf, const string& filter_modules, const string& filter_disabled, const string& filter_headers)
{
static bool ignore_files=false;
string line(buf);
switch(BufState)
{
case 0: // expect filter start (set state to 1) or just a line (state =0)
{
if(line.find("<Filter")!=-1) BufState++;
ProjLines.push_back(line);
break;
}
case 1: // found filter, read the name and maybe start ignoring files, state++
{
int from=line.find("\"")+1;
int to=line.find("\"",from);
string name=line.substr(from,to-from);
if(name==filter_modules || name==filter_headers || name==filter_disabled)
{
ProjAssoc[ProjLines.size()+4]=name;
ignore_files=true;
}
BufState++;
ProjLines.push_back(line);
break;
}
case 2: // state++
case 3: // state++
case 4: // state++
{
BufState++;
ProjLines.push_back(line);
break;
}
case 5: // expect file or end of filter (back to 0, stop ignoring files)
{
// end of filter?
if(line.find("</Filter>")!=-1)
{
BufState=0;
ignore_files=false;
ProjLines.push_back(line);
break;
}
// file, pass
}
case 6: // state++
case 7: // state++
case 8: // state++
{
if(!ignore_files) ProjLines.push_back(line);
BufState++;
if(BufState>8) BufState=5;
break;
}
default:
;
}
}
示例5: main
int main()
{
StrVec str;
str.push_back("adf");
str.push_back("sdfd");
for (auto i = str.begin(); i != str.end(); ++i)
cout << *i << ends;
cout << endl;
return 0;
}
示例6: main
int main() {
StrVec words;
words.push_back("ss");
words.push_back("sb");
words.push_back("asf");
words.push_back("safasfd");
words.push_back("asfas");
std::cout<<words.size()<<std::endl;
//words = StrVec();
//words = words;
std::cout<<"cap "<<words.capacity()<<std::endl;
std::cout<<"sz "<<words.size()<<std::endl;
for_each(words.begin(), words.end(), [](const std::string &s){std::cout<<s<<std::endl;});
std::cout<<"exit"<<std::endl;
}
示例7: breakDir
void cGRASS::breakDir(string Dir)
{
StrVec Vec;
Vec.clear();
char dir[255];
strcpy(dir,Dir.c_str());
char * t;
string temp;
printf ("Splitting string \"%s\" into tokens:\n",dir);
t = strtok (dir,"/");
while (t != NULL)
{
temp = t;
Vec.push_back(temp);
t = strtok (NULL, "/");
}
MapSet = Vec[Vec.size()-1];
Location = Vec[Vec.size()-2];
GDBase = "";
for (uint i = 0; i < Vec.size()-2; i++)
{
GDBase = GDBase + "/" + Vec[i];
}
// printf(MapSet);
// printf(Location);
// printf(GDBase);
}
示例8: PWARN
template<> StrVec
GncDbiProviderImpl<DbType::DBI_MYSQL>::get_index_list (dbi_conn conn)
{
StrVec retval;
const char* errmsg;
auto tables = get_table_list(conn, "");
for (auto table_name : tables)
{
auto result = dbi_conn_queryf (conn,
"SHOW INDEXES IN %s WHERE Key_name != 'PRIMARY'",
table_name.c_str());
if (dbi_conn_error (conn, &errmsg) != DBI_ERROR_NONE)
{
PWARN ("Index Table Retrieval Error: %s on table %s\n",
errmsg, table_name.c_str());
continue;
}
while (dbi_result_next_row (result) != 0)
{
std::string index_name {dbi_result_get_string_idx (result, 3)};
retval.push_back(index_name + " " + table_name);
}
dbi_result_free (result);
}
return retval;
}
示例9: split_path
StrVec split_path (const char* path)
{
StrVec rv;
std::string pstr = path;
std::string::size_type pos, ppos = 0;
while ((pos = pstr.find (PATH_SEPARATOR, ppos)) != std::string::npos)
{
if (pos != ppos || ppos == 0)
rv.push_back (pstr.substr (ppos, pos - ppos));
ppos = pos + 1;
}
if (ppos < pstr.length ())
rv.push_back (pstr.substr (ppos, pstr.length () - ppos));
return rv;
}
示例10: split
extern StrVec string_util::split(const string &source,const string &split)
{
string::size_type number=count_occur(source,split);
if(number==0)
{
StrVec result;
result.push_back(source);
return result;
}
vector<string> result;
string::size_type start=0;
string::size_type stop=0;
string inner;
while(true)
{
stop=source.find(split,start);
if(stop==string::npos)
{
result.push_back(source.substr(start));
break;
}
else
{
result.push_back(source.substr(start,stop-start));
start=stop+split.size();
}
}
return result;
}
示例11: main
int main()
{
StrVec v = {"Gone", "with", "the"};
v.push_back("winds");
for_each(v.begin(), v.end(), [](const string &s) {cout << s << " ";});
cout << endl;
return 0;
}
示例12: getVec
StrVec getVec(istream &is)
{
StrVec svec;
string s;
while (is >> s)
svec.push_back(s);
return svec;
}
示例13: newEntry
size_t Data::newEntry(const std::string& key, const SLStore& dv)
{
KeyIdx ki(key, m_keyIdx.size());
KeyIdxVec::iterator it = std::upper_bound(m_keyIdx.begin(), m_keyIdx.end(), ki, key_less);
m_keys.push_back(key);
m_varData.push_back(dv);
m_keyIdx.insert(it, ki);
return ki.second;
}
示例14: main
int main()
{
StrVec vec = { "aaa", "bbb", "ccc" };
cout << vec.size() << " " << vec.capacity() << endl;
vec.push_back("ddd");
vec.print();
system("pause");
return 0;
}
示例15: getVec
StrVec getVec(std::istream &is)
{
StrVec svec;
std::string s;
while (is >> s)
svec.push_back(s);
// this is where move is necessary
return svec;
}