Mercurial > hg > orthanc-python
annotate Sources/PythonBytes.cpp @ 220:7ecdfdcb49d5
NEWS
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 04 Jul 2024 08:32:24 +0200 |
parents | 3678a028f1f6 |
children |
rev | line source |
---|---|
219
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
171
diff
changeset
|
1 /** |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
171
diff
changeset
|
2 * SPDX-FileCopyrightText: 2020-2023 Osimis S.A., 2024-2024 Orthanc Team SRL, 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
171
diff
changeset
|
3 * SPDX-License-Identifier: AGPL-3.0-or-later |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
171
diff
changeset
|
4 */ |
3678a028f1f6
making the project REUSE-compliant
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
171
diff
changeset
|
5 |
122 | 6 /** |
7 * Python plugin for Orthanc | |
166
6fada29b6759
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
122
diff
changeset
|
8 * Copyright (C) 2020-2023 Osimis S.A., Belgium |
6fada29b6759
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
122
diff
changeset
|
9 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
6fada29b6759
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
122
diff
changeset
|
10 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
122 | 11 * |
12 * This program is free software: you can redistribute it and/or | |
13 * modify it under the terms of the GNU Affero General Public License | |
14 * as published by the Free Software Foundation, either version 3 of | |
15 * the License, or (at your option) any later version. | |
16 * | |
17 * This program is distributed in the hope that it will be useful, but | |
18 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 * Affero General Public License for more details. | |
21 * | |
22 * You should have received a copy of the GNU Affero General Public License | |
23 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
24 **/ | |
25 | |
26 | |
27 #include "PythonBytes.h" | |
28 | |
29 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" | |
30 | |
31 | |
32 void PythonBytes::SanityCheck() | |
33 { | |
34 if (!bytes_->IsValid()) | |
35 { | |
171
c8de83fe7faa
removed deprecation warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
166
diff
changeset
|
36 ORTHANC_PLUGINS_LOG_ERROR("Cannot create Python bytes"); |
122 | 37 ORTHANC_PLUGINS_THROW_EXCEPTION(InternalError); |
38 } | |
39 } | |
40 | |
41 | |
42 PythonBytes::PythonBytes(PythonLock& lock, | |
43 const void* data, | |
44 size_t size) | |
45 { | |
46 if (data == NULL && | |
47 size != 0) | |
48 { | |
49 ORTHANC_PLUGINS_THROW_EXCEPTION(NullPointer); | |
50 } | |
51 else | |
52 { | |
53 PyObject* obj = PyBytes_FromStringAndSize(reinterpret_cast<const char*>(data), size); | |
54 bytes_.reset(new PythonObject(lock, obj)); | |
55 SanityCheck(); | |
56 } | |
57 } |