//************************************************************************************************** // AppConfig.cpp * // --------------- * // Started : 2016-09-27 * // Last Update : 2016-09-30 * // Copyright : (C) 2014-2016 MSWaters * //************************************************************************************************** //************************************************************************************************** // * // This program is free software; you can redistribute it and/or modify it under the * // terms of the GNU General Public License as published by the Free Software Foundation; * // either version 3 of the License, or (at your option) any later version. * // * //************************************************************************************************** #include "AppConfig.hpp" //************************************************************************************************** // Tell wxWidgets how to create an instance of this application class wxIMPLEMENT_APP( AppConfig ); // Define a structure declaring the command line syntax static const wxCmdLineEntryDesc tCmdLnDesc[] = { #if wxCHECK_VERSION( 3,0,0 ) { wxCMD_LINE_SWITCH, "h", "", "", wxCMD_LINE_VAL_NONE , wxCMD_LINE_OPTION_HELP }, { wxCMD_LINE_OPTION, "r", "", "", wxCMD_LINE_VAL_STRING, wxCMD_LINE_OPTION_MANDATORY }, #else { wxCMD_LINE_SWITCH, wxT("h"), wxT(""), wxT(""), wxCMD_LINE_VAL_NONE , wxCMD_LINE_OPTION_HELP }, { wxCMD_LINE_OPTION, wxT("r"), wxT(""), wxT(""), wxCMD_LINE_VAL_STRING, wxCMD_LINE_OPTION_MANDATORY }, #endif { wxCMD_LINE_NONE } }; //************************************************************************************************** bool AppConfig::OnInit( void ) { wxCmdLineParser oCmdLn; wxString osRCFile; oCmdLn.SetDesc( tCmdLnDesc ); oCmdLn.SetCmdLine( argc, argv ); if( oCmdLn.Parse( false ) != 0 ) { Usage( ); return( false ); } if( oCmdLn.Found( wxT("h") ) ) { Usage( ); return( false ); } oCmdLn.Found( wxT("r"), &osRCFile ); // Configure and create the global configuration object if( ! m_oConfig.bOpen( osRCFile ) ) return( false ); return( true ); } //************************************************************************************************** int AppConfig::MainLoop( ) { // Display the utility banner std::cout << "\n Config Class Test Utility" << "\n Version 0.41 2016-09-29)\n"; std::cout << "\noConfig.Print( ) :\n"; m_oConfig.Print( ); std::cout << "\n"; return( EXIT_SUCCESS ); } //************************************************************************************************** void AppConfig::Usage( void ) { std::cout << "\nUsage : " << GetAppName( ) << " [-OPTIONS] [FILE]" << "\nOptions : -h : Print usage (this message)" << "\n -r RCFILE : Specify a configuration file" << "\n RCFILE = ~/.gspiceui.conf (default)" << "\n\n"; } //**************************************************************************************************