Mercurial > hg > orthanc
comparison OrthancServer/Sources/Search/DatabaseMetadataConstraint.cpp @ 5828:7030fa489669 find-refactoring
tools/find: QueryMetadata
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Mon, 07 Oct 2024 15:19:26 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
5827:976872a99d39 | 5828:7030fa489669 |
---|---|
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-2023 Osimis S.A., Belgium | |
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium | |
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium | |
8 * | |
9 * This program is free software: you can redistribute it and/or | |
10 * modify it under the terms of the GNU General Public License as | |
11 * published by the Free Software Foundation, either version 3 of the | |
12 * 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 * General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
24 #include "../PrecompiledHeadersServer.h" | |
25 #include "DatabaseMetadataConstraint.h" | |
26 | |
27 #include "../../../OrthancFramework/Sources/OrthancException.h" | |
28 | |
29 #include <boost/lexical_cast.hpp> | |
30 #include <cassert> | |
31 | |
32 | |
33 namespace Orthanc | |
34 { | |
35 DatabaseMetadataConstraint::DatabaseMetadataConstraint(MetadataType metadata, | |
36 ConstraintType type, | |
37 const std::vector<std::string>& values, | |
38 bool caseSensitive) : | |
39 metadata_(metadata), | |
40 constraintType_(type), | |
41 values_(values), | |
42 caseSensitive_(caseSensitive) | |
43 { | |
44 if (type != ConstraintType_List && | |
45 values_.size() != 1) | |
46 { | |
47 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
48 } | |
49 } | |
50 | |
51 | |
52 DatabaseMetadataConstraint::DatabaseMetadataConstraint(MetadataType metadata, | |
53 ConstraintType type, | |
54 const std::string& value, | |
55 bool caseSensitive) : | |
56 metadata_(metadata), | |
57 constraintType_(type), | |
58 caseSensitive_(caseSensitive) | |
59 { | |
60 if (type == ConstraintType_List) | |
61 { | |
62 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
63 } | |
64 | |
65 values_.push_back(value); | |
66 } | |
67 | |
68 const std::string& DatabaseMetadataConstraint::GetValue(size_t index) const | |
69 { | |
70 if (index >= values_.size()) | |
71 { | |
72 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
73 } | |
74 else | |
75 { | |
76 return values_[index]; | |
77 } | |
78 } | |
79 | |
80 | |
81 const std::string& DatabaseMetadataConstraint::GetSingleValue() const | |
82 { | |
83 if (values_.size() != 1) | |
84 { | |
85 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
86 } | |
87 else | |
88 { | |
89 return values_[0]; | |
90 } | |
91 } | |
92 | |
93 } |