// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> void ObjectCache::addObject(MultiKey key, PO obj) { if ( !obj ) return; if ( key.first != obj->publicID() || key.second.empty() ) return; bool found = false; for (size_t i = 0; i < _cache.size(); ++i) if ( _cache[i].first == key && _cache[i].second == obj ) found = true; if ( !found ) _cache.push_back(ObjectPair(key, obj)); else { if ( _errMsg < 4 ) SEISCOMP_DEBUG("Already cached object with multikey: %s/%s", key.first.c_str(), key.second.c_str()); if ( _errMsg == 3 ) SEISCOMP_DEBUG("This message will not be repeated for other objects"); ++_errMsg; } }
static void run(int argc, const char* argv[]) { PO po; PO::Option& inputFn = po.add("input").requiresValue("<filename>"); PO::Option& widgetId = po.add("widgetid").requiresValue("<filename>"); po.parse(argc, argv); // Try to load the XML file TiXmlDocument* doc = NULL; if (inputFn.enabled()) { base::FileHandle inputFile(base::open_file(inputFn.value(), "rb")); doc = new TiXmlDocument(); doc->SetValue(inputFn.value().c_str()); if (!doc->LoadFile(inputFile)) throw std::runtime_error("invalid input file"); } if (doc && widgetId.enabled()) gen_ui_class(doc, inputFn.value(), widgetId.value()); }
static void run(int argc, const char* argv[]) { PO po; PO::Option& inputOpt = po.add("input").requiresValue("<filename>"); PO::Option& widgetId = po.add("widgetid").requiresValue("<id>"); PO::Option& prefH = po.add("pref-h"); PO::Option& prefCpp = po.add("pref-cpp"); PO::Option& theme = po.add("theme"); PO::Option& strings = po.add("strings"); PO::Option& commandIds = po.add("command-ids"); PO::Option& widgetsDir = po.add("widgets-dir").requiresValue("<dir>"); PO::Option& stringsDir = po.add("strings-dir").requiresValue("<dir>"); PO::Option& guiFile = po.add("gui-file").requiresValue("<filename>"); po.parse(argc, argv); // Try to load the XML file TiXmlDocument* doc = nullptr; std::string inputFilename = po.value_of(inputOpt); if (!inputFilename.empty() && base::get_file_extension(inputFilename) == "xml") { base::FileHandle inputFile(base::open_file(inputFilename, "rb")); doc = new TiXmlDocument(); doc->SetValue(inputFilename.c_str()); if (!doc->LoadFile(inputFile.get())) { std::cerr << doc->Value() << ":" << doc->ErrorRow() << ":" << doc->ErrorCol() << ": " << "error " << doc->ErrorId() << ": " << doc->ErrorDesc() << "\n"; throw std::runtime_error("invalid input file"); } } if (doc) { // Generate widget class if (po.enabled(widgetId)) gen_ui_class(doc, inputFilename, po.value_of(widgetId)); // Generate preference header file else if (po.enabled(prefH)) gen_pref_header(doc, inputFilename); // Generate preference c++ file else if (po.enabled(prefCpp)) gen_pref_impl(doc, inputFilename); // Generate theme class else if (po.enabled(theme)) gen_theme_class(doc, inputFilename); } // Generate strings.ini.h file else if (po.enabled(strings)) { gen_strings_class(inputFilename); } // Generate command_ids.ini.h file else if (po.enabled(commandIds)) { gen_command_ids(inputFilename); } // Check all translation files (en.ini, es.ini, etc.) else if (po.enabled(widgetsDir) && po.enabled(stringsDir)) { check_strings(po.value_of(widgetsDir), po.value_of(stringsDir), po.value_of(guiFile)); } }
static void run(int argc, const char* argv[]) { PO po; PO::Option& inputOpt = po.add("input").requiresValue("<filename>"); PO::Option& widgetId = po.add("widgetid").requiresValue("<filename>"); PO::Option& prefH = po.add("pref-h"); PO::Option& prefCpp = po.add("pref-cpp"); PO::Option& skin = po.add("skin"); po.parse(argc, argv); // Try to load the XML file TiXmlDocument* doc = NULL; std::string inputFilename = po.value_of(inputOpt); if (!inputFilename.empty()) { base::FileHandle inputFile(base::open_file(inputFilename, "rb")); doc = new TiXmlDocument(); doc->SetValue(inputFilename.c_str()); if (!doc->LoadFile(inputFile.get())) throw std::runtime_error("invalid input file"); } if (doc) { if (po.enabled(widgetId)) gen_ui_class(doc, inputFilename, po.value_of(widgetId)); else if (po.enabled(prefH)) gen_pref_header(doc, inputFilename); else if (po.enabled(prefCpp)) gen_pref_impl(doc, inputFilename); else if (po.enabled(skin)) gen_skin_class(doc, inputFilename); } }