Mercurial > hg > orthanc-webviewer
comparison Orthanc/Core/Toolbox.h @ 141:9362080e5e3d
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 15 Jul 2016 12:00:11 +0200 |
parents | d73006baca3f |
children | d850500b8ca6 |
comparison
equal
deleted
inserted
replaced
140:31615831e42d | 141:9362080e5e3d |
---|---|
45 | 45 |
46 class NullType | 46 class NullType |
47 { | 47 { |
48 }; | 48 }; |
49 | 49 |
50 enum ServerBarrierEvent | |
51 { | |
52 ServerBarrierEvent_Stop, | |
53 ServerBarrierEvent_Reload // SIGHUP signal: reload configuration file | |
54 }; | |
55 | |
56 namespace Toolbox | 50 namespace Toolbox |
57 { | 51 { |
52 #if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 | |
58 ServerBarrierEvent ServerBarrier(const bool& stopFlag); | 53 ServerBarrierEvent ServerBarrier(const bool& stopFlag); |
59 | 54 |
60 ServerBarrierEvent ServerBarrier(); | 55 ServerBarrierEvent ServerBarrier(); |
56 #endif | |
61 | 57 |
62 void ToUpperCase(std::string& s); // Inplace version | 58 void ToUpperCase(std::string& s); // Inplace version |
63 | 59 |
64 void ToLowerCase(std::string& s); // Inplace version | 60 void ToLowerCase(std::string& s); // Inplace version |
65 | 61 |
67 const std::string& source); | 63 const std::string& source); |
68 | 64 |
69 void ToLowerCase(std::string& result, | 65 void ToLowerCase(std::string& result, |
70 const std::string& source); | 66 const std::string& source); |
71 | 67 |
68 #if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 | |
72 void ReadFile(std::string& content, | 69 void ReadFile(std::string& content, |
73 const std::string& path); | 70 const std::string& path); |
74 | 71 #endif |
72 | |
73 #if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 | |
75 bool ReadHeader(std::string& header, | 74 bool ReadHeader(std::string& header, |
76 const std::string& path, | 75 const std::string& path, |
77 size_t headerSize); | 76 size_t headerSize); |
78 | 77 #endif |
78 | |
79 #if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 | |
79 void WriteFile(const std::string& content, | 80 void WriteFile(const std::string& content, |
80 const std::string& path); | 81 const std::string& path); |
81 | 82 #endif |
83 | |
84 #if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 | |
82 void WriteFile(const void* content, | 85 void WriteFile(const void* content, |
83 size_t size, | 86 size_t size, |
84 const std::string& path); | 87 const std::string& path); |
85 | 88 #endif |
89 | |
90 #if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 | |
86 void USleep(uint64_t microSeconds); | 91 void USleep(uint64_t microSeconds); |
87 | 92 #endif |
93 | |
94 #if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 | |
88 void RemoveFile(const std::string& path); | 95 void RemoveFile(const std::string& path); |
96 #endif | |
89 | 97 |
90 void SplitUriComponents(UriComponents& components, | 98 void SplitUriComponents(UriComponents& components, |
91 const std::string& uri); | 99 const std::string& uri); |
92 | 100 |
93 void TruncateUri(UriComponents& target, | 101 void TruncateUri(UriComponents& target, |
100 std::string AutodetectMimeType(const std::string& path); | 108 std::string AutodetectMimeType(const std::string& path); |
101 | 109 |
102 std::string FlattenUri(const UriComponents& components, | 110 std::string FlattenUri(const UriComponents& components, |
103 size_t fromLevel = 0); | 111 size_t fromLevel = 0); |
104 | 112 |
113 #if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 | |
105 uint64_t GetFileSize(const std::string& path); | 114 uint64_t GetFileSize(const std::string& path); |
115 #endif | |
106 | 116 |
107 #if !defined(ORTHANC_ENABLE_MD5) || ORTHANC_ENABLE_MD5 == 1 | 117 #if !defined(ORTHANC_ENABLE_MD5) || ORTHANC_ENABLE_MD5 == 1 |
108 void ComputeMD5(std::string& result, | 118 void ComputeMD5(std::string& result, |
109 const std::string& data); | 119 const std::string& data); |
110 | 120 |
141 void EncodeDataUriScheme(std::string& result, | 151 void EncodeDataUriScheme(std::string& result, |
142 const std::string& mime, | 152 const std::string& mime, |
143 const std::string& content); | 153 const std::string& content); |
144 #endif | 154 #endif |
145 | 155 |
156 #if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 | |
146 std::string GetPathToExecutable(); | 157 std::string GetPathToExecutable(); |
147 | 158 |
148 std::string GetDirectoryOfExecutable(); | 159 std::string GetDirectoryOfExecutable(); |
160 #endif | |
149 | 161 |
150 std::string ConvertToUtf8(const std::string& source, | 162 std::string ConvertToUtf8(const std::string& source, |
151 Encoding sourceEncoding); | 163 Encoding sourceEncoding); |
152 | 164 |
153 std::string ConvertFromUtf8(const std::string& source, | 165 std::string ConvertFromUtf8(const std::string& source, |
175 | 187 |
176 void TokenizeString(std::vector<std::string>& result, | 188 void TokenizeString(std::vector<std::string>& result, |
177 const std::string& source, | 189 const std::string& source, |
178 char separator); | 190 char separator); |
179 | 191 |
192 #if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 | |
180 void MakeDirectory(const std::string& path); | 193 void MakeDirectory(const std::string& path); |
181 | 194 #endif |
195 | |
196 #if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 | |
182 bool IsExistingFile(const std::string& path); | 197 bool IsExistingFile(const std::string& path); |
198 #endif | |
183 | 199 |
184 #if ORTHANC_PUGIXML_ENABLED == 1 | 200 #if ORTHANC_PUGIXML_ENABLED == 1 |
185 void JsonToXml(std::string& target, | 201 void JsonToXml(std::string& target, |
186 const Json::Value& source, | 202 const Json::Value& source, |
187 const std::string& rootElement = "root", | 203 const std::string& rootElement = "root", |
188 const std::string& arrayElement = "item"); | 204 const std::string& arrayElement = "item"); |
189 #endif | 205 #endif |
190 | 206 |
207 #if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 | |
191 void ExecuteSystemCommand(const std::string& command, | 208 void ExecuteSystemCommand(const std::string& command, |
192 const std::vector<std::string>& arguments); | 209 const std::vector<std::string>& arguments); |
210 #endif | |
193 | 211 |
194 bool IsInteger(const std::string& str); | 212 bool IsInteger(const std::string& str); |
195 | 213 |
196 void CopyJsonWithoutComments(Json::Value& target, | 214 void CopyJsonWithoutComments(Json::Value& target, |
197 const Json::Value& source); | 215 const Json::Value& source); |
199 bool StartsWith(const std::string& str, | 217 bool StartsWith(const std::string& str, |
200 const std::string& prefix); | 218 const std::string& prefix); |
201 | 219 |
202 int GetProcessId(); | 220 int GetProcessId(); |
203 | 221 |
222 #if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 | |
204 bool IsRegularFile(const std::string& path); | 223 bool IsRegularFile(const std::string& path); |
224 #endif | |
225 | |
226 FILE* OpenFile(const std::string& path, | |
227 FileMode mode); | |
228 | |
229 void UriEncode(std::string& target, | |
230 const std::string& source); | |
231 | |
232 std::string GetJsonStringField(const ::Json::Value& json, | |
233 const std::string& key, | |
234 const std::string& defaultValue); | |
235 | |
236 bool GetJsonBooleanField(const ::Json::Value& json, | |
237 const std::string& key, | |
238 bool defaultValue); | |
239 | |
240 int GetJsonIntegerField(const ::Json::Value& json, | |
241 const std::string& key, | |
242 int defaultValue); | |
243 | |
244 unsigned int GetJsonUnsignedIntegerField(const ::Json::Value& json, | |
245 const std::string& key, | |
246 unsigned int defaultValue); | |
205 } | 247 } |
206 } | 248 } |