本文整理汇总了C++中StringTable::find方法的典型用法代码示例。如果您正苦于以下问题:C++ StringTable::find方法的具体用法?C++ StringTable::find怎么用?C++ StringTable::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringTable
的用法示例。
在下文中一共展示了StringTable::find方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: text
GameString text(const GameStringKey& id) const {
auto a = m_strings.find(id);
if (a != m_strings.end()) {
return a->second;
}
return GameStringUtil::fromString("MISSING: " + id);
}
示例3: 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;
}
示例4: 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;
}
}
示例5: main
int main(int argc, char** argv)
{
gArgc = argc;
gArgv = argv;
if (!ReadConfig()) {
UIError("Couldn't read configuration.");
return 0;
}
if (!UIInit())
return 0;
if (argc > 1) {
gReporterDumpFile = argv[1];
}
if (gReporterDumpFile.empty()) {
// no dump file specified, run the default UI
UIShowDefaultUI();
} else {
// Start by running minidump analyzer to gather stack traces.
string reporterDumpFile = gReporterDumpFile;
vector<string> args = { reporterDumpFile };
UIRunProgram(GetProgramPath(UI_MINIDUMP_ANALYZER_FILENAME),
args, /* wait */ true);
// go ahead with the crash reporter
gExtraFile = GetAdditionalFilename(gReporterDumpFile, kExtraDataExtension);
if (gExtraFile.empty()) {
UIError(gStrings[ST_ERROR_BADARGUMENTS]);
return 0;
}
if (!UIFileExists(gExtraFile)) {
UIError(gStrings[ST_ERROR_EXTRAFILEEXISTS]);
return 0;
}
gMemoryFile = GetAdditionalFilename(gReporterDumpFile,
kMemoryReportExtension);
if (!UIFileExists(gMemoryFile)) {
gMemoryFile.erase();
}
StringTable queryParameters;
if (!ReadStringsFromFile(gExtraFile, queryParameters, true)) {
UIError(gStrings[ST_ERROR_EXTRAFILEREAD]);
return 0;
}
if (queryParameters.find("ProductName") == queryParameters.end()) {
UIError(gStrings[ST_ERROR_NOPRODUCTNAME]);
return 0;
}
// There is enough information in the extra file to rewrite strings
// to be product specific
RewriteStrings(queryParameters);
if (queryParameters.find("ServerURL") == queryParameters.end()) {
UIError(gStrings[ST_ERROR_NOSERVERURL]);
return 0;
}
// Hopefully the settings path exists in the environment. Try that before
// asking the platform-specific code to guess.
gSettingsPath = UIGetEnv("MOZ_CRASHREPORTER_DATA_DIRECTORY");
if (gSettingsPath.empty()) {
string product = queryParameters["ProductName"];
string vendor = queryParameters["Vendor"];
if (!UIGetSettingsPath(vendor, product, gSettingsPath)) {
gSettingsPath.clear();
}
}
if (gSettingsPath.empty() || !UIEnsurePathExists(gSettingsPath)) {
UIError(gStrings[ST_ERROR_NOSETTINGSPATH]);
return 0;
}
OpenLogFile();
gEventsPath = UIGetEnv("MOZ_CRASHREPORTER_EVENTS_DIRECTORY");
gPingPath = UIGetEnv("MOZ_CRASHREPORTER_PING_DIRECTORY");
// Assemble and send the crash ping
string hash;
string pingUuid;
hash = ComputeDumpHash();
if (!hash.empty()) {
AppendToEventFile("MinidumpSha256Hash", hash);
}
if (SendCrashPing(queryParameters, hash, pingUuid, gPingPath)) {
AppendToEventFile("CrashPingUUID", pingUuid);
}
// Update the crash event with stacks if they are present
//.........这里部分代码省略.........
示例6: AddSubmittedReport
static bool AddSubmittedReport(const string& serverResponse)
{
StringTable responseItems;
istringstream in(serverResponse);
ReadStrings(in, responseItems, false);
if (responseItems.find("StopSendingReportsFor") != responseItems.end()) {
// server wants to tell us to stop sending reports for a certain version
string reportPath =
gSettingsPath + UI_DIR_SEPARATOR + "EndOfLife" +
responseItems["StopSendingReportsFor"];
ofstream* reportFile = UIOpenWrite(reportPath);
if (reportFile->is_open()) {
// don't really care about the contents
*reportFile << 1 << "\n";
reportFile->close();
}
delete reportFile;
}
if (responseItems.find("Discarded") != responseItems.end()) {
// server discarded this report... save it so the user can resubmit it
// manually
return false;
}
if (responseItems.find("CrashID") == responseItems.end())
return false;
string submittedDir =
gSettingsPath + UI_DIR_SEPARATOR + "submitted";
if (!UIEnsurePathExists(submittedDir)) {
return false;
}
string path = submittedDir + UI_DIR_SEPARATOR +
responseItems["CrashID"] + ".txt";
ofstream* file = UIOpenWrite(path);
if (!file->is_open()) {
delete file;
return false;
}
char buf[1024];
UI_SNPRINTF(buf, 1024,
gStrings["CrashID"].c_str(),
responseItems["CrashID"].c_str());
*file << buf << "\n";
if (responseItems.find("ViewURL") != responseItems.end()) {
UI_SNPRINTF(buf, 1024,
gStrings["CrashDetailsURL"].c_str(),
responseItems["ViewURL"].c_str());
*file << buf << "\n";
}
file->close();
delete file;
WriteSubmissionEvent(Succeeded, responseItems["CrashID"]);
return true;
}
示例7: main
int main(int argc, char** argv)
{
gArgc = argc;
gArgv = argv;
if (!ReadConfig()) {
UIError("Couldn't read configuration.");
return 0;
}
if (!UIInit())
return 0;
if (argc > 1) {
gReporterDumpFile = argv[1];
}
if (gReporterDumpFile.empty()) {
// no dump file specified, run the default UI
UIShowDefaultUI();
} else {
gExtraFile = GetAdditionalFilename(gReporterDumpFile, kExtraDataExtension);
if (gExtraFile.empty()) {
UIError(gStrings[ST_ERROR_BADARGUMENTS]);
return 0;
}
if (!UIFileExists(gExtraFile)) {
UIError(gStrings[ST_ERROR_EXTRAFILEEXISTS]);
return 0;
}
gMemoryFile = GetAdditionalFilename(gReporterDumpFile,
kMemoryReportExtension);
if (!UIFileExists(gMemoryFile)) {
gMemoryFile.erase();
}
StringTable queryParameters;
if (!ReadStringsFromFile(gExtraFile, queryParameters, true)) {
UIError(gStrings[ST_ERROR_EXTRAFILEREAD]);
return 0;
}
if (queryParameters.find("ProductName") == queryParameters.end()) {
UIError(gStrings[ST_ERROR_NOPRODUCTNAME]);
return 0;
}
// There is enough information in the extra file to rewrite strings
// to be product specific
RewriteStrings(queryParameters);
if (queryParameters.find("ServerURL") == queryParameters.end()) {
UIError(gStrings[ST_ERROR_NOSERVERURL]);
return 0;
}
// Hopefully the settings path exists in the environment. Try that before
// asking the platform-specific code to guess.
#ifdef XP_WIN32
static const wchar_t kDataDirKey[] = L"MOZ_CRASHREPORTER_DATA_DIRECTORY";
const wchar_t *settingsPath = _wgetenv(kDataDirKey);
if (settingsPath && *settingsPath) {
gSettingsPath = WideToUTF8(settingsPath);
}
#else
static const char kDataDirKey[] = "MOZ_CRASHREPORTER_DATA_DIRECTORY";
const char *settingsPath = getenv(kDataDirKey);
if (settingsPath && *settingsPath) {
gSettingsPath = settingsPath;
}
#endif
else {
string product = queryParameters["ProductName"];
string vendor = queryParameters["Vendor"];
if (!UIGetSettingsPath(vendor, product, gSettingsPath)) {
gSettingsPath.clear();
}
}
if (gSettingsPath.empty() || !UIEnsurePathExists(gSettingsPath)) {
UIError(gStrings[ST_ERROR_NOSETTINGSPATH]);
return 0;
}
OpenLogFile();
#ifdef XP_WIN32
static const wchar_t kEventsDirKey[] = L"MOZ_CRASHREPORTER_EVENTS_DIRECTORY";
const wchar_t *eventsPath = _wgetenv(kEventsDirKey);
if (eventsPath && *eventsPath) {
gEventsPath = WideToUTF8(eventsPath);
}
#else
static const char kEventsDirKey[] = "MOZ_CRASHREPORTER_EVENTS_DIRECTORY";
const char *eventsPath = getenv(kEventsDirKey);
if (eventsPath && *eventsPath) {
gEventsPath = eventsPath;
}
//.........这里部分代码省略.........