comparison Orthanc/Toolbox.h @ 23:7a0af291cc90

Synchronization with Orthanc mainline
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 01 Jun 2015 11:52:28 +0200
parents 02f7a0400a91
children
comparison
equal deleted inserted replaced
22:b42eeb4bd1e3 23:7a0af291cc90
35 #include "Enumerations.h" 35 #include "Enumerations.h"
36 36
37 #include <stdint.h> 37 #include <stdint.h>
38 #include <vector> 38 #include <vector>
39 #include <string> 39 #include <string>
40
41 #if ORTHANC_PUGIXML_ENABLED == 1
40 #include <json/json.h> 42 #include <json/json.h>
43 #endif
41 44
42 namespace Orthanc 45 namespace Orthanc
43 { 46 {
44 typedef std::vector<std::string> UriComponents; 47 typedef std::vector<std::string> UriComponents;
45 48
49 class NullType
50 {
51 };
52
46 namespace Toolbox 53 namespace Toolbox
47 { 54 {
48 Endianness DetectEndianness(); 55 void ServerBarrier(const bool& stopFlag);
49 56
50 void TokenizeString(std::vector<std::string>& result, 57 void ServerBarrier();
51 const std::string& source,
52 char separator);
53 58
54 void CreateNewDirectory(const std::string& path); 59 void ToUpperCase(std::string& s); // Inplace version
55 60
56 bool IsExistingFile(const std::string& path); 61 void ToLowerCase(std::string& s); // Inplace version
62
63 void ToUpperCase(std::string& result,
64 const std::string& source);
65
66 void ToLowerCase(std::string& result,
67 const std::string& source);
57 68
58 void ReadFile(std::string& content, 69 void ReadFile(std::string& content,
59 const std::string& path); 70 const std::string& path);
60 71
61 void WriteFile(const std::string& content, 72 void WriteFile(const std::string& content,
63 74
64 void USleep(uint64_t microSeconds); 75 void USleep(uint64_t microSeconds);
65 76
66 void RemoveFile(const std::string& path); 77 void RemoveFile(const std::string& path);
67 78
79 void SplitUriComponents(UriComponents& components,
80 const std::string& uri);
81
82 void TruncateUri(UriComponents& target,
83 const UriComponents& source,
84 size_t fromLevel);
85
86 bool IsChildUri(const UriComponents& baseUri,
87 const UriComponents& testedUri);
88
89 std::string AutodetectMimeType(const std::string& path);
90
91 std::string FlattenUri(const UriComponents& components,
92 size_t fromLevel = 0);
93
94 uint64_t GetFileSize(const std::string& path);
95
96 void ComputeMD5(std::string& result,
97 const std::string& data);
98
99 void ComputeMD5(std::string& result,
100 const void* data,
101 size_t length);
102
103 void ComputeSHA1(std::string& result,
104 const std::string& data);
105
106 bool IsSHA1(const std::string& str);
107
108 void DecodeBase64(std::string& result,
109 const std::string& data);
110
111 void EncodeBase64(std::string& result,
112 const std::string& data);
113
114 std::string GetPathToExecutable();
115
116 std::string GetDirectoryOfExecutable();
117
118 std::string ConvertToUtf8(const std::string& source,
119 const Encoding sourceEncoding);
120
121 std::string ConvertToAscii(const std::string& source);
122
68 std::string StripSpaces(const std::string& source); 123 std::string StripSpaces(const std::string& source);
124
125 #if BOOST_HAS_DATE_TIME == 1
126 std::string GetNowIsoString();
127 #endif
128
129 // In-place percent-decoding for URL
130 void UrlDecode(std::string& s);
131
132 Endianness DetectEndianness();
133
134 #if BOOST_HAS_REGEX == 1
135 std::string WildcardToRegularExpression(const std::string& s);
136 #endif
137
138 void TokenizeString(std::vector<std::string>& result,
139 const std::string& source,
140 char separator);
141
142 #if BOOST_HAS_REGEX == 1
143 void DecodeDataUriScheme(std::string& mime,
144 std::string& content,
145 const std::string& source);
146 #endif
147
148 void MakeDirectory(const std::string& path);
149
150 bool IsExistingFile(const std::string& path);
151
152 #if ORTHANC_PUGIXML_ENABLED == 1
153 void JsonToXml(std::string& target,
154 const Json::Value& source,
155 const std::string& rootElement = "root",
156 const std::string& arrayElement = "item");
157 #endif
158
159 void ExecuteSystemCommand(const std::string& command,
160 const std::vector<std::string>& arguments);
161
162 bool IsInteger(const std::string& str);
69 } 163 }
70 } 164 }