comparison Orthanc/Core/SQLite/FunctionContext.h @ 25:15acbf5e7545

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 02 Jun 2015 11:16:30 +0200
parents
children 3809121c3290
comparison
equal deleted inserted replaced
24:ed9acb0f938e 25:15acbf5e7545
1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store
3 *
4 * Copyright (C) 2012-2015 Sebastien Jodogne <s.jodogne@gmail.com>,
5 * Medical Physics Department, CHU of Liege, Belgium
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following disclaimer
15 * in the documentation and/or other materials provided with the
16 * distribution.
17 * * Neither the name of the CHU of Liege, nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 **/
33
34
35 #pragma once
36
37 #include "Statement.h"
38
39 struct sqlite3_context;
40 struct Mem; // This corresponds to the opaque type "sqlite3_value"
41
42 namespace Orthanc
43 {
44 namespace SQLite
45 {
46 class FunctionContext : public NonCopyable
47 {
48 friend class Connection;
49
50 private:
51 struct sqlite3_context* context_;
52 unsigned int argc_;
53 struct ::Mem** argv_;
54
55 void CheckIndex(unsigned int index) const;
56
57 public:
58 FunctionContext(struct sqlite3_context* context,
59 int argc,
60 struct ::Mem** argv);
61
62 ColumnType GetColumnType(unsigned int index) const;
63
64 unsigned int GetParameterCount() const
65 {
66 return argc_;
67 }
68
69 int GetIntValue(unsigned int index) const;
70
71 int64_t GetInt64Value(unsigned int index) const;
72
73 double GetDoubleValue(unsigned int index) const;
74
75 std::string GetStringValue(unsigned int index) const;
76
77 bool IsNullValue(unsigned int index) const;
78
79 void SetNullResult();
80
81 void SetIntResult(int value);
82
83 void SetDoubleResult(double value);
84
85 void SetStringResult(const std::string& str);
86 };
87 }
88 }