Mercurial > hg > orthanc-databases
annotate Framework/Common/Query.h @ 522:c49136b34891 large-queries
use a prepared statement for InsertOrUpdateMetadata
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Fri, 05 Jul 2024 09:15:54 +0200 |
parents | 54d518dcd74a |
children |
rev | line source |
---|---|
0 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
507
54d518dcd74a
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
459
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
54d518dcd74a
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
459
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
459
ecd0b719cff5
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
389
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
0 | 8 * |
9 * This program is free software: you can redistribute it and/or | |
10 * modify it under the terms of the GNU Affero General Public License | |
11 * as published by the Free Software Foundation, either version 3 of | |
12 * the License, or (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, but | |
15 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 * Affero General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU Affero General Public License | |
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
24 #pragma once | |
25 | |
26 #include "DatabasesEnumerations.h" | |
27 | |
28 #include <map> | |
29 #include <vector> | |
30 #include <string> | |
31 #include <boost/noncopyable.hpp> | |
32 | |
33 | |
34 namespace OrthancDatabases | |
35 { | |
36 class Query : public boost::noncopyable | |
37 { | |
38 public: | |
39 class IParameterFormatter : public boost::noncopyable | |
40 { | |
41 public: | |
42 virtual ~IParameterFormatter() | |
43 { | |
44 } | |
45 | |
46 virtual void Format(std::string& target, | |
47 const std::string& source, | |
48 ValueType type) = 0; | |
49 }; | |
50 | |
51 private: | |
52 typedef std::map<std::string, ValueType> Parameters; | |
53 | |
54 class Token; | |
55 | |
56 std::vector<Token*> tokens_; | |
57 Parameters parameters_; | |
58 bool readOnly_; | |
59 | |
60 void Setup(const std::string& sql); | |
61 | |
62 public: | |
29 | 63 explicit Query(const std::string& sql); |
0 | 64 |
65 Query(const std::string& sql, | |
66 bool isReadOnly); | |
67 | |
68 ~Query(); | |
69 | |
70 bool IsReadOnly() const | |
71 { | |
72 return readOnly_; | |
73 } | |
74 | |
75 void SetReadOnly(bool isReadOnly) | |
76 { | |
77 readOnly_ = isReadOnly; | |
78 } | |
79 | |
80 bool HasParameter(const std::string& parameter) const; | |
81 | |
82 ValueType GetType(const std::string& parameter) const; | |
83 | |
84 void SetType(const std::string& parameter, | |
85 ValueType type); | |
86 | |
87 void Format(std::string& result, | |
88 IParameterFormatter& formatter) const; | |
89 }; | |
90 } |