comparison Framework/Orthanc/Core/Toolbox.cpp @ 12:9220cf4a63d5

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 09 Nov 2016 14:14:34 +0100
parents 2dbe613f6c93
children 0b9034112fde
comparison
equal deleted inserted replaced
11:4b7e0244881f 12:9220cf4a63d5
101 } 101 }
102 } 102 }
103 #endif 103 #endif
104 104
105 105
106 #if ORTHANC_PUGIXML_ENABLED == 1 106 #if ORTHANC_ENABLE_PUGIXML == 1
107 #include "ChunkedBuffer.h" 107 #include "ChunkedBuffer.h"
108 #include <pugixml.hpp> 108 #include <pugixml.hpp>
109 #endif 109 #endif
110 110
111 111
839 catch (std::runtime_error&) 839 catch (std::runtime_error&)
840 { 840 {
841 // Bad input string or bad encoding 841 // Bad input string or bad encoding
842 return ConvertToAscii(source); 842 return ConvertToAscii(source);
843 } 843 }
844 }
845
846
847 bool Toolbox::IsAsciiString(const void* data,
848 size_t size)
849 {
850 const uint8_t* p = reinterpret_cast<const uint8_t*>(data);
851
852 for (size_t i = 0; i < size; i++, p++)
853 {
854 if (*p > 127 || (*p != 0 && iscntrl(*p)))
855 {
856 return false;
857 }
858 }
859
860 return true;
844 } 861 }
845 862
846 863
847 std::string Toolbox::ConvertToAscii(const std::string& source) 864 std::string Toolbox::ConvertToAscii(const std::string& source)
848 { 865 {
1188 return boost::filesystem::exists(path); 1205 return boost::filesystem::exists(path);
1189 } 1206 }
1190 #endif 1207 #endif
1191 1208
1192 1209
1193 #if ORTHANC_PUGIXML_ENABLED == 1 1210 #if ORTHANC_ENABLE_PUGIXML == 1
1194 class ChunkedBufferWriter : public pugi::xml_writer 1211 class ChunkedBufferWriter : public pugi::xml_writer
1195 { 1212 {
1196 private: 1213 private:
1197 ChunkedBuffer buffer_; 1214 ChunkedBuffer buffer_;
1198 1215