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


C++ StringVector::empty方法代码示例

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


在下文中一共展示了StringVector::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: object

TEST_F(IdfFixture, IdfObject_GroupPushingAndPopping) {
  // NON-EXTENSIBLE OBJECT
  IdfObject object(IddObjectType::Lights);
  EXPECT_TRUE(object.pushExtensibleGroup().empty());

  // MINFIELDS INCLUDES AN EXTENSIBLE GROUP, BUT EXTENSIBLE GROUPS STILL INITIALIZED AS EMPTY
  object = IdfObject(IddObjectType::BuildingSurface_Detailed);
  EXPECT_EQ(static_cast<unsigned>(10),object.numFields());
  // push empty strings
  EXPECT_FALSE(object.pushExtensibleGroup().empty());
  EXPECT_EQ(static_cast<unsigned>(13),object.numFields());
  // push non-empty strings (correct number)
  StringVector values;
  values.push_back("2.1");
  values.push_back("100.0");
  values.push_back("0.0");
  EXPECT_FALSE(object.pushExtensibleGroup(values).empty());
  EXPECT_EQ(static_cast<unsigned>(16),object.numFields());
  // try to push incorrect number of non-empty strings
  values.pop_back();
  EXPECT_TRUE(object.pushExtensibleGroup(values).empty());
  EXPECT_EQ(static_cast<unsigned>(16),object.numFields());
  // pop until false
  StringVector result;
  result.push_back("Fake entry.");
  unsigned n = 16;
  while (!result.empty()) {
    result = object.popExtensibleGroup();
    if (!result.empty()) { n -= 3; }
    EXPECT_EQ(n,object.numFields());
  }
  EXPECT_EQ(static_cast<unsigned>(10),object.numFields());

}
开发者ID:ChengXinDL,项目名称:OpenStudio,代码行数:34,代码来源:IdfObject_GTest.cpp

示例2: process

void RpmTransaction::process(const StringVector& install,
			     const StringVector& remove,
			     const StringVector& upgrade)
{
  int rc = 0;
  int probFilter = 0;
  int notifyFlags = 0;
  int tsFlags = 0;
  rpmProblemSet probs;
  if (!upgrade.empty()) 
    probFilter |= RPMPROB_FILTER_OLDPACKAGE;
  //  probFilter |= RPMPROB_FILTER_REPLACEPKG//reinstall;;
  //  probFilter |= RPMPROB_FILTER_REPLACEOLDFILES;
  //      probFilter |= RPMPROB_FILTER_REPLACENEWFILES;
  notifyFlags |= INSTALL_LABEL | INSTALL_HASH;
  if (!remove.empty())
    addToTransactionRemove(remove);
  if (!install.empty())
    addToTransactionInstall(install);
  if (!upgrade.empty())
    addToTransactionUpgrade(upgrade);
  rpmDependencyConflict conflicts = NULL;
  int numConflicts;
  if (rpmdepCheck(m_ts, &conflicts, &numConflicts) || conflicts) 
    {
      std::cerr << "Conflicts found!!" << std::endl;
      if (conflicts)
	{
	  printDepProblems(stderr, conflicts, numConflicts);
	  rpmdepFreeConflicts(conflicts, numConflicts);
	}
      exit(EXIT_FAILURE);
    }
  rc = rpmdepOrder(m_ts);
  if (rc > 0) 
    {
      std::cerr << "Ordering failed" << std::endl;
      return;
    }
  rc = rpmRunTransactions(m_ts, rpmShowProgress, (void *)notifyFlags, NULL,
			  &probs, (rpmtransFlags)tsFlags,
			  (rpmprobFilterFlags)probFilter);
  if (rc > 0) 
    {
      std::cerr << "Error while running transaction" << std::endl;
      //	if (probs->numProblems > 0)
      //	  rpmpsPrint(stderr, probs);
    } else 
    {
      if (rc < 0)
	std::cerr << "warning:some errors occurred while running transaction" << std::endl; 
    }
  std::cout << "Done." << std::endl;


  //  rpmpsFree(probs);

}
开发者ID:marigostra,项目名称:deepsolver,代码行数:58,代码来源:rpmtrans.cpp

示例3: getIddKeyNames

const std::vector<std::string>& GasMixture::validGasTypes() {
  static StringVector result;
  if (result.empty()) {
    result = getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(),
                            OS_WindowMaterial_GasMixtureFields::Gas1Type);
    OS_ASSERT(!result.empty());
  }
  return result;
}
开发者ID:ORNL-BTRIC,项目名称:OpenStudio,代码行数:9,代码来源:GasMixture.cpp

示例4: parseStringVector

static void parseStringVector(const std::string& str, StringVector& res)
{
  res.clear();
  std::string item;
  bool inQuotes = 0;
  for(std::string::size_type i = 0;i < str.length();i++)
    {
      if (!inQuotes && str[i] == ':')
	{
	  res.push_back(item);
	  item.erase();
	  continue;
	}
      if (!inQuotes && str[i] == '\"')
	{
	  inQuotes = 1;
	  continue;
	}
      if (inQuotes && str[i] == '\"')
	{
	  if (i + 1 < str.length() && str[i + 1] == '\"')
	    {
	      item += "\"";
	      i++;
	      continue;
	    }
	  inQuotes = 0;
	  continue;
	}
      item += str[i];
    }
  if (!res.empty() || !item.empty())
    res.push_back(item);
}
开发者ID:marigostra,项目名称:deepsolver,代码行数:34,代码来源:RepoParams.cpp

示例5: throw

void
checkForUnmatchedPatterns(
	const Configuration *		cfg,
	const StringVector &		namesList,
	const StringVector &		wildcardedNamesAndTypes,
	StringVector &				unmatchedPatterns) throw(ConfigurationException)
{
	int							i;
	int							len;
	const char *				wildcardedName;

	unmatchedPatterns.empty();
	//--------
	// Check if there is a wildcarded name that does not match anything
	//--------
	len = wildcardedNamesAndTypes.length();
	for (i = 0; i < len; i += 3) {
		wildcardedName = wildcardedNamesAndTypes[i+1];
		if (!doesPatternMatchAnyUnexpandedNameInList(cfg, wildcardedName,
		                                             namesList))
		{
			unmatchedPatterns.add(wildcardedName);
		}
	}
}
开发者ID:2mia,项目名称:config4cpp,代码行数:25,代码来源:config2cpp-main.cpp

示例6: canonicalize

void SystemPath::canonicalize()
{
    StringVector aNewPathComponents;

    for ( StringVector::const_iterator i( theComponents.begin() );
           i != theComponents.end(); ++i )
    {
        if ( *i == "." )
        {
            continue;
        }
        else if ( *i == ".." )
        {
            if ( aNewPathComponents.empty() )
            {
                break;
            }
            aNewPathComponents.pop_back();
        }
        else
        {
            aNewPathComponents.push_back( *i );
        }
    }

    theComponents.swap( aNewPathComponents );
}
开发者ID:ecell,项目名称:ecell3,代码行数:27,代码来源:FullID.cpp

示例7: model

 std::vector<std::string> SimulationControl_Impl::annualSimulationEnvironmentPeriods() const {
   StringVector result;
   OptionalSqlFile oSqlFile = model().sqlFile();
   if (oSqlFile && runSimulationforWeatherFileRunPeriods()) {
     RunPeriodVector runPeriods = this->runPeriods();
     StringVector environmentPeriods = oSqlFile->availableEnvPeriods();
     for (const RunPeriod& runPeriod : runPeriods) {
       if (runPeriod.isAnnual() && !runPeriod.isRepeated()) {
         std::string rpName = runPeriod.name().get();
         StringVector::const_iterator it = std::find_if(environmentPeriods.begin(),environmentPeriods.end(),std::bind(istringEqual,rpName,std::placeholders::_1));
         if (it != environmentPeriods.end()) {
           result.push_back(*it);
         }
       }
     }
     if (result.empty()) {
       // try environment name from WeatherFile
       OptionalWeatherFile oWeatherFile = model().getOptionalUniqueModelObject<WeatherFile>();
       if (oWeatherFile) {
         OptionalString os = oWeatherFile->environmentName();
         if (os) {
           std::string candidate = *os;
           StringVector::const_iterator it = std::find_if(environmentPeriods.begin(),environmentPeriods.end(),std::bind(istringEqual,candidate,std::placeholders::_1));
           if (it != environmentPeriods.end()) {
             result.push_back(*it);
           }
         }
       }
     }
   }
   return result;
 }
开发者ID:jamiebull1,项目名称:OpenStudio,代码行数:32,代码来源:SimulationControl.cpp

示例8: getAllSymbolsUsedByKernel

ModuleLinkerPass::StringVector ModuleLinkerPass::getAllSymbolsUsedByKernel(
	const std::string& kernelName) const
{
	StringSet usedSymbols;

	usedSymbols.insert(kernelName);

	StringVector unprocessedSymbols = getAllSymbolsUsedByThisKernel(
		kernelName, _linkedModule);
	
	while(!unprocessedSymbols.empty())
	{
		StringVector newSymbols;
	
		for(auto symbol = unprocessedSymbols.begin();
			symbol != unprocessedSymbols.end(); ++symbol)
		{
			if(!usedSymbols.insert(*symbol).second) continue;
		
			if(!isKernelSymbol(_linkedModule, *symbol)) continue;
		
			StringVector kernelSymbols = getAllSymbolsUsedByThisKernel(
				*symbol, _linkedModule);
				
			newSymbols.insert(newSymbols.end(), kernelSymbols.begin(),
				kernelSymbols.end());
		}
		
		unprocessedSymbols = std::move(newSymbols);
	}
	
	return StringVector(usedSymbols.begin(), usedSymbols.end());
}
开发者ID:dougct,项目名称:ocelot-ufmg,代码行数:33,代码来源:ModuleLinkerPass.cpp

示例9: selectGapSequence

// Attempt to select one of the passed in strings as the gap sequence. If none fit the constraints,
// this sets gapSequence to the empty string and returns an error code
GapFillReturnCode GapFillProcess::selectGapSequence(int estimatedSize, const StringVector& sequences, std::string& gapSequence) const
{
    assert(!sequences.empty());
    int selectedIdx = -1;
    int selectedSizeDiff = std::numeric_limits<int>::max();

    for(size_t i = 0; i < sequences.size(); ++i)
    {
        int diff = abs(sequences[i].size() - estimatedSize);
        //printf("ES: %d S: %zu D: %d\n", estimatedSize, sequences[i].size(), diff);

        if(diff < selectedSizeDiff)
        {
            selectedSizeDiff = diff;
            selectedIdx = i;
        }
    }

    // Perform checks on the quality of the gap sequences
    int MAX_SIZE_DIFF = 100;
    if(selectedSizeDiff > MAX_SIZE_DIFF)
    {
        gapSequence = "";
        return GFRC_BAD_SIZE;
    }
    
    gapSequence = sequences[selectedIdx];
    return GFRC_OK;
}
开发者ID:AlgoLab,项目名称:FastStringGraph,代码行数:31,代码来源:GapFillProcess.cpp

示例10:

 // Get all output variable names that could be associated with this object.
 const std::vector<std::string>& Connection_Impl::outputVariableNames() const 
 { 
   static StringVector result;
   if (result.empty()) {
   }
   return result;
 }
开发者ID:CheyenneBerlin,项目名称:OpenStudio,代码行数:8,代码来源:Connection.cpp

示例11:

void
ConfigScope::listLocalNames(
	Configuration::Type		typeMask,
	StringVector &			vec) const
{
	int						i;
	int						countWanted;
	int						countUnwanted;
	ConfigScopeEntry *		entry;

	//--------
	// Iterate over all the entries in the hash table and copy
	// their names into the StringVector
	//--------
	vec.empty();
	vec.ensureCapacity(m_numEntries);
	countWanted = 0;
	countUnwanted = 0;
	for (i = 0; i < m_tableSize; i++) {
		entry = m_table[i].m_next;
		while (entry) {
			if (entry->type() & typeMask) {
				vec.add(entry->name());
				countWanted++;
			} else {
				countUnwanted++;
			}
			entry = entry->m_next;
		}
	}
	assert(countWanted + countUnwanted == m_numEntries);
}
开发者ID:offa,项目名称:config4cpp,代码行数:32,代码来源:ConfigScope.cpp

示例12: InitFromArgv

	void CommandLine::InitFromArgv(const StringVector& argv) {
		argv_ = StringVector(1);
		switches_.clear();
		begin_args_ = 1;
		SetProgram(argv.empty() ? FilePath() : FilePath(argv[0]));
		AppendSwitchesAndArguments(*this, argv);
	}
开发者ID:tantaishan,项目名称:MyEcho,代码行数:7,代码来源:command_line.cpp

示例13: ParseFunctionName

/*!
 * Parses lines for function/procedure names.
 *
 * \param line line to be processed
 * \param lastline last line processed
 * \param functionStack stack of functions
 * \param functionName function name found
 *
 * \return 1 if function name is found
 * \return 0 if it is still in some function
 * \return 2 if the code line doesn't belong to any function
 */
int CVerilogCounter::ParseFunctionName(const string &line, string &lastline, StringVector &functionStack, string &functionName)
{
	string str;
	size_t idx;
	/* FIND KEYWORD "task" / "function" */
	static int func_flag = 0, task_flag = 0;
	/* FIND KEYWORD "task" / "function" */
	idx = CUtil::FindKeyword(line, "task");
	if (idx != string::npos)
	{
		if (idx + 5 < line.length())
		{
			str = line.substr(idx + 5);
			functionStack.push_back(str);
		}
		task_flag++;/* FOUND KEYWORD "task" */
	}
	
	idx = CUtil::FindKeyword(line, "function");
	if (idx != string::npos)
	{
		if (idx + 9 < line.length())
		{
			str = line.substr(idx + 9);
			functionStack.push_back(str);
		}
		func_flag++;/* FOUND KEYWORD "function" */
	}
    
	if (functionStack.empty())
	{
		// dealing with some code out of any subroutines, it a "main" code
		return 2;
	}
    
	idx = CUtil::FindKeyword(line, "endtask");
	if(idx != string::npos){
		task_flag--;
	}
	else{
		idx = CUtil::FindKeyword(line, "endfunction");
		if(idx != string::npos){
			func_flag--;
		}
	}
	
	if (idx != string::npos)
	{
		str = functionStack.back();
		functionStack.pop_back();
		idx = str.find(";");
		if (idx != string::npos)
		{
			functionName = CUtil::ClearRedundantSpaces(str.substr(0, idx));
			lastline=line; // warning fix
			return 1;
		}
	}
	return 0;
}
开发者ID:XiangyuLi926,项目名称:2016SummerUCCProject,代码行数:72,代码来源:CVerilogCounter.cpp

示例14: initialise

void QuantitationInfo::initialise ()
{
	GenIFStream fromFile ( MsparamsDir::instance ().getParamPath ( "quan.txt" ) );
	string line;
	while ( getline ( fromFile, line ) ) {
		if ( line.length () != 0 && line [0] != '#' ) {
			name.push_back ( line );
			string n = name.back ();
			StringVector sv;
			for ( ; ; ) {
				string modificationName;
				getline ( fromFile, modificationName );
				if ( modificationName [0] == '>' ) {
					if ( sv.empty () && n != "Label:15N" ) {
						ErrorHandler::genError ()->error ( "No quantitation modifications specified for quantitation type " + n + " in file quan.txt.\n" );
					}
					break;
				}
				else
					sv.push_back ( modificationName );
			}
			singQuanInfo [n] = sv;
		}
	}
}
开发者ID:proteinprospector,项目名称:prospector,代码行数:25,代码来源:lu_quan_ratio.cpp

示例15: checkAlignmentsAreConsistent

// Check that all the strings in the vector align to the same coordinates
// of the passed in sequence
bool HapgenUtil::checkAlignmentsAreConsistent(const std::string& refString, const StringVector& queries)
{
    if(queries.empty())
        return true;

    // Perform local alignments of each query to the refString
    LocalAlignmentResultVector alignments;
    for(size_t i = 0; i < queries.size(); ++i)
        alignments.push_back(StdAlnTools::localAlignment(refString, queries[i]));

    size_t i = 0;
    for(size_t j = 1; j < alignments.size(); ++j)
    {
        if(alignments[i].targetStartIndex != alignments[j].targetStartIndex ||
           alignments[j].targetEndIndex != alignments[j].targetEndIndex)
        {
            std::cerr << "Warning: inconsistent alignments found for haplotype realignment\n";
            std::cerr << "A[" << i << "]: " << alignments[i] << "\n";
            std::cerr << "A[" << j << "]: " << alignments[j] << "\n";
            return false;
        }
    }

    return true;
}
开发者ID:SherlockThang,项目名称:sga,代码行数:27,代码来源:HapgenUtil.cpp


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