/**@brief Once all options have been looked for call finishSetUp() so that any *warnings or help messages can be print and to find out if set up was *successful * @param out The std::ostream out object to print to * */ void finishSetUp(std::ostream &out = std::cout) { if (commands_.printingHelp() || commands_.gettingFlags() ) { printFlags(out); exit(1); } lookForInvalidOptionsDashInsens(); printWarnings(out); if (failed_) { exit(1); } }
virtual const char * what () const throw () override { if (m_str.empty ()) { std::stringstream ss; ss << "The provided plugin configuration is not valid!\n"; ss << "Errors/Warnings during the check were:\n"; printError (ss, m_key); printWarnings (ss, m_key); m_str = ss.str (); } return m_str.c_str (); }
int main (void) { KeySet * myConfig = ksNew (0, KS_END); Key * key = keyNew ("/sw/MyApp", KEY_CASCADING_NAME, KEY_END); KDB * handle = kdbOpen (key); if (!handle) printError (key); printWarnings (key); if (kdbGet (handle, myConfig, key) < 0) printError (key); printWarnings (key); keyDel (key); // lookup Key * result = ksLookupByName (myConfig, "/sw/MyApp/Tests/TestKey1", 0); if (!result) printf ("Key not found in KeySet\n"); else { // do something with the key const char * key_name = keyName (result); const char * key_value = keyString (result); const char * key_comment = keyString (keyGetMeta (result, "comment")); printf ("key: %s value: %s comment: %s\n", key_name, key_value, key_comment); } ksDel (myConfig); // delete the in-memory configuration // maybe you want kdbSet() myConfig here kdbClose (handle, 0); // no more affairs with the key database. }
/**@brief Once all options have been looked for call finishSetUp() so that any *warnings or help messages can be print and to find out if set up was *successful * @param out The std::ostream out object to print to * */ void finishSetUp(std::ostream &out) { if (commands_.containsFlagCaseInsensitive("-getFlags") || commands_.containsFlagCaseInsensitive("-flags") || commands_.containsFlagCaseInsensitive("-h") || commands_.containsFlagCaseInsensitive("-help")) { printFlags(out); exit(1); } lookForInvalidOptions(); printWarnings(out); if (failed_) { exit(1); } }
virtual const char * what () const throw () override { if (m_str.empty ()) { // note that the code will be re-evaluated // if it prints nothing, but an expensive // function not printing anything seems // to be unlikely. // // note that printError/printWarning will be // used either from namespace kdb or global // namespace. std::stringstream ss; ss << "Was not able to load such a plugin!\n\n"; ss << "Maybe you misspelled it, there is no such plugin or the loader has problems.\n"; ss << "You might want to try to set LD_LIBRARY_PATH, use kdb-full or kdb-static.\n"; ss << "Errors/Warnings during loading were:\n"; printError (ss, m_key); printWarnings (ss, m_key); m_str = ss.str (); } return m_str.c_str (); }