fintp_base
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DbDad.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 DBDAD_H
22 #define DBDAD_H
23 
24 #include <string>
25 #include <map>
26 #include "CacheManager.h"
27 
28 #include "DatabaseProvider.h"
29 #include "Database.h"
30 #include "DataParameter.h"
31 
32 #include "DllMain.h"
33 
34 using namespace std;
35 
36 namespace FinTP
37 {
39  {
40  private:
41 
42  int m_Length;
43  DataType::DATA_TYPE m_Type;
44  string m_Format;
45  string m_ElementName;
46  vector< string > m_ColumnNames;
47 
48  public:
49 
50  explicit DbDadElement( string name = "UNNAMED", DataType::DATA_TYPE type = DataType::INVALID_TYPE, int length = -1, string format = "" ) :
51  m_Length( length ), m_Type( type ), m_Format( format ), m_ElementName( name )
52  {
53  }
54 
55  int length() const { return m_Length; }
56  DataType::DATA_TYPE type() const { return m_Type; }
57  string format() const { return m_Format; }
58  string name() const { return m_ElementName; }
59  const vector< string >& columnNames() const { return m_ColumnNames; }
60 
61  void addColumnName( const string& columnName ) { m_ColumnNames.push_back( columnName ); }
62  };
63 
65  {
66  public :
68  {
71  WITHVALUES
72  };
73 
74  private :
75 
76  map< string, DbDadElement > m_Elements;
77  string m_TableName;
78  DatabaseProviderFactory* m_DbProvider;
79 
80 
81  bool CastAndAdd( bool& first, stringstream& statementString, stringstream& castString, const string& parameterName, const string& parameterValue, bool escape = true );
82  bool CastAndAdd( bool& first, stringstream& statementString, stringstream& castString, const string& parameterName, const string& parameterValue, ParametersVector& params );
83 
84  public :
85 
86  DbDad() : m_TableName( "NONE" ) { m_DbProvider = NULL;}
87  explicit DbDad( const string& filename, DatabaseProviderFactory* dbProvider );
88 
89  /*const DataType::DATA_TYPE elementType( const string& elementName ) const;
90  const int elementLength( const string& elementName ) const;
91  const string DbDad::elementFormat( const string& elementName ) const;*/
92 
93  const DbDadElement& operator[]( const string& name );
94 
95  const string tableName() const { return m_TableName; }
96  void Upload( const string& xmlData, Database* currentDatabase, bool usingParams = false );
97  };
98 }
99 
100 #endif // DBDAD_H