本文整理汇总了C++中stringVector类的典型用法代码示例。如果您正苦于以下问题:C++ stringVector类的具体用法?C++ stringVector怎么用?C++ stringVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了stringVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: replace
void
ProgrammableOpAttributes::AddFunction(const std::string& name, const stringVector& atts)
{
JSONNode vars = JSONNode::JSONArray();
for(int i = 0; i < atts.size(); ++i)
vars.Append(atts[i]);
JSONNode node;
node["vars"] = vars;
std::string argstring = "";
for(size_t i = 0; i < atts.size(); ++i)
argstring += atts[i] + (i == atts.size()-1 ? "" : ",");
// char buf[1024];
// sprintf(buf,"import visit_internal_funcs\nsetout(visit_internal_funcs.%s(%s))",name.c_str(),argstring.c_str());
std::ostringstream ostr;
ostr << "import visit_internal_funcs\n"
<< "setout(visit_internal_funcs." << name << "(" << argstring << "))" << std::endl;
std::string escapedCode = ostr.str();
//std::cout << escapedCode << std::endl;
replace(escapedCode, "\n", "\\n");
node["source"] = escapedCode;
script["scripts"][name] = node;
//update scriptmap
scriptMap = script.ToString();
Select(ID_scriptMap, (void *)&scriptMap);
}
示例2:
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);
}
示例3:
// ****************************************************************************
// 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);
}
示例4:
void
ViewerDatabaseCorrelationMethods::DeclineCorrelationCreation(const stringVector &dbs)
{
if(dbs.size() > 0)
{
for(size_t i = 0; i < dbs.size(); ++i)
declinedFiles.push_back(dbs[i]);
declinedFilesLength.push_back((int)dbs.size());
}
}
示例5: GetStringVectorFromPyObject
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;
}
示例6: SelectPreferredIDs
// ****************************************************************************
// Method: FileOpenOptions::AddFallbackFormatsToPreferred
//
// Purpose:
// Adds any given formats to the *end* of the preferred list, moving
// their position to the back if they were already in the list.
//
// Arguments:
// given the list of formats labeled as "fallback"
//
// Programmer: Jeremy Meredith
// Creation: March 26, 2010
//
// ****************************************************************************
void
FileOpenOptions::AddFallbackFormatsToPreferred(const stringVector &given)
{
// for each format, append it
for (size_t i=0; i<given.size(); i++)
{
// get its actual ID
std::string id = "";
for (size_t j=0; j<typeIDs.size(); j++)
{
if (given[i] == typeIDs[j] ||
given[i] == typeNames[j])
{
id = typeIDs[j];
break;
}
}
// if no id, we don't have that plugin, so skip this one
if (id == "")
continue;
// make a new list with this given one at the back
stringVector newPreferredIDs;
for (size_t j=0; j<preferredIDs.size(); j++)
{
if (preferredIDs[j] != id)
newPreferredIDs.push_back(preferredIDs[j]);
}
newPreferredIDs.push_back(id);
preferredIDs = newPreferredIDs;
}
SelectPreferredIDs();
}
示例7:
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;
}
示例8:
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);
}
}
示例9: 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);
}
示例10:
void
ConfigManager::RemoveLeadAndTailQuotes(stringVector &sv)
{
for(size_t i = 0; i < sv.size(); ++i)
{
std::string &s = sv[i];
if(s.size() > 0)
{
int head = (s[0] == '"') ? 1 : 0;
int tail = (s[s.size()-1] == '"') ? 1 : 0;
sv[i] = s.substr(head, s.size() - head - tail);
}
}
}
示例11:
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());
}
示例12:
bool
QvisPlotListBox::NeedsToBeRegenerated(const PlotList *pl,
const stringVector &prefixes, const stringVector &createdSelections) const
{
bool retval = true;
if(pl->GetNumPlots() == count() && prefixes.size() == (size_t)count())
{
for(int i = 0; i < pl->GetNumPlots(); ++i)
{
QvisPlotListBoxItem *lbi = (QvisPlotListBoxItem *)item(i);
const Plot &newPlot = pl->operator[](i);
const Plot ¤tPlot = lbi->GetPlot();
// See if the prefixes are different.
if(prefixes[i] != std::string(lbi->GetPrefix().toStdString()))
return true;
// See if the createdSelections are different.
if(createdSelections[i] != std::string(lbi->GetSelectionName().toStdString()))
return true;
// See if the plots are different
bool nu = newPlot.GetStateType() != currentPlot.GetStateType() ||
newPlot.GetPlotType() != currentPlot.GetPlotType() ||
newPlot.GetHiddenFlag() != currentPlot.GetHiddenFlag() ||
newPlot.GetExpandedFlag() != currentPlot.GetExpandedFlag() ||
newPlot.GetActiveOperator() != currentPlot.GetActiveOperator() ||
newPlot.GetPlotVar() != currentPlot.GetPlotVar() ||
newPlot.GetDatabaseName() != currentPlot.GetDatabaseName() ||
newPlot.GetOperators() != currentPlot.GetOperators() ||
newPlot.GetDescription() != currentPlot.GetDescription() ||
newPlot.GetSelection() != currentPlot.GetSelection() ||
newPlot.GetFollowsTime() != currentPlot.GetFollowsTime();
if(nu) return true;
}
return false;
}
return retval;
}
示例13:
avtCentering
avtMissingDataFilter::MissingDataCentering(const stringVector &vars) const
{
bool mixed = false;
avtCentering c0 = AVT_ZONECENT;
for(size_t i = 0; i < vars.size(); ++i)
{
const avtScalarMetaData *scalar = metadata.GetScalar(vars[i]);
if(scalar != NULL)
{
avtCentering thisC = scalar->centering;
if(i == 0)
c0 = thisC;
if(thisC != c0)
{
mixed = true;
break;
}
}
}
return mixed ? AVT_ZONECENT : c0;
}
示例14: 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);
}
}
}
}
示例15: if
bool
ProgrammableOpAttributes::SetupPipeline(const JSONNode& atts, stringVector& args, const std::string& parent)
{
if(atts.GetType() != JSONNode::JSONARRAY)
return false;
const JSONNode::JSONArray& array = atts.GetArray();
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());
//.........这里部分代码省略.........