fintp_base
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AppSettings.h
Go to the documentation of this file.
1 /*
2 * FinTP - Financial Transactions Processing Application
3 * Copyright (C) 2013 Business Information Systems (Allevo) S.R.L.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>
17 * or contact Allevo at : 031281 Bucuresti, 23C Calea Vitan, Romania,
18 * phone +40212554577, office@allevo.ro <mailto:office@allevo.ro>, www.allevo.ro.
19 */
20 
21 #ifndef APPSETTINGS_H
22 #define APPSETTINGS_H
23 
24 #include <string>
25 #include <map>
26 
27 #include <xercesc/dom/DOM.hpp>
28 //#include <xercesc/dom/DOMBuilder.hpp>
29 //#include <xercesc/parsers/DOMBuilderImpl.hpp>
30 #include <xercesc/sax/ErrorHandler.hpp>
31 //#include <xercesc/parsers/DOMBuilderImpl.hpp>
32 
33 #include "DllMain.h"
34 #include "Collections.h"
35 
36 XERCES_CPP_NAMESPACE_USE
37 using namespace std;
38 
39 namespace FinTP
40 {
41  typedef pair< std::string, NameValueCollection > SectionEntry;
42 
43  //EXPIMP_TEMPLATE template class ExportedObject std::map< std::string, NameValueCollection >;
44 
46  {
47  public :
48 
50  {
51  None
52  };
53 
58  {
59  // Common settings
69  LOGMAXLINES
70  };
71 
72  private:
73 
74  // member variables
75  NameValueCollection m_Settings;
76  map< std::string, NameValueCollection > m_Sections;
77  map< std::string, void ( * )( DOMElement* ) > m_Readers;
78 
79  public:
80 
81  //constructors
82  AppSettings( void );
83  explicit AppSettings( const string& configFileName, const string& configContent = "" );
84 
85  //destructor
86  ~AppSettings();
87 
88  // attach callback methods for sections
89  void setSectionReader( const string& sectionName, void ( *callback )( DOMElement* ) );
90 
91  void Dump( void ) const;
92  void loadConfig( const string& configFilename, const string& configContent = "" );
93 
94  const NameValueCollection& getSettings() const { return m_Settings; }
95  const map< std::string, NameValueCollection >& getSections() const { return m_Sections; }
96 
97  bool ContainsSection( const string& section );
98 
99  NameValueCollection& getSection( const string& sectionName );
100  string getSectionAttribute( const string& sectionName, const string& attributeName );
101 
102  //operators
103  string operator[] ( const string& key ) const;
104 
105  static string getName( const ConfigPrefix prefix, const ConfigSettings setting );
106 
107  void readFiltersForConnector( const DOMNode* filters, const string& connType );
108  };
109 }
110 
111 #endif