Mercurial > hg > orthanc
comparison OrthancFramework/Sources/FileStorage/FileInfo.h @ 4500:3b4940bca158
added safeguards in Orthanc::FileInfo
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 09 Feb 2021 14:49:30 +0100 |
parents | d9473bd5ed43 |
children | b525e0c3cff0 |
comparison
equal
deleted
inserted
replaced
4499:6f99949b2878 | 4500:3b4940bca158 |
---|---|
29 namespace Orthanc | 29 namespace Orthanc |
30 { | 30 { |
31 struct FileInfo | 31 struct FileInfo |
32 { | 32 { |
33 private: | 33 private: |
34 std::string uuid_; | 34 bool valid_; |
35 FileContentType contentType_; | 35 std::string uuid_; |
36 | 36 FileContentType contentType_; |
37 uint64_t uncompressedSize_; | 37 uint64_t uncompressedSize_; |
38 std::string uncompressedMD5_; | 38 std::string uncompressedMD5_; |
39 | 39 CompressionType compressionType_; |
40 CompressionType compressionType_; | 40 uint64_t compressedSize_; |
41 uint64_t compressedSize_; | 41 std::string compressedMD5_; |
42 std::string compressedMD5_; | |
43 | 42 |
44 public: | 43 public: |
45 FileInfo() | 44 FileInfo() : |
45 valid_(false) | |
46 { | 46 { |
47 } | 47 } |
48 | 48 |
49 /** | 49 /** |
50 * Constructor for an uncompressed attachment. | 50 * Constructor for an uncompressed attachment. |
51 **/ | 51 **/ |
52 FileInfo(const std::string& uuid, | 52 FileInfo(const std::string& uuid, |
53 FileContentType contentType, | 53 FileContentType contentType, |
54 uint64_t size, | 54 uint64_t size, |
55 const std::string& md5) : | 55 const std::string& md5); |
56 uuid_(uuid), | |
57 contentType_(contentType), | |
58 uncompressedSize_(size), | |
59 uncompressedMD5_(md5), | |
60 compressionType_(CompressionType_None), | |
61 compressedSize_(size), | |
62 compressedMD5_(md5) | |
63 { | |
64 } | |
65 | 56 |
66 /** | 57 /** |
67 * Constructor for a compressed attachment. | 58 * Constructor for a compressed attachment. |
68 **/ | 59 **/ |
69 FileInfo(const std::string& uuid, | 60 FileInfo(const std::string& uuid, |
70 FileContentType contentType, | 61 FileContentType contentType, |
71 uint64_t uncompressedSize, | 62 uint64_t uncompressedSize, |
72 const std::string& uncompressedMD5, | 63 const std::string& uncompressedMD5, |
73 CompressionType compressionType, | 64 CompressionType compressionType, |
74 uint64_t compressedSize, | 65 uint64_t compressedSize, |
75 const std::string& compressedMD5) : | 66 const std::string& compressedMD5); |
76 uuid_(uuid), | |
77 contentType_(contentType), | |
78 uncompressedSize_(uncompressedSize), | |
79 uncompressedMD5_(uncompressedMD5), | |
80 compressionType_(compressionType), | |
81 compressedSize_(compressedSize), | |
82 compressedMD5_(compressedMD5) | |
83 { | |
84 } | |
85 | 67 |
86 const std::string& GetUuid() const | 68 bool IsValid() const; |
87 { | 69 |
88 return uuid_; | 70 const std::string& GetUuid() const; |
89 } | |
90 | 71 |
91 FileContentType GetContentType() const | 72 FileContentType GetContentType() const; |
92 { | |
93 return contentType_; | |
94 } | |
95 | 73 |
96 uint64_t GetUncompressedSize() const | 74 uint64_t GetUncompressedSize() const; |
97 { | |
98 return uncompressedSize_; | |
99 } | |
100 | 75 |
101 CompressionType GetCompressionType() const | 76 CompressionType GetCompressionType() const; |
102 { | |
103 return compressionType_; | |
104 } | |
105 | 77 |
106 uint64_t GetCompressedSize() const | 78 uint64_t GetCompressedSize() const; |
107 { | |
108 return compressedSize_; | |
109 } | |
110 | 79 |
111 const std::string& GetCompressedMD5() const | 80 const std::string& GetCompressedMD5() const; |
112 { | |
113 return compressedMD5_; | |
114 } | |
115 | 81 |
116 const std::string& GetUncompressedMD5() const | 82 const std::string& GetUncompressedMD5() const; |
117 { | |
118 return uncompressedMD5_; | |
119 } | |
120 }; | 83 }; |
121 } | 84 } |