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


C++ StringMap类代码示例

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


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

示例1: checkStringMapSyntax

 void checkStringMapSyntax()
 {
     StringMapSyntaxChecker checker;
     StringMap< StringMapSyntaxChecker *> intlookup;
     intlookup.begin();
     intlookup.end();
     intlookup.insert( "ABC", &checker );
     intlookup.insertUpdate( "CDE", &checker );
     intlookup.find( "ABC" );
     intlookup.remove( "ABC" );
     intlookup.release_objects();
 }
开发者ID:DSpeichert,项目名称:OpenLiteSpeed,代码行数:12,代码来源:stringmap.cpp

示例2: FATAL_ERROR_IF

void Client::sendInventoryFields(const std::string &formname,
		const StringMap &fields)
{
	size_t fields_size = fields.size();
	FATAL_ERROR_IF(fields_size > 0xFFFF, "Unsupported number of inventory fields");

	NetworkPacket pkt(TOSERVER_INVENTORY_FIELDS, 0);
	pkt << formname << (u16) (fields_size & 0xFFFF);

	StringMap::const_iterator it;
	for (it = fields.begin(); it != fields.end(); ++it) {
		const std::string &name  = it->first;
		const std::string &value = it->second;
		pkt << name;
		pkt.putLongString(value);
	}

	Send(&pkt);
}
开发者ID:BlockMen,项目名称:minetest,代码行数:19,代码来源:client.cpp

示例3: NotifyFunctionEmitted

    virtual void NotifyFunctionEmitted(const Function &F, void *Code,
                                       size_t Size, const EmittedFunctionDetails &Details)
    {
        int8_t gc_state = jl_gc_safe_enter();
        uv_rwlock_wrlock(&threadsafe);
        jl_gc_safe_leave(gc_state);
        StringMap<jl_lambda_info_t*>::iterator linfo_it = linfo_in_flight.find(F.getName());
        jl_lambda_info_t *linfo = NULL;
        if (linfo_it != linfo_in_flight.end()) {
            linfo = linfo_it->second;
            linfo_in_flight.erase(linfo_it);
        }
#if defined(_OS_WINDOWS_)
        create_PRUNTIME_FUNCTION((uint8_t*)Code, Size, F.getName(), (uint8_t*)Code, Size, NULL);
#endif
        FuncInfo tmp = {&F, Size, Details.LineStarts, linfo};
        info[(size_t)(Code)] = tmp;
        uv_rwlock_wrunlock(&threadsafe);
    }
开发者ID:btaidm,项目名称:julia,代码行数:19,代码来源:debuginfo.cpp

示例4: if

RESTParameters::RESTParameters(const std::string &params, const StringMap &registeredParams)
{
    std::string key;
    std::string value;
    bool keyFlag = true;
    int n=0;
    // test first if n is legal before reading params to avoid crash on MSVC
    while (n<params.size() && params[n]!=' ')
    {
        if (params[n]=='=')
        {
            keyFlag = false;
        }
        else if (params[n]=='&' || params[n]==' ' || params[n]=='\r' || params[n]=='\n')
        {
            if (registeredParams.find(key)!=registeredParams.end()) mParameters[key]=value;
            keyFlag = true;
            key="";
            value="";
        }
        else
        {
            if (keyFlag)
            {
                key+=params[n];
            }
            else
            {
                value+=params[n];
            }
        }

        n++;
        if (n==params.size() || params[n]==' ' || params[n]=='\r' || params[n]=='\n')
        {
            if (registeredParams.find(key)!=registeredParams.end()) mParameters[key]=value;
            key="";
            value="";
            break;
        }
    }
}
开发者ID:WilliamTambellini,项目名称:DumaisLib,代码行数:42,代码来源:RESTParameters.cpp

示例5: checkobject

// to_table(self)
int NodeMetaRef::l_to_table(lua_State *L)
{
	MAP_LOCK_REQUIRED;

	NodeMetaRef *ref = checkobject(L, 1);

	NodeMetadata *meta = getmeta(ref, true);
	if (meta == NULL) {
		lua_pushnil(L);
		return 1;
	}
	lua_newtable(L);

	// fields
	lua_newtable(L);
	{
		StringMap fields = meta->getStrings();
		for (StringMap::const_iterator
				it = fields.begin(); it != fields.end(); ++it) {
			const std::string &name = it->first;
			const std::string &value = it->second;
			lua_pushlstring(L, name.c_str(), name.size());
			lua_pushlstring(L, value.c_str(), value.size());
			lua_settable(L, -3);
		}
	}
	lua_setfield(L, -2, "fields");

	// inventory
	lua_newtable(L);
	Inventory *inv = meta->getInventory();
	if (inv) {
		std::vector<const InventoryList *> lists = inv->getLists();
		for(std::vector<const InventoryList *>::const_iterator
				i = lists.begin(); i != lists.end(); i++) {
			push_inventory_list(L, inv, (*i)->getName().c_str());
			lua_setfield(L, -2, (*i)->getName().c_str());
		}
	}
	lua_setfield(L, -2, "inventory");
	return 1;
}
开发者ID:hondalyfe88,项目名称:MultiCraft,代码行数:43,代码来源:l_nodemeta.cpp

示例6: locationFromSources

string Assembly::locationFromSources(StringMap const& _sourceCodes, SourceLocation const& _location) const
{
	if (_location.isEmpty() || _sourceCodes.empty() || _location.start >= _location.end || _location.start < 0)
		return "";

	auto it = _sourceCodes.find(*_location.sourceName);
	if (it == _sourceCodes.end())
		return "";

	string const& source = it->second;
	if (size_t(_location.start) >= source.size())
		return "";

	string cut = source.substr(_location.start, _location.end - _location.start);
	auto newLinePos = cut.find_first_of("\n");
	if (newLinePos != string::npos)
		cut = cut.substr(0, newLinePos) + "...";

	return cut;
}
开发者ID:M0rrisChang,项目名称:Smart-Contract,代码行数:20,代码来源:Assembly.cpp

示例7: getMap

/// Return the LibCallFunctionInfo object corresponding to
/// the specified function if we have it.  If not, return null.
const LibCallFunctionInfo *
LibCallInfo::getFunctionInfo(const Function *F) const {
  StringMap<const LibCallFunctionInfo*> *Map = getMap(Impl);
  
  /// If this is the first time we are querying for this info, lazily construct
  /// the StringMap to index it.
  if (!Map) {
    Impl = Map = new StringMap<const LibCallFunctionInfo*>();
    
    const LibCallFunctionInfo *Array = getFunctionInfoArray();
    if (!Array) return nullptr;
    
    // We now have the array of entries.  Populate the StringMap.
    for (unsigned i = 0; Array[i].Name; ++i)
      (*Map)[Array[i].Name] = Array+i;
  }
  
  // Look up this function in the string map.
  return Map->lookup(F->getName());
}
开发者ID:Automatic,项目名称:firmware-llvm,代码行数:22,代码来源:LibCallSemantics.cpp

示例8: ft

void
Test::assertTermEditDistance(const vespalib::string &query, const vespalib::string &field,
                             uint32_t expectedDel, uint32_t expectedIns, uint32_t expectedSub)
{
    // Setup feature test.
    vespalib::string feature = "termEditDistance(foo)";
    FtFeatureTest ft(_factory, feature);
    ft.getIndexEnv().getBuilder().addField(FieldType::INDEX, CollectionType::SINGLE, "foo");
    StringMap foo;
    foo.add("foo", field);
    FT_SETUP(ft, query, foo, 1);

    // Execute and compare results.
    search::fef::test::RankResult exp;
    exp .addScore(feature + ".out", (feature_t)(expectedDel*1 + expectedIns*1 + expectedSub*1))
        .addScore(feature + ".del", (feature_t)expectedDel)
        .addScore(feature + ".ins", (feature_t)expectedIns)
        .addScore(feature + ".sub", (feature_t)expectedSub);
    ASSERT_TRUE(ft.execute(exp));
}
开发者ID:songhtdo,项目名称:vespa,代码行数:20,代码来源:beta_features.cpp

示例9: findSubstring

 vector<int> findSubstring(string S, vector<string> &L) {
     vector<int> result;
     if (S.length() == 0 || L.size() == 0 || L[0].length() == 0)
         return result;
     //  preprocess L
     StringMap Lmap;
     for (auto it = L.begin(); it != L.end(); ++it) {
         auto findL = Lmap.find(*it);
         if (findL != Lmap.end()) {
             Lmap[*it]++;
         } else {
             Lmap[*it] = 1;
         }
     }
     int wordLength = (int)L[0].length();
     int wordNum = (int)L.size();
     for (int startPos = 0; startPos < wordLength; ++startPos) {
         findSubstringInChunk(S, startPos, wordLength, wordNum, Lmap, result);    
     }
     return result;
 }
开发者ID:dut09,项目名称:leetcode,代码行数:21,代码来源:SubstringWithConcatenationOfAllWords.cpp

示例10: parse_params

StringMap parse_params(const string &msg)
{
    StringMap params;
    Strings param_parts;
    split_str_by_chars(msg, "&", param_parts);
    for (size_t i = 0; i < param_parts.size(); ++i) {
        Strings value_parts;
        split_str_by_chars(param_parts[i], "=", value_parts, 2);
        if (value_parts.size() < 1)
            throw ParserEx("parse_params", "value_parts.size() < 1");
        string n = value_parts[0], v;
        if (value_parts.size() == 2)
            v = url_decode(value_parts[1]);
        StringMap::iterator it = params.find(n);
        if (it == params.end())
            params[n] = v;
        else
            params[n] += v;
    }
    return params;
}
开发者ID:rwiths,项目名称:schedule-mami,代码行数:21,代码来源:micro_http.cpp

示例11: isRegexStartDelim

bool Scanner::isRegexStartDelim(LexContext *ctx, const StringMap &map)
{
	/* exclude { m } or { m => ... } or { m, ... } or *m or //m */
	string prev_data = string(ctx->buffer());
	//... [before_prev_token] [prev_token] [symbol] ...
	if (map.find(prev_data) == map.end()) return false;
	Token *before_prev_token = ctx->tmgr->lastToken();
	string before_prev_data = (before_prev_token) ? string(before_prev_token->_data) : "";
	TokenType::Type before_prev_type = (before_prev_token) ?
		before_prev_token->info.type : TokenType::Undefined;
	TokenKind::Kind before_prev_kind = (before_prev_token) ?
		before_prev_token->info.kind : TokenKind::Undefined;
	char symbol = ctx->smgr->currentChar();
	if (before_prev_type == TokenType::RegDelim) return false; /* regex option */
	if (before_prev_data == "*") return false;  /* glob */
	if (before_prev_data == "&") return false;  /* function call */
	if (before_prev_data == "::") return false; /* method call */
	if (symbol == '}' || symbol == '=' || symbol == ')') return false;
	if (before_prev_kind == TokenKind::Modifier) return false; /* dereference */
	return true;
}
开发者ID:dolmen,项目名称:p5-Compiler-Lexer,代码行数:21,代码来源:Compiler_scanner.cpp

示例12: doDelete

void ConnectionQuery::doDelete(const string& table, const StringMap& filter) {
	ostringstream sql;
	sql << "DELETE FROM " << table;
	if (filter.size()) {
		sql << " WHERE ";
		for (StringMap::const_iterator it = filter.begin();;) {
//#ifndef NEWARCH
//			// sql << it->first << "=" << mysqlpp::quote << it->second;
//			sql << it->first << "=" << "'" << mysqlpp::quote << it->second << "'";
//#else
			sql << it->first << "=" << "'" << mysqlpp::quote << it->second << "'";
//#endif
			if (++it == filter.end()) {
				break;
			} else {
				sql << " AND ";
			}
		}
	}
	doExecute(sql.str());
}
开发者ID:bradenwu,项目名称:oce,代码行数:21,代码来源:connectionquery.cpp

示例13: gatherImportedSummariesForModule

/// Compute the set of summaries needed for a ThinLTO backend compilation of
/// \p ModulePath.
void llvm::gatherImportedSummariesForModule(
    StringRef ModulePath,
    const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
    const FunctionImporter::ImportMapTy &ImportList,
    std::map<std::string, GVSummaryMapTy> &ModuleToSummariesForIndex) {
  // Include all summaries from the importing module.
  ModuleToSummariesForIndex[ModulePath] =
      ModuleToDefinedGVSummaries.lookup(ModulePath);
  // Include summaries for imports.
  for (auto &ILI : ImportList) {
    auto &SummariesForIndex = ModuleToSummariesForIndex[ILI.first()];
    const auto &DefinedGVSummaries =
        ModuleToDefinedGVSummaries.lookup(ILI.first());
    for (auto &GI : ILI.second) {
      const auto &DS = DefinedGVSummaries.find(GI.first);
      assert(DS != DefinedGVSummaries.end() &&
             "Expected a defined summary for imported global value");
      SummariesForIndex[GI.first] = DS->second;
    }
  }
}
开发者ID:kraj,项目名称:llvm,代码行数:23,代码来源:FunctionImport.cpp

示例14: return

FileNameDatabaseHeader::FndbOffset
FndbManager::PushBack (/*[in]*/ const char * lpsz)
{
  if (enableStringPooling)
    {
      StringMap::const_iterator it = stringMap.find(lpsz);
      if (it != stringMap.end())
	{
	  return (it->second);
	}
    }
  FileNameDatabaseHeader::FndbOffset ret = GetMemTop();
  MIKTEX_ASSERT (lpsz != 0);
  PushBack (lpsz, strlen(lpsz));
  FastPushBack (null_byte);
  if (enableStringPooling)
    {
      stringMap[lpsz] = ret;
    }
  return (ret);
}
开发者ID:bngabonziza,项目名称:miktex,代码行数:21,代码来源:makefndb.cpp

示例15: if

RESTParameters::RESTParameters(std::string params, StringMap registeredParams)
{
    std::string key;
    std::string value;
    bool keyFlag = true;
    int n=0;
    while (params[n]!=' ' && n<params.size())
    {
        if (params[n]=='=')
        {
            keyFlag = false;
        }
        else if (params[n]=='&' || params[n]==' ' || params[n]=='\r' || params[n]=='\n')
        {
            if (registeredParams.find(key)!=registeredParams.end()) mParameters[key]=value;
            keyFlag = true;
            key="";
            value="";
        } 
        else
        {
            if (keyFlag)
            {
                key+=params[n];
            }
            else
            {
                value+=params[n];
            }
        }

        n++;
        if (params[n]==' ' || params[n]=='\r' || params[n]=='\n' || n==params.size())
        {
            if (registeredParams.find(key)!=registeredParams.end()) mParameters[key]=value;
            key="";
            value="";
        }
    }
}
开发者ID:LaughingSun,项目名称:rest,代码行数:40,代码来源:RESTParameters.cpp


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