AppConfig.cpp
3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//**************************************************************************************************
// 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";
}
//**************************************************************************************************