comparison Framework/PostgreSQL/PostgreSQLResult.h @ 0:7cea966b6829

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 04 Jul 2018 08:16:29 +0200
parents
children 6a574d810b98
comparison
equal deleted inserted replaced
-1:000000000000 0:7cea966b6829
1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Affero General Public License
9 * as published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/
20
21
22 #pragma once
23
24 #if ORTHANC_ENABLE_POSTGRESQL != 1
25 # error PostgreSQL support must be enabled to use this file
26 #endif
27
28 #include "PostgreSQLStatement.h"
29
30 namespace OrthancDatabases
31 {
32 class PostgreSQLResult : public boost::noncopyable
33 {
34 private:
35 void *result_; /* Object of type "PGresult*" */
36 int position_;
37 PostgreSQLDatabase& database_;
38 unsigned int columnsCount_;
39
40 void Clear();
41
42 void CheckDone();
43
44 void CheckColumn(unsigned int column, /*Oid*/ unsigned int expectedType) const;
45
46 public:
47 explicit PostgreSQLResult(PostgreSQLStatement& statement);
48
49 ~PostgreSQLResult()
50 {
51 Clear();
52 }
53
54 void Next();
55
56 bool IsDone() const
57 {
58 return result_ == NULL;
59 }
60
61 unsigned int GetColumnsCount() const
62 {
63 return columnsCount_;
64 }
65
66 bool IsNull(unsigned int column) const;
67
68 bool GetBoolean(unsigned int column) const;
69
70 int GetInteger(unsigned int column) const;
71
72 int64_t GetInteger64(unsigned int column) const;
73
74 std::string GetString(unsigned int column) const;
75
76 void GetLargeObject(std::string& result,
77 unsigned int column) const;
78
79 void GetLargeObject(void*& result,
80 size_t& size,
81 unsigned int column) const;
82
83 IValue* GetValue(unsigned int column) const;
84 };
85 }