annotate OrthancFramework/Sources/Compression/ZipReader.h @ 4932:b7ce2bb6b881 more-tags

refactored the list of MainDicomTags to be able to change it dynamicaly. Unit tests and Integration tests ok
author Alain Mazy <am@osimis.io>
date Wed, 09 Mar 2022 11:17:08 +0100
parents 43e613a7756b
children 0ea402b4d901
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4355
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
4870
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
4355
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public License
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * the License, or (at your option) any later version.
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * Lesser General Public License for more details.
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * License along with this program. If not, see
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * <http://www.gnu.org/licenses/>.
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "../OrthancFramework.h"
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #if !defined(ORTHANC_SANDBOXED)
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 # error The macro ORTHANC_SANDBOXED must be defined
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 #endif
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 #if !defined(ORTHANC_ENABLE_ZLIB)
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 # error The macro ORTHANC_ENABLE_ZLIB must be defined
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #endif
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #if ORTHANC_ENABLE_ZLIB != 1
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 # error ZLIB support must be enabled to include this file
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #endif
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 #include <stdint.h>
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 #include <string>
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 #include <boost/noncopyable.hpp>
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 #include <boost/shared_ptr.hpp>
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 namespace Orthanc
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 class ORTHANC_PUBLIC ZipReader : public boost::noncopyable
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 {
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 private:
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 class MemoryBuffer;
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 struct PImpl;
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 boost::shared_ptr<PImpl> pimpl_;
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 ZipReader();
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 void SeekFirst();
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 public:
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 ~ZipReader();
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 uint64_t GetFilesCount() const;
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
4356
18c94a82f3d4 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4355
diff changeset
66 bool ReadNextFile(std::string& filename,
18c94a82f3d4 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4355
diff changeset
67 std::string& content);
4355
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 static ZipReader* CreateFromMemory(const void* buffer,
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 size_t size);
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 static ZipReader* CreateFromMemory(const std::string& buffer);
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 #if ORTHANC_SANDBOXED != 1
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 static ZipReader* CreateFromFile(const std::string& path);
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 #endif
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 static bool IsZipMemoryBuffer(const void* buffer,
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 size_t size);
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 static bool IsZipMemoryBuffer(const std::string& content);
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 #if ORTHANC_SANDBOXED != 1
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 static bool IsZipFile(const std::string& path);
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 #endif
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 };
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 }