aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
nanodbcParser.h
Go to the documentation of this file.
1
/***************************************************************************
2
* Copyright (c) 2005-2024 by Christophe GONZALES(_at_AMU) and Pierre-Henri WUILLEMIN(_at_LIP6) *
3
* info_at_agrum_dot_org *
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 2 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, write to the *
17
* Free Software Foundation, Inc., *
18
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19
***************************************************************************/
26
27
#ifdef _ODBC
28
29
# ifndef GUM_NANODBC_PARSER_H
30
# define GUM_NANODBC_PARSER_H
31
32
# include <string>
33
# include <cstdlib>
34
# include <vector>
35
# include <stdexcept>
36
# include <sql.h>
37
38
# include <
agrum/agrum.h
>
39
# include <agrum/base/external/nanodbc/nanodbc.h>
40
41
namespace
gum
{
42
43
namespace
learning
{
44
53
class
GUM_SHARED_PUBLIC
NanodbcParser
{
54
public
:
55
// ##########################################################################
57
// ##########################################################################
59
61
NanodbcParser
();
62
64
67
NanodbcParser
(nanodbc::connection& connection,
const
std::string& query);
68
70
virtual
~NanodbcParser
();
71
73
74
75
// ########################################################################
77
// ########################################################################
79
81
82
bool
next
();
83
85
86
const
std::vector< std::string >&
current
()
const
;
87
89
std::size_t
nbLine
()
const
;
90
92
std::size_t
nbColumns
()
const
;
93
95
std::string
columnName
(
const
std::size_t i)
const
;
96
98
void
useNewQuery
(nanodbc::connection& connexion,
const
std::string& query);
99
101
102
103
# ifndef DOXYGEN_SHOULD_SKIP_THIS
104
105
private
:
106
// the result of the last SQL query performed
107
nanodbc::result _result_;
108
109
// the line number within the current query
110
std::size_t _nb_line_{std::size_t(0)};
111
112
// a vector that will contain the content of the current line of result
113
std::vector< std::string > _data_;
114
115
# endif
/* DOXYGEN_SHOULD_SKIP_THIS */
116
};
117
118
}
// namespace learning
119
120
}
// namespace gum
121
122
// include the inlined functions if necessary
123
#ifndef GUM_NO_INLINE
124
# include <
agrum/base/database/nanodbcParser_inl.h
>
125
#endif
/* GUM_NO_INLINE */
126
127
# endif
// GUM_NANODBC_PARSER_H
128
129
#endif
// _ODBC
agrum.h
gum::learning::NanodbcParser::nbColumns
std::size_t nbColumns() const
returns the number of columns in the query result
gum::learning::NanodbcParser::~NanodbcParser
virtual ~NanodbcParser()
destructor
gum::learning::NanodbcParser::next
bool next()
Gets the next line of the SQL stream and parses it.
gum::learning::NanodbcParser::NanodbcParser
NanodbcParser(nanodbc::connection &connection, const std::string &query)
constructor that executes an SQL query if the connection is active
gum::learning::NanodbcParser::nbLine
std::size_t nbLine() const
returns the current line number within the query
gum::learning::NanodbcParser::NanodbcParser
NanodbcParser()
Default constructor: create a parser without being connected.
gum::learning::NanodbcParser::useNewQuery
void useNewQuery(nanodbc::connection &connexion, const std::string &query)
start a new query
gum::learning::NanodbcParser::current
const std::vector< std::string > & current() const
returns the current parsed line.
gum::learning::NanodbcParser::columnName
std::string columnName(const std::size_t i) const
returns the name of the ith column
gum::learning
include the inlined functions if necessary
Definition
CSVParser.h:55
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
nanodbcParser_inl.h
Class for parsing SQL results using Nanodbc.
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0