annotate Framework/Common/InputFileValue.h @ 522:c49136b34891 large-queries tip

use a prepared statement for InsertOrUpdateMetadata
author Alain Mazy <am@orthanc.team>
date Fri, 05 Jul 2024 09:15:54 +0200
parents 54d518dcd74a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
244
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
244
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 *
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * This program is free software: you can redistribute it and/or
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * modify it under the terms of the GNU Affero General Public License
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * as published by the Free Software Foundation, either version 3 of
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * the License, or (at your option) any later version.
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 *
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * Affero General Public License for more details.
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 *
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * You should have received a copy of the GNU Affero General Public License
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "IValue.h"
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include <Compatibility.h>
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 namespace OrthancDatabases
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 {
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 class InputFileValue : public IValue
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 private:
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 std::string content_;
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 public:
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 explicit InputFileValue(const std::string& content) :
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 content_(content)
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 }
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 InputFileValue(const void* buffer,
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 size_t size)
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 content_.assign(reinterpret_cast<const char*>(buffer), size);
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 }
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 const std::string& GetContent() const
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 {
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 return content_;
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 }
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 const void* GetBuffer() const
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 {
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 return (content_.empty() ? NULL : content_.c_str());
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 }
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 size_t GetSize() const
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 {
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 return content_.size();
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 }
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 virtual ValueType GetType() const ORTHANC_OVERRIDE
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 {
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 return ValueType_InputFile;
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 }
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 virtual IValue* Convert(ValueType target) const ORTHANC_OVERRIDE;
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 };
02cd7254c949 separating class InputFileValue from FileValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 }