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


C++ stringVector::size方法代码示例

本文整理汇总了C++中stringVector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ stringVector::size方法的具体用法?C++ stringVector::size怎么用?C++ stringVector::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stringVector的用法示例。


在下文中一共展示了stringVector::size方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
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

示例3: 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

示例4:

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

示例5:

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

示例6:

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

示例7: if

bool
LaunchService::SetupGatewaySocketBridgeIfNeeded(stringVector &launchArgs)
{
    const char *mName="LaunchService::SetupGatewaySocketBridgeIfNeeded: ";

    // Get the port and host.
    int  oldlocalport       = -1;
    int  portargument       = -1;
    int  hostargument       = -1;
    for (size_t i=0; i<launchArgs.size(); i++)
    {
        if (i<launchArgs.size()-1 && launchArgs[i] == "-port")
        {
            oldlocalport = atoi(launchArgs[i+1].c_str());
            portargument = i+1;
        }
        else if (i<launchArgs.size()-1 && launchArgs[i] == "-host")
        {
            hostargument = i+1;
        }
    }

    bool setupBridge = (portargument != -1 && hostargument != -1);
    if(setupBridge)
    {
        debug5 << mName << "Setting up gateway port bridge.\n";
        // find a new local port
        int lowerRemotePort = 10000;
        int upperRemotePort = 40000;
        int remotePortRange = 1+upperRemotePort-lowerRemotePort;

#if defined(_WIN32)
        srand((unsigned)time(0));
        int newlocalport = lowerRemotePort+(rand()%remotePortRange);
#else
        srand48(long(time(0)));
        int newlocalport = lowerRemotePort+(lrand48()%remotePortRange);
#endif
        debug5 << mName << "Bridging new port INADDR_ANY/" << newlocalport
               << " to tunneled port localhost/" << oldlocalport << endl;

        // replace the host with my host name
        char hostname[1024];
        gethostname(hostname,1024);
        launchArgs[hostargument] = hostname;

        // replace the launch argument port number
        char newportstr[10];
        sprintf(newportstr,"%d",newlocalport);
        launchArgs[portargument] = newportstr;

        // fork and start the socket bridge
        int *ports = new int[2];
        ports[0] = newlocalport;
        ports[1] = oldlocalport;
#ifdef _WIN32
        _beginthread(CreateSocketBridge, 0, (void*)ports);
#else
        switch (fork())
        {
          case -1:
            // Could not fork.
            exit(-1); // HOOKS_IGNORE
            break;
          case 0:
              {
                  // The child process will start the bridge
                  // Close stdin and any other file descriptors.
                  fclose(stdin);
                  for (int k = 3 ; k < 32 ; ++k)
                  {
                      close(k);
                  }
                  CreateSocketBridge((void*)ports);
                  exit(0); // HOOKS_IGNORE
                  break;
              }
          default:
            // Parent process continues on as normal
            // Caution: there is a slight race condition here, though
            // it would require the engine to launch and try to connect
            // back before the child process got the bridge set up.
            // The odds of this happening are low, but it should be fixed.
            break;
        }
#endif
    }
    else
    {
        debug5 << mName << "Required -host or -port argument not found" << endl;
    }

    return setupBridge;
}
开发者ID:HarinarayanKrishnan,项目名称:VisIt26RC_Trunk,代码行数:94,代码来源:LaunchService.C

示例8:

void
SetVisItEnvironment(const stringVector &env)
{
    for(size_t i = 0; i < env.size(); ++i)
        _putenv(env[i].c_str());
}
开发者ID:cchriste,项目名称:visit,代码行数:6,代码来源:visit.c

示例9: GetInput

avtContract_p
avtModelFitFilter::ModifyContract(avtContract_p in_spec){
    std::string db = GetInput()->GetInfo().GetAttributes().GetFullDBName();
    ref_ptr<avtDatabase> dbp = avtCallback::GetDatabase(db, 0, NULL);
    avtDatabaseMetaData *md = dbp->GetMetaData(0);

    numTimesteps = (int)md->GetTimes().size();
    activeTs = in_spec->GetDataRequest()->GetTimestep();

    std::string meshName = GetInput()->GetInfo().GetAttributes().GetMeshname();

    pipelineVar = in_spec->GetDataRequest()->GetVariable();
    new_pipelineVar = strdup(pipelineVar);

    const stringVector curListedVars = atts.GetVars();

    if(!curListedVars.size())
    return in_spec;
  
    if((!strcmp(pipelineVar, "operators/ModelFit/model")) || 
       (!strcmp(pipelineVar, "operators/ModelFit/distance")))
        for(int i = 0; ; i++)
          if((strcmp(curListedVars[i].c_str(), "operators/ModelFit/model")) && 
             (strcmp(curListedVars[i].c_str(), "operators/ModelFit/distance")))
            {
                strcpy(new_pipelineVar, curListedVars[i].c_str());
                break;
            }

    avtDataRequest_p aDR  = new avtDataRequest(in_spec->GetDataRequest(), new_pipelineVar);
    aDR->SetOriginalVariable(pipelineVar);
    avtContract_p outSpec = new avtContract(in_spec, aDR);

    const char *curListedVar;
    std::vector<CharStrRef> curSecondaryVars = outSpec->GetDataRequest()->GetSecondaryVariables();
    size_t listedVarNum, secVarNum;
    char secVarName[1024];

    for(listedVarNum = 0; listedVarNum < curListedVars.size(); listedVarNum++){
        curListedVar = curListedVars[listedVarNum].c_str();
    
        if(strcmp(curListedVar, pipelineVar)){
            for(secVarNum = 0; secVarNum < curSecondaryVars.size(); secVarNum++)
                if(!strcmp(*curSecondaryVars[secVarNum], curListedVar))
                    break;
            if(secVarNum >= curSecondaryVars.size())
                outSpec->GetDataRequest()->AddSecondaryVariable(curListedVar);
            sprintf(secVarName, "%s", curListedVar);
        }
        curSecondaryVars = outSpec->GetDataRequest()->GetSecondaryVariables();
    }
    
    curSecondaryVars = outSpec->GetDataRequest()->GetSecondaryVariables();
    for(secVarNum = 0; secVarNum < curSecondaryVars.size(); secVarNum++){
        if(!strcmp(*curSecondaryVars[secVarNum], "operators/ModelFit/distance"))
            outSpec->GetDataRequest()->RemoveSecondaryVariable("operators/ModelFit/distance");

        if(!strcmp(*curSecondaryVars[secVarNum], "operators/ModelFit/model"))
            outSpec->GetDataRequest()->RemoveSecondaryVariable("operators/ModelFit/model");
    }
    return outSpec;
}
开发者ID:burlen,项目名称:visit_vtk_7_src,代码行数:62,代码来源:avtModelFitFilter.C

示例10: switch

bool
avtMissingDataFilter::TagMissingData(vtkDataSet *in_ds, vtkDataArray *missingData, 
    const stringVector &varsMissingData, avtCentering centering) const
{
    bool missing = false;
    unsigned char *mdptr = (unsigned char *)missingData->GetVoidPointer(0);

    // Go through each variable and populate the avtMissingData array.
    for(size_t i = 0; i < varsMissingData.size(); ++i)
    {
        const avtScalarMetaData *scalar = metadata.GetScalar(varsMissingData[i]);
        if(scalar != NULL)
        {
            // Try checking the current variable against the cell data.
            vtkDataArray *arr = in_ds->GetCellData()->GetArray(varsMissingData[i].c_str());
            if(arr != 0)
            {
                debug5 << "\tApplying rule for cell data \"" << varsMissingData[i]
                       << "\" to avtMissingData" << endl;
                vtkIdType nCells = in_ds->GetNumberOfCells();

                switch(scalar->GetMissingDataType())
                {
                case avtScalarMetaData::MissingData_Value:
                    { // new scope
                    double missingValue = scalar->GetMissingData()[0];
                    for(vtkIdType cellid = 0; cellid < nCells; ++cellid)
                    {
                        if(arr->GetTuple1(cellid) == missingValue)
                        {
                            mdptr[cellid] = 1;
                            missing = true;
                        }
                    }
                    }
                    break;
                case avtScalarMetaData::MissingData_Valid_Min:
                    { // new scope
                    double minValue = scalar->GetMissingData()[0];
                    for(vtkIdType cellid = 0; cellid < nCells; ++cellid)
                    {
                        if(arr->GetTuple1(cellid) < minValue)
                        {
                            mdptr[cellid] = 1;
                            missing = true;
                        }
                    }
                    }
                    break;
                case avtScalarMetaData::MissingData_Valid_Max:
                    { // new scope
                    double maxValue = scalar->GetMissingData()[0];
                    for(vtkIdType cellid = 0; cellid < nCells; ++cellid)
                    {
                        if(arr->GetTuple1(cellid) > maxValue)
                        {
                            mdptr[cellid] = 1;
                            missing = true;
                        }
                    }
                    }
                    break;
                case avtScalarMetaData::MissingData_Valid_Range:
                    { // new scope
                    double minValue = scalar->GetMissingData()[0];
                    double maxValue = scalar->GetMissingData()[1];
                    for(vtkIdType cellid = 0; cellid < nCells; ++cellid)
                    {
                        double val = arr->GetTuple1(cellid);
                        if(val < minValue || val > maxValue)
                        {
                            mdptr[cellid] = 1;
                            missing = true;
                        }
                    }
                    }
                    break;
                default:
                    break;
                }
            }

            // Try checking the current variable against the point data.
            arr = in_ds->GetPointData()->GetArray(varsMissingData[i].c_str());
            if(arr != 0)
            {
                debug5 << "\tApplying rule for point data \"" << varsMissingData[i]
                       << "\" to avtMissingData. Storing values as "
                       << (centering==AVT_ZONECENT?"cells":"points") << endl;

                vtkIdType nPoints = in_ds->GetNumberOfPoints();
                vtkIdList *idList = vtkIdList::New();
                switch(scalar->GetMissingDataType())
                {
                case avtScalarMetaData::MissingData_Value:
                    { // new scope
                    double missingValue = scalar->GetMissingData()[0];
                    if(centering == AVT_NODECENT)
                    {
                        for(vtkIdType ptid = 0; ptid < nPoints; ++ptid)
//.........这里部分代码省略.........
开发者ID:burlen,项目名称:visit_vtk_7_src,代码行数:101,代码来源:avtMissingDataFilter.C

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

示例12: if

avtDataTree_p
avtQueryOverTimeFilter::CreateTree(const doubleVector &times,
                                   const doubleVector &res,
                                   stringVector &vars,
                                   const bool doMultiCurvePlot)
{
    int nPts = 0;
    bool singleCurve = true;
    if (useTimeForXAxis && nResultsToStore == 1)
    {
        // Single curve with time for x axis.  NORMAL case.
        // Most queries currently use this option.
        nPts = (times.size() <= res.size() ? times.size() : res.size());
    }
    else if (!useTimeForXAxis && nResultsToStore == 2)
    {
        // Single curve, res[odd] = x, res[even] = y.
        nPts = res.size() / 2;
    }
    else if (useTimeForXAxis && nResultsToStore > 1)
    {
        singleCurve = false;
    }
    else if (!useTimeForXAxis && nResultsToStore > 2)
    {
        // multiple curves, res[odd] = x, res[even] = y.
    }

    if (singleCurve)
    {

        vtkRectilinearGrid *rgrid = vtkVisItUtility::Create1DRGrid(nPts);

        if (nPts == 0)
        {
            avtDataTree_p tree = new avtDataTree(rgrid, 0);
            rgrid->Delete();
            return tree;
        }

        vtkDataArray *xc = rgrid->GetXCoordinates();
        vtkDoubleArray *sc = vtkDoubleArray::New();

        sc->SetNumberOfComponents(1);
        sc->SetNumberOfTuples(nPts);

        rgrid->GetPointData()->SetScalars(sc);
        rgrid->SetDimensions(nPts, 1 , 1);

        sc->Delete();

        for (int i = 0; i < nPts; i++)
        {
            if (useTimeForXAxis)
            {
                xc->SetTuple1(i, times[i]);
                sc->SetTuple1(i, res[i]);
            }
            else
            {
                xc->SetTuple1(i, res[i*2]);
                sc->SetTuple1(i, res[i*2+1]);
            }
        }
        avtDataTree_p tree = new avtDataTree(rgrid, 0);
        rgrid->Delete();
        return tree;
    }
    else  if(doMultiCurvePlot)
    {
        // Setup for a MultiCurve plot
        nPts = times.size();

        vtkRectilinearGrid *rgrid =
            vtkVisItUtility::CreateEmptyRGrid(nPts, nResultsToStore, 1, VTK_FLOAT);

        if (nPts == 0)
        {
            avtDataTree_p tree = new avtDataTree(rgrid, 0);
            rgrid->Delete();
            return tree;
        }

        if (res.size() != nPts*nResultsToStore)
        {
            debug1 << "Mismatch in QOT times/results sizes: " << endl;
            debug1 << "    times size:      " << times.size() << endl;
            debug1 << "    nResultsToStore: " << nResultsToStore << endl;
            debug1 << "    results size:    " << res.size() << endl;
            avtDataTree_p tree = new avtDataTree(rgrid, 0);
            rgrid->Delete();
            return tree;
        }

        vtkDataArray *xc = rgrid->GetXCoordinates();
        vtkDataArray *yc = rgrid->GetYCoordinates();
        vtkDoubleArray *sc = vtkDoubleArray::New();

        sc->SetNumberOfComponents(1);
        sc->SetNumberOfTuples(nPts*nResultsToStore);
//.........这里部分代码省略.........
开发者ID:HarinarayanKrishnan,项目名称:VisIt26RC_Trunk,代码行数:101,代码来源:avtQueryOverTimeFilter.C


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