当前位置: 首页>>代码示例>>C++>>正文


C++ stringVector类代码示例

本文整理汇总了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);
}
开发者ID:HarinarayanKrishnan,项目名称:VisIt28RC_Trunk,代码行数:34,代码来源:ProgrammableOpAttributes.C

示例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);
}
开发者ID:burlen,项目名称:visit_vtk_7_src,代码行数:8,代码来源:XMLNode.C

示例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);
}
开发者ID:HarinarayanKrishnan,项目名称:VisIt28RC_Trunk,代码行数:21,代码来源:QvisScatterPlotWizardPage.C

示例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());
    }
}
开发者ID:burlen,项目名称:visit_vtk_7_src,代码行数:10,代码来源:ViewerDatabaseCorrelationMethods.C

示例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;
}
开发者ID:burlen,项目名称:visit_vtk_7_src,代码行数:54,代码来源:PyProgrammableOpAttributes.C

示例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();
}
开发者ID:EricAlex,项目名称:ThirdParty-dev,代码行数:47,代码来源:FileOpenOptions.C

示例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;
}
开发者ID:burlen,项目名称:visit_vtk_7_src,代码行数:28,代码来源:avtProgrammableOperation.C

示例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);
    }
}
开发者ID:EricAlex,项目名称:ThirdParty-dev,代码行数:10,代码来源:Dyna3DFile.cpp

示例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);
}
开发者ID:VisBlank,项目名称:ipfixcol,代码行数:51,代码来源:Utils.cpp

示例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);
        }
    }
}
开发者ID:burlen,项目名称:visit_vtk_7_src,代码行数:14,代码来源:ConfigManager.C

示例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());
}
开发者ID:ahota,项目名称:visit_intel,代码行数:16,代码来源:PluginManagerAttributes.C

示例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 &currentPlot = 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;
}
开发者ID:HarinarayanKrishnan,项目名称:VisIt28RC_Trunk,代码行数:42,代码来源:QvisPlotListBox.C

示例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;
}
开发者ID:burlen,项目名称:visit_vtk_7_src,代码行数:23,代码来源:avtMissingDataFilter.C

示例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);
			}
		}
	}

}
开发者ID:VisBlank,项目名称:ipfixcol,代码行数:66,代码来源:Utils.cpp

示例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());
//.........这里部分代码省略.........
开发者ID:HarinarayanKrishnan,项目名称:VisIt28RC_Trunk,代码行数:101,代码来源:ProgrammableOpAttributes.C


注:本文中的stringVector类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。