本文整理汇总了C++中StringVec::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ StringVec::push_back方法的具体用法?C++ StringVec::push_back怎么用?C++ StringVec::push_back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringVec
的用法示例。
在下文中一共展示了StringVec::push_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getVarNames
StringVec SpeckleyNodes::getVarNames() const
{
StringVec res;
res.push_back("Nodes_Id");
res.push_back("Nodes_Tag");
return res;
}
示例2: processLDFlags
void processLDFlags(const String& ldFlags, StringVec& libs) {
// Tokenize flags
StringVec ldFlagTokens;
tokenize(ldFlags, ldFlagTokens, " \t", "", "\"'", "", "", true, false);
// Expand -Wl, and -Xlinker tokens to make parsing easier
StringVec ldFlagsFixed;
replaceWlArgs(ldFlagTokens, ldFlagsFixed);
String savedToken;
for (auto opt : ldFlagsFixed) {
if (savedToken.empty()) {
opt = reduceLinkerToken(opt);
if (opt == "-library" || opt == "-framework") {
savedToken = opt;
} else if (strBeginsWith(opt, "-l")) {
String libName = strEndsWith(opt, ".o") ? opt.substr(2) : "lib" + opt.substr(2) + ".?";
libs.push_back(libName);
} else if (strEndsWith(opt, ".a") || strEndsWith(opt, ".dylib") || strEndsWith(opt, ".o")) {
libs.push_back(opt);
}
} else {
if (savedToken == "-library") {
libs.push_back(opt);
} else if (savedToken == "-framework") {
std::string frameworkName = opt.substr(0, opt.find(',')) + ".framework";
libs.push_back(frameworkName);
}
savedToken.clear();
}
}
}
示例3: getVarNames
StringVec SpeckleyElements::getVarNames() const
{
StringVec res;
res.push_back(name + string("_Id"));
res.push_back(name + string("_Owner"));
//res.push_back(name + string("_Tag"));
return res;
}
示例4: explodeString
StringVec explodeString(const std::string& string, const std::string& separator)
{
StringVec returnVector;
size_t start = 0, end = 0;
while((end = string.find(separator, start)) != std::string::npos)
{
returnVector.push_back(string.substr(start, end - start));
start = end + separator.size();
}
returnVector.push_back(string.substr(start));
return returnVector;
}
示例5: explodeString
StringVec explodeString(const std::string& inString, const std::string& separator, int32_t limit/* = -1*/)
{
StringVec returnVector;
std::string::size_type start = 0, end = 0;
while (--limit != -1 && (end = inString.find(separator, start)) != std::string::npos) {
returnVector.push_back(inString.substr(start, end - start));
start = end + separator.size();
}
returnVector.push_back(inString.substr(start));
return returnVector;
}
示例6: getRecursiveDirList
void getRecursiveDirList(const String& baseDir, StringVec& dirVec, const StringVec& ignoreList)
{
DIR* dir = opendir(baseDir.c_str());
if (!dir)
return;
dirVec.push_back(baseDir);
struct dirent* entry;
while ((entry = readdir(dir))) {
if (entry->d_type == DT_DIR) {
String path = joinPaths(baseDir, entry->d_name);
if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, ".."))
continue;
if (matchWildcardList(entry->d_name, ignoreList))
continue;
getRecursiveDirList(path, dirVec, ignoreList);
}
}
closedir(dir);
}
示例7: setStringVecValue
inline void setStringVecValue( StringVec& sv, const std::string& value, size_t index = 0 )
{
size_t size = sv.size();
if( size <= index )
{
while( size < index )
{
sv.push_back( "" );
++size;
}
sv.push_back( value );
}
else
sv[index] = value;
}
示例8: getMeshNames
StringVec SpeckleyElements::getMeshNames() const
{
StringVec res;
if (nodeMesh)
res.push_back(nodeMesh->getName());
return res;
}
示例9: GetExistingProfiles
ProfileDlg::StringVec ProfileDlg::GetExistingProfiles()
{
StringVec profiles;
HKEY hKey;
if (::RegOpenKeyEx(HKEY_CURRENT_USER, PROFILES_LOC, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
return profiles;
DWORD dwIndex = 0;
LONG lRet;
DWORD len = 50;
TCHAR profileName[50];
while ((lRet = ::RegEnumKeyEx(hKey, dwIndex, profileName, &len, NULL,
NULL, NULL, NULL)) != ERROR_NO_MORE_ITEMS)
{
// Do we have a key to open?
if (lRet == ERROR_SUCCESS)
{
// Open the key and get the value
HKEY hItem;
if (::RegOpenKeyEx(hKey, profileName, 0, KEY_READ, &hItem) != ERROR_SUCCESS)
continue;
profiles.push_back(profileName);
::RegCloseKey(hItem);
}
dwIndex++;
len = 50;
}
::RegCloseKey(hKey);
return profiles;
}
示例10: normalize
std::string Path::normalize(const std::string & path)
{
// Easiest way is: split, then remove "." and remove a/.. (but not ../.. !)
// This does not get a/b/../.. so if we remove a/.., go through the string again
// Also need to treat rootdir/.. specially
// Also normalize(foo/..) -> "." but normalize(foo/bar/..) -> "foo"
StringVec v = Path::split(path);
if (v.size() == 0)
return "";
StringVec outv;
bool doAgain = true;
while (doAgain)
{
doAgain = false;
for (unsigned int i = 0; i < v.size(); i++)
{
if (v[i] == "") continue; // remove empty fields
if (v[i] == "." && v.size() > 1) continue; // skip "." unless it is by itself
if (i == 0 && isRootdir(v[i]) && i+1 < v.size() && v[i+1] == "..")
{
// <root>/.. -> <root>
outv.push_back(v[i]);
i++; // skipped following ".."
doAgain = true;
continue;
}
// remove "foo/.."
if (i+1 < v.size() && v[i] != ".." && v[i+1] == "..")
{
// but as a special case, if the full path is "foo/.." return "."
if (v.size() == 2) return ".";
i++;
doAgain = true;
continue;
}
outv.push_back(v[i]);
}
if (doAgain)
{
v = outv;
outv.clear();
}
}
return Path::join(outv.begin(), outv.end());
}
示例11: explodeString
StringVec explodeString(const std::string& string, const std::string& separator, bool trim/* = true*/)
{
StringVec returnVector;
size_t start = 0, end = 0;
while((end = string.find(separator, start)) != std::string::npos)
{
std::string t = string.substr(start, end - start);
if(trim)
trimString(t);
returnVector.push_back(t);
start = end + separator.size();
}
returnVector.push_back(string.substr(start));
return returnVector;
}
示例12: get_vocab_names
StringVec Grammar::get_vocab_names() const
{
StringVec vec;
if( m_inherit ) {
vec = m_inherit->get_vocab_names();
}
for( size_t i = 0 ; i < m_vocabs.size() ; i++ ) {
vec.push_back( m_vocabs[i]->get_name() );
}
return vec;
}
示例13: Split
//---------------------------------------------------------------------------------------------------------------------
// This is basically like the Perl split() function. It splits str into substrings by cutting it at each delimiter.
// The result is stored in vec.
//---------------------------------------------------------------------------------------------------------------------
void Split(const string& str, StringVec& vec, char delimiter)
{
vec.clear();
size_t strLen = str.size();
if (strLen == 0)
return;
size_t startIndex = 0;
size_t indexOfDel = str.find_first_of(delimiter, startIndex);
while (indexOfDel != string::npos)
{
vec.push_back(str.substr(startIndex, indexOfDel-startIndex));
startIndex=indexOfDel + 1;
if (startIndex >= strLen)
break;
indexOfDel = str.find_first_of(delimiter, startIndex);
}
if(startIndex < strLen)
vec.push_back(str.substr(startIndex));
}
示例14: split
int split(StringVec &result, const String &src, const String& delm)
{
String _src(src);
char *p = strtok((char*)_src.c_str(), delm.c_str());
while (p != NULL)
{
result.push_back(p);
p = strtok(NULL, delm.c_str());
}
return int(result.size());
}
示例15: replaceWlArgs
// "Expand" -Wl and -Xlinker tokens
// This is OK to do since we're interested in a small subset of flags.
// Preserving correctness is not important.
static void replaceWlArgs(const StringVec& inArgs, StringVec& outArgs) {
for (auto arg : inArgs) {
if (strBeginsWith(arg, "-Wl,")) {
StringVec tokens;
tokenize(arg, tokens, ",", "", "", "", "");
outArgs.insert(outArgs.end(), tokens.begin() + 1, tokens.end());
} else if (arg != "-Xlinker") {
outArgs.push_back(arg);
}
}
}