本文整理汇总了C++中StringTable::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ StringTable::insert方法的具体用法?C++ StringTable::insert怎么用?C++ StringTable::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringTable
的用法示例。
在下文中一共展示了StringTable::insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addSymbol
void LibOMF::addSymbol(ObjModule *om, const char *name, int pickAny)
{
#if LOG
printf("LibOMF::addSymbol(%s, %s, %d)\n", om->name, name, pickAny);
#endif
StringValue *s = tab.insert(name, strlen(name));
if (!s)
{ // already in table
if (!pickAny)
{ s = tab.lookup(name, strlen(name));
assert(s);
ObjSymbol *os = (ObjSymbol *)s->ptrvalue;
error("multiple definition of %s: %s and %s: %s",
om->name, name, os->om->name, os->name);
}
}
else
{
ObjSymbol *os = new ObjSymbol();
os->name = strdup(name);
os->om = om;
s->ptrvalue = (void *)os;
objsymbols.push(os);
}
}
示例2: initTraitsStringTable
void initTraitsStringTable()
{
traitsStringTable._init();
for (size_t idx = 0; ; idx++)
{
const char *s = traits[idx];
if (!s) break;
StringValue *sv = traitsStringTable.insert(s, strlen(s));
sv->ptrvalue = (void *)traits[idx];
}
}
示例3: StringID
//---------------------------------------------------------------------------
unsigned int StringID( const std::string& stringValue )
{
std::string value( stringValue );
ToLower( value );
StringTable::iterator iter = s_theStringTable.find( value );
if ( iter != s_theStringTable.end() )
{
return iter->second.m_id;
}
else
{
StringTableEntry newEntry;
newEntry.m_id = s_nextStringID;
newEntry.m_originalString = stringValue;
s_theStringTable.insert( std::make_pair( value, newEntry ) );
++ s_nextStringID;
return newEntry.m_id;
}
}