本文整理汇总了C++中stringVector::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ stringVector::push_back方法的具体用法?C++ stringVector::push_back怎么用?C++ stringVector::push_back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stringVector
的用法示例。
在下文中一共展示了stringVector::push_back方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// ****************************************************************************
// Method: QvisScatterPlotWizardPage::GetSelectedVars()
//
// Purpose: Returns the names of the selected variables.
//
// Programmer: Cyrus Harrison
// Creation: Wed Aug 18 15:26:15 PDT 2010
//
//
// Modifications:
//
// ****************************************************************************
void
QvisScatterPlotWizardPage::GetSelectedVars(stringVector &res) const
{
res.clear();
res.push_back(xVarName);
res.push_back(yVarName);
res.push_back(zVarName);
res.push_back(colorVarName);
}
示例2: if
bool
GetStringVectorFromPyObject(PyObject *obj, stringVector &vec)
{
bool retval = true;
if(obj == 0)
{
retval = false;
}
else if(PyTuple_Check(obj))
{
// Extract arguments from the tuple.
for(int i = 0; i < PyTuple_Size(obj); ++i)
{
PyObject *item = PyTuple_GET_ITEM(obj, i);
if(PyString_Check(item))
vec.push_back(PyString_AS_STRING(item));
else
{
VisItErrorFunc("The tuple must contain all strings.");
retval = false;
break;
}
}
}
else if(PyList_Check(obj))
{
// Extract arguments from the list.
for(int i = 0; i < PyList_Size(obj); ++i)
{
PyObject *item = PyList_GET_ITEM(obj, i);
if(PyString_Check(item))
vec.push_back(PyString_AS_STRING(item));
else
{
VisItErrorFunc("The list must contain all strings.");
retval = false;
break;
}
}
}
else if(PyString_Check(obj))
{
vec.push_back(PyString_AS_STRING(obj));
}
else
{
retval = false;
VisItErrorFunc("The object could not be converted to a "
"vector of strings.");
}
return retval;
}
示例3:
void
XMLNode::GetAttributeNames(stringVector &result) const
{
result.clear();
map<string,string>::const_iterator itr;
for(itr =attributes.begin(); itr != attributes.end();++itr)
result.push_back(itr->first);
}
示例4:
ProgrammableOperation::ResponseType
avtProgrammableOperation::avtVisItForEachLocation::getSignature(std::string& name,
stringVector& argnames,
std::vector<ScriptType>& argtypes)
{
name = "visit_foreach_location";
argnames.push_back("window");
argtypes.push_back(ProgrammableOperation::INT_VECTOR_TYPE);
argnames.push_back("variableName");
argtypes.push_back(ProgrammableOperation::VTK_DATA_ARRAY_TYPE);
argnames.push_back("kernelLanguage");
argtypes.push_back(ProgrammableOperation::STRING_TYPE);
argnames.push_back("kernel");
argtypes.push_back(ProgrammableOperation::STRING_TYPE);
argnames.push_back("kernelName");
argtypes.push_back(ProgrammableOperation::STRING_TYPE);
argnames.push_back("primaryVariable");
argtypes.push_back(ProgrammableOperation::STRING_TYPE);
argnames.push_back("kernelArgs");
argtypes.push_back(ProgrammableOperation::VARIANT_VECTOR_TYPE);
return ProgrammableOperation::VTK_MULTI_DIMENSIONAL_DATA_ARRAY;
}
示例5:
void
Dyna3DFile::GetMaterials(intVector &matnos, stringVector &matnames, doubleVector &matdens)
{
for(int i = 0; i < materialCards.size(); ++i)
{
matnos.push_back(materialCards[i].materialNumber);
matnames.push_back(materialCards[i].materialName);
matdens.push_back(materialCards[i].density);
}
}
示例6: loadDirRange
void loadDirRange(std::string &dir, std::string &firstDir, std::string &lastDir, stringVector &tables)
throw (std::invalid_argument)
{
/* remove slash, if any */
if (firstDir[firstDir.length()-1] == '/') {
firstDir.resize(firstDir.length()-1);
}
if (lastDir[lastDir.length()-1] == '/') {
lastDir.resize(lastDir.length()-1);
}
/* check that first dir comes before last dir */
if (strverscmp(firstDir.c_str(), lastDir.c_str()) > 0) {
throw std::invalid_argument(lastDir + " comes before " + firstDir);
}
struct dirent **namelist;
int dirs_counter;
/* scan for subdirectories */
dirs_counter = scandir(dir.c_str(), &namelist, NULL, versionsort);
if (dirs_counter < 0) {
#ifdef DEBUG
std::cerr << "Cannot scan directory " << dir << ": " << strerror(errno) << std::endl;
#endif
return;
}
/*
* namelist now contains dirent structure for every entry in directory.
* the structures are sorted according to versionsort, which is ok for most cases
*/
int counter = 0;
struct dirent *dent;
while(dirs_counter--) {
dent = namelist[counter++];
/* Check that the directory is in range and not '.' or '..' */
if (dent->d_type == DT_DIR && strcmp(dent->d_name, ".") && strcmp(dent->d_name, "..") &&
strverscmp(dent->d_name, firstDir.c_str()) >= 0 && strverscmp(dent->d_name, lastDir.c_str()) <= 0) {
std::string tableDir = dir + dent->d_name;
Utils::sanitizePath(tableDir);
tables.push_back(std::string(tableDir));
}
free(namelist[counter-1]);
}
free(namelist);
}
示例7:
void
PluginManagerAttributes::UniqueCategories(const std::string &t, stringVector &c) const
{
c.clear();
for(size_t i = 0; i < type.size(); ++i)
{
if(type[i] == t)
{
if(i < category.size() &&
category[i] != "?" &&
std::find(c.begin(), c.end(), category[i]) == c.end())
c.push_back(category[i]);
}
}
std::sort(c.begin(), c.end());
}
示例8: loadDirsTree
void loadDirsTree(std::string basedir, std::string first, std::string last, stringVector &tables)
{
struct dirent **namelist;
int dirs_counter;
sanitizePath(basedir);
/* Find root directories */
std::string root_first = rootDir(first);
std::string root_last = rootDir(last);
/* scan for subdirs */
dirs_counter = scandir(basedir.c_str(), &namelist, NULL, versionsort);
if (dirs_counter < 0) {
#ifdef DEBUG
std::cerr << "Cannot stat directory " << basedir << ": " << strerror(errno) << std::endl;
#endif
return;
}
/* Add all directories into vector */
for (int i = 0; i < dirs_counter; ++i) {
std::string entry_name = namelist[i]->d_name;
/* Ignore . and .. */
if (entry_name == "." || entry_name == "..") {
continue;
}
/* If first dir was given, ignore entries before it */
if (!root_first.empty() && strverscmp(entry_name.c_str(), root_first.c_str()) < 0) {
continue;
} else if (strverscmp(entry_name.c_str(), root_first.c_str()) == 0) {
if (root_first == first.substr(0, first.length() - 1)) {
/* Found first folder */
std::string tableDir = basedir + entry_name;
sanitizePath(tableDir);
tables.push_back(tableDir);
} else {
/* Go deeper and find first folder */
std::string new_basedir = basedir + entry_name;
std::string new_first = first.substr(root_first.length() + 1);
loadDirsTree(new_basedir, new_first, "", tables);
}
} else if (root_last.empty() || strverscmp(entry_name.c_str(), root_last.c_str()) < 0) {
/* Entry is between first and last */
std::string tableDir = basedir + entry_name;
sanitizePath(tableDir);
tables.push_back(tableDir);
} else if (strverscmp(entry_name.c_str(), root_last.c_str()) == 0){
/* Entry == root_last */
if (root_last == last.substr(0, last.length() - 1)) {
/* We're on last level, add last directory to vector */
std::string tableDir = basedir + entry_name;
sanitizePath(tableDir);
tables.push_back(tableDir);
} else {
/* Goo deeper */
std::string new_basedir = basedir + entry_name;
std::string new_last = last.substr(root_last.length() + 1);
loadDirsTree(new_basedir, "", new_last, tables);
}
}
}
}
示例9: if
//.........这里部分代码省略.........
for(int i = 0; i < array.size(); ++i)
{
/// need key, value pair
/// this can be in the form of a dictionary, "a = b", pair tuple (a,b), or a pair array [a,b]
JSONNode node = array[i];
JSONNode key,value;
if(node.GetType() == JSONNode::JSONARRAY)
{
if(node.GetArray().size() != 2) continue;
key = node.GetArray()[0];
value = node.GetArray()[1];
}
else if(node.GetType() == JSONNode::JSONOBJECT)
{
/// parse through dictionary and compute arguments from names..
const JSONNode::JSONObject& obj = node.GetJsonObject();
if(obj.size() != 1) continue;
const JSONNode::JSONObject::const_iterator itr = obj.begin();
key = itr->first;
value = itr->second;
}
else if(node.GetType() == JSONNode::JSONSTRING)
{
std::string pair = node.GetString();
int index = pair.find("=");
if(index == std::string::npos) continue;
key = pair.substr(0,index);
value = trim(pair.substr(index+1));
}
if(key.GetType() != JSONNode::JSONSTRING) continue;
std::string keystr = trim(key.GetString());
std::ostringstream str;
str << "import json\n";
if(value.GetType() == JSONNode::JSONSTRING)
{
std::string v = trim(value.GetString());
///character at 0 and has :
if(v.find(":") != std::string::npos && v.find(":") == 0)
{
/// optionally handle whether it can be as_vtkarray, as_ndarray, or as_rarray
size_t index = v.find(":as_ndarray");
if(index == std::string::npos)
index = v.find(":as_rarray");
if(index != std::string::npos)
{
std::string newName = getNextName();
v = v.substr(0,index);
AddNode(newName, "as_ndarray");
AddConnection(v, newName, "in");
AddConnection(newName,parent,keystr);
}
else
{
index = v.find(":as_vtkarray");
if(index != std::string::npos)
v = v.substr(0,index);
AddConnection(v,parent,keystr);
}
}
else
{
std::string escapedCode = trim(value.GetString());
replace(escapedCode,"\n","\\\n");
replace(escapedCode,"'","\"");
escapedCode = "'" + escapedCode + "'";
str << "try:\n"
<< " a = json.loads(" << escapedCode << ")\n"
<< "except:\n"
<< " a = " << escapedCode << "\n"
<< "setout(a)\n";
AddPythonScript(keystr,stringVector(),str.str());
AddNode(keystr,keystr);
AddConnection(keystr,parent,keystr);
}
}
else
{
str << "setout(json.loads('" << trim(value.ToString()) << "'))\n";
AddPythonScript(keystr,stringVector(),str.str());
AddNode(keystr,keystr);
AddConnection(keystr,parent,keystr);
}
args.push_back(keystr);
}
return true;
}
示例10: vp
//.........这里部分代码省略.........
/*
* Determine visit user path (Path to My Documents).
*/
{
char visituserpath[MAX_PATH], expvisituserpath[MAX_PATH];
bool haveVISITUSERHOME=0;
TCHAR szPath[MAX_PATH];
struct _stat fs;
if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL,
SHGFP_TYPE_CURRENT, szPath)))
{
SNPRINTF(visituserpath, 512, "%s\\VisIt", szPath);
haveVISITUSERHOME = true;
}
if (haveVISITUSERHOME)
{
ExpandEnvironmentStrings(visituserpath,expvisituserpath,512);
if (_stat(expvisituserpath, &fs) == -1)
{
_mkdir(expvisituserpath);
}
}
else
{
strcpy(expvisituserpath, visitpath);
}
sprintf(tmpdir, "%s\\My images", expvisituserpath);
if (_stat(tmpdir, &fs) == -1)
{
_mkdir(tmpdir);
}
sprintf(tmp, "VISITUSERHOME=%s", expvisituserpath);
env.push_back(tmp);
}
/*
* Turn the long VisIt path into the shortened system path.
*/
if(useShortFileName)
{
char *vp2 = (char *)malloc(512);
GetShortPathName(visitpath, vp2, 512);
if (freeVisItPath)
free(visitpath);
visitpath = vp2;
freeVisItPath = true;
}
string vp(visitpath);
/*
* Add VisIt's home directory to the path.
*/
env.push_back(AddPath(tmp, visitpath, visitdevdir));
/*
* Set the VisIt home dir.
*/
sprintf(tmp, "VISITHOME=%s", visitpath);
env.push_back(tmp);
if (visitdevdir != 0)
free(visitdevdir);
/*
* Set the plugin dir.
示例11: source
bool
AccessViewerSession::GetSourceMap(stringVector &keys, stringVector &values,
std::map<std::string, stringVector> &uses)
{
const char *mName = "AccessViewerSession::GetSourceMap: ";
DataNode *vsNode = GetVSNode();
bool ret = false;
if(vsNode != 0)
{
DataNode *smNode = vsNode->GetNode("SourceMap");
if(smNode != 0)
{
keys.clear();
values.clear();
DataNode **children = smNode->GetChildren();
for(int i = 0; i < smNode->GetNumChildren(); ++i)
{
if(children[i]->GetNodeType() == STRING_NODE)
{
keys.push_back(children[i]->GetKey());
values.push_back(children[i]->AsString());
}
}
ret = keys.size() > 0;
}
else
{
debug1 << mName << "Could not find SourceMap node." << endl;
}
// NOTE: This section knows a lot about viewer session files, which
// means that if the viewer session format changes then this
// code must also change.
//
// Look through the plots in the session file and determine
// where each source is used so we can give a little more
// information to the user.
DataNode *wmNode = vsNode->GetNode("ViewerWindowManager");
if(wmNode != 0)
{
DataNode *winNode = wmNode->GetNode("Windows");
if(winNode != 0)
{
DataNode **wins = winNode->GetChildren();
for(int i = 0; i < winNode->GetNumChildren(); ++i)
{
if(wins[i]->GetNodeType() == INTERNAL_NODE &&
wins[i]->GetKey() == "ViewerWindow")
{
DataNode *vpl = wins[i]->GetNode("ViewerPlotList");
if(vpl != 0)
{
char tmp[1000];
int ploti = 0;
DataNode *plotNode = 0;
do
{
SNPRINTF(tmp, 1000, "plot%02d", ploti++);
plotNode = vpl->GetNode(tmp);
if(plotNode != 0)
{
DataNode *pluginIDNode = 0,
*varNameNode = 0,
*sourceIDNode = 0;
pluginIDNode = plotNode->GetNode("pluginID");
sourceIDNode = plotNode->GetNode("sourceID");
varNameNode = plotNode->GetNode("variableName");
if(sourceIDNode != 0 &&
sourceIDNode->GetNodeType() == STRING_NODE &&
pluginIDNode != 0 &&
pluginIDNode->GetNodeType() == STRING_NODE &&
varNameNode != 0 &&
varNameNode->GetNodeType() == STRING_NODE)
{
std::string source(sourceIDNode->AsString());
std::string varName(varNameNode->AsString());
std::string plotName(pluginIDNode->AsString());
std::string::size_type pos = plotName.rfind("_");
if(pos != std::string::npos)
plotName = plotName.substr(0, pos);
SNPRINTF(tmp, 1000, "Window %d, %s plot of %s",
i+1, plotName.c_str(), varName.c_str());
if(uses.find(source) == uses.end())
uses[source] = stringVector();
uses[source].push_back(std::string(tmp));
}
else
{
debug1 << mName << "pluginID, sourceID, or "
"variableName nodes not located or they "
"were the wrong types." << endl;
}
}
//.........这里部分代码省略.........
示例12: parse_options
//.........这里部分代码省略.........
switch (c) {
// stdout
case 'c':
stdoutput = true;
break;
// decompress
case 'd':
program_mode = PM_DECOMPRESS;
break;
// compress
case 'z':
program_mode = PM_COMPRESS;
break;
// keep
case 'k':
keep = true;
break;
// force
case 'f':
force = true;
break;
// test
case 't':
program_mode = PM_TEST;
break;
// suffix
case 'S':
if (optarg) {
free(suffix);
suffix = strdup(optarg);
}
break;
// quiet
case 'q':
verbosity = 0;
break;
// verbose
case 'v':
verbosity++;
break;
// help
case 'h':
program_mode = PM_HELP;
break;
// license
case 'L':
program_mode = PM_LICENSE;
break;
// version
case 'V':
program_mode = PM_VERSION;
break;
case '1': case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9':
compression_mode = c - '0';
break;
// Advanced options //
// Compression mode
case 'A':
advanced_options.compression_mode =
str2int (optarg, 0, 2);
break;
// Dictionary size
case 'D':
advanced_options.dictionary =
str2int (optarg, 0, 28);
break;
// Fast bytes
case 'F':
advanced_options.fast_bytes =
str2int (optarg, 0, 273);
break;
default:
throw ArgumentException("");
break;
} // switch(c)
} // while(1)
for (int i = optind; i < argc; i++) {
if (strcmp("-", argv[i]) == 0)
continue;
filenames.push_back(argv[i]);
}
} // parse_options