本文整理汇总了C++中StringTable类的典型用法代码示例。如果您正苦于以下问题:C++ StringTable类的具体用法?C++ StringTable怎么用?C++ StringTable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StringTable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RETURN_IF_ERROR
/***********************************************************************************
**
**
** MailRecovery::CheckAndFixLexicon
***********************************************************************************/
OP_STATUS MailRecovery::CheckAndFixLexicon()
{
OpString path;
RETURN_IF_ERROR(MailFiles::GetLexiconPath(path));
StringTable lexicon;
// Open the string table
if (lexicon.Open(path.CStr(), LEXICON_FILENAME) == OpBoolean::IS_TRUE)
{
OpStringC8 log_heading("Lexicon");
OpStatus::Ignore(DesktopFileLogger::Log(m_recovery_log,log_heading,"Checking consistency"));
if (lexicon.CheckConsistency(FALSE) == OpBoolean::IS_FALSE)
{
OpStatus::Ignore(DesktopFileLogger::Log(m_recovery_log,log_heading,"Database not consistent, deleting file and reindexing."));
// close Lexicon stringtable and delete file
RETURN_IF_ERROR(lexicon.Close(1));
OpFile lexicon_file;
RETURN_IF_ERROR(lexicon_file.Construct(path.CStr()));
RETURN_IF_ERROR(lexicon_file.Delete(TRUE));
}
else
{
OpStatus::Ignore(DesktopFileLogger::Log(m_recovery_log,log_heading,"Database consistent"));
RETURN_IF_ERROR(lexicon.Close());
}
}
return OpStatus::OK;
}
示例2: SaveSettings
void SaveSettings()
{
/*
* NOTE! This code needs to stay in sync with the preference setting
* code in in nsExceptionHandler.cpp.
*/
StringTable settings;
ReadStringsFromFile(gSettingsPath + "/" + kIniFile, settings, true);
if (!gEmailFieldHint)
settings["Email"] = gtk_entry_get_text(GTK_ENTRY(gEmailEntry));
else
settings.erase("Email");
settings["EmailMe"] =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gEmailMeCheck)) ? "1" : "0";
if (gIncludeURLCheck != 0)
settings["IncludeURL"] =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gIncludeURLCheck))
? "1" : "0";
settings["SubmitReport"] =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gSubmitReportCheck))
? "1" : "0";
WriteStringsToFile(gSettingsPath + "/" + kIniFile,
"Crash Reporter", settings, true);
}
示例3: StyleProviderImpl
StyleProviderImpl(const StyleSheet& stylesheet, StringTable& stringTable) :
stringTable(stringTable),
filters(),
gradients()
{
filters.nodes.reserve(24);
filters.ways.reserve(24);
filters.areas.reserve(24);
filters.relations.reserve(24);
filters.canvases.reserve(24);
for (const Rule& rule : stylesheet.rules) {
for (const Selector& selector : rule.selectors) {
for (const std::string& name : selector.names) {
FilterMap* filtersPtr = nullptr;
if (name == "node") filtersPtr = &filters.nodes;
else if (name == "way") filtersPtr = &filters.ways;
else if (name == "area") filtersPtr = &filters.areas;
else if (name == "relation") filtersPtr = &filters.relations;
else if (name == "canvas") filtersPtr = &filters.canvases;
else
std::domain_error("Unexpected selector name:" + name);
Filter filter = Filter();
filter.conditions.reserve(selector.conditions.size());
for (const Condition& condition : selector.conditions) {
ConditionType c;
if (condition.operation == "") c.type = OpType::Exists;
else if (condition.operation == "=") c.type = OpType::Equals;
else if (condition.operation == "!=") c.type = OpType::NotEquals;
else
std::domain_error("Unexpected condition operation:" + condition.operation);
c.key = stringTable.getId(condition.key);
c.value = stringTable.getId(condition.value);
filter.conditions.push_back(c);
}
filter.declarations.reserve(rule.declarations.size());
for (auto i = 0; i < rule.declarations.size(); ++i) {
Declaration declaration = rule.declarations[i];
uint32_t key = stringTable.getId(declaration.key);
if (utymap::utils::GradientUtils::isGradient(declaration.value))
addGradient(declaration.value);
filter.declarations[key] = Style::value_type(new StyleDeclaration(key, declaration.value));
}
std::sort(filter.conditions.begin(), filter.conditions.end(),
[](const ConditionType& c1, const ConditionType& c2) { return c1.key > c2.key; });
for (int i = selector.zoom.start; i <= selector.zoom.end; ++i) {
(*filtersPtr)[i].push_back(filter);
}
}
}
}
}
示例4: main
int main()
{
StringTable st;
assert(st.GetIndexByName("test1")==0);
assert(st.GetIndexByName("test2")==1);
assert(st.GetIndexByName("test1")==0);
assert(st.GetNameByIndex(1)=="test2");
cout<<"PASS"<<endl;
}
示例5: mergeTables
void StringTable::mergeTables(const StringTable& other)
{
TableIterator iter = other.getBegin();
const TableIterator endIter = other.getEnd();
while (iter!=endIter)
{
m_Strings[iter->first] = iter->second;
++iter;
}//while
}
示例6: StringValue
//---------------------------------------------------------------------------
const char* StringValue( const unsigned int stringID )
{
const char* errorValue = "empty!";
StringTable::iterator iter;
for ( iter = s_theStringTable.begin(); iter != s_theStringTable.end(); ++ iter )
{
if ( iter->second.m_id == stringID ) return iter->second.m_originalString.c_str();
}
return errorValue;
}
示例7: LoadSettings
static void LoadSettings()
{
/*
* NOTE! This code needs to stay in sync with the preference checking
* code in in nsExceptionHandler.cpp.
*/
StringTable settings;
if (ReadStringsFromFile(gSettingsPath + "/" + kIniFile, settings, true)) {
if (settings.find("Email") != settings.end()) {
gtk_entry_set_text(GTK_ENTRY(gEmailEntry), settings["Email"].c_str());
gEmailFieldHint = false;
}
if (settings.find("EmailMe") != settings.end()) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gEmailMeCheck),
settings["EmailMe"][0] != '0');
}
if (settings.find("IncludeURL") != settings.end() &&
gIncludeURLCheck != 0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gIncludeURLCheck),
settings["IncludeURL"][0] != '0');
}
bool enabled;
if (settings.find("SubmitReport") != settings.end())
enabled = settings["SubmitReport"][0] != '0';
else
enabled = ShouldEnableSending();
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gSubmitReportCheck),
enabled);
}
}
示例8: 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];
}
}
示例9: QuadKeyBuilderImpl
QuadKeyBuilderImpl(GeoStore& geoStore, StringTable& stringTable) :
geoStore_(geoStore),
stringTable_(stringTable),
builderKeyId_(stringTable.getId(BuilderKeyName)),
builderFactory_()
{
}
示例10: CountOccurrences
static void CountOccurrences(int nthreads) {
StringTable table;
tick_count t0 = tick_count::now();
parallel_for( blocked_range<MyString*>( Data, Data+N, 1000 ), Tally(table) );
tick_count t1 = tick_count::now();
int n = 0;
for( StringTable::iterator i=table.begin(); i!=table.end(); ++i ) {
if( verbose && nthreads )
printf("%s %d\n",i->first.c_str(),i->second);
n += i->second;
}
if ( !silent ) printf("total = %d unique = %u time = %g\n", n, unsigned(table.size()), (t1-t0).seconds());
}
示例11: 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;
}
}
示例12: Save
void Save(const char* filename)
{
const std::string header("String #");
const std::string header_next(" is ");
const char splitter = '~';
if(_origin.empty())
return;
std::ofstream fin(filename);
fin << "// Total:" << _origin.size() << std::endl;
StringTable::iterator itr = _origin.begin();
for(;itr!=_origin.end();itr++)
{
fin << header << itr->first << header_next << splitter
<< itr->second << splitter << std::endl;
}
}
示例13: strlen
void *trait_search_fp(void *arg, const char *seed)
{
//printf("trait_search_fp('%s')\n", seed);
size_t len = strlen(seed);
if (!len)
return NULL;
StringValue *sv = traitsStringTable.lookup(seed, len);
return sv ? (void*)sv->ptrvalue : NULL;
}
示例14: PushString
unsigned int PushString(unsigned int index, const std::string& content)
{
StringTable::iterator ot = _origin.find(index);
if(ot != _origin.end())
throw std::runtime_error( "String ID conflict." );
StringTableRev::iterator otr = _origin_rev.find(content);
if(otr != _origin_rev.end())
return otr->second; // duplicated string
// got unique string
_origin[index] = content;
_origin_rev[content] = index;
if(_max_id < index)
_max_id = index;
return index;
}
示例15: WriteStrings
bool WriteStrings(ostream& out,
const string& header,
StringTable& strings,
bool escape)
{
out << "[" << header << "]" << std::endl;
for (StringTable::iterator iter = strings.begin();
iter != strings.end();
iter++) {
out << iter->first << "=";
if (escape)
out << Escape(iter->second);
else
out << iter->second;
out << std::endl;
}
return true;
}