Mercurial > hg > orthanc
changeset 1648:a0a4fa28624c
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 25 Sep 2015 11:33:55 +0200 |
parents | fe458dde986e |
children | 8040d56cb0b3 |
files | Core/Toolbox.cpp Core/Toolbox.h |
diffstat | 2 files changed, 29 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/Toolbox.cpp Fri Sep 25 11:02:26 2015 +0200 +++ b/Core/Toolbox.cpp Fri Sep 25 11:33:55 2015 +0200 @@ -527,6 +527,29 @@ { result = base64_decode(data); } + + +# if BOOST_HAS_REGEX == 1 + void Toolbox::DecodeDataUriScheme(std::string& mime, + std::string& content, + const std::string& source) + { + boost::regex pattern("data:([^;]+);base64,([a-zA-Z0-9=+/]*)", + boost::regex::icase /* case insensitive search */); + + boost::cmatch what; + if (regex_match(source.c_str(), what, pattern)) + { + mime = what[1]; + DecodeBase64(content, what[2]); + } + else + { + throw OrthancException(ErrorCode_BadFileFormat); + } + } +# endif + #endif @@ -1009,28 +1032,6 @@ } -#if BOOST_HAS_REGEX == 1 - void Toolbox::DecodeDataUriScheme(std::string& mime, - std::string& content, - const std::string& source) - { - boost::regex pattern("data:([^;]+);base64,([a-zA-Z0-9=+/]*)", - boost::regex::icase /* case insensitive search */); - - boost::cmatch what; - if (regex_match(source.c_str(), what, pattern)) - { - mime = what[1]; - DecodeBase64(content, what[2]); - } - else - { - throw OrthancException(ErrorCode_BadFileFormat); - } - } -#endif - - void Toolbox::MakeDirectory(const std::string& path) { if (boost::filesystem::exists(path))
--- a/Core/Toolbox.h Fri Sep 25 11:02:26 2015 +0200 +++ b/Core/Toolbox.h Fri Sep 25 11:33:55 2015 +0200 @@ -117,6 +117,12 @@ void EncodeBase64(std::string& result, const std::string& data); + +# if BOOST_HAS_REGEX == 1 + void DecodeDataUriScheme(std::string& mime, + std::string& content, + const std::string& source); +# endif #endif std::string GetPathToExecutable(); @@ -153,12 +159,6 @@ const std::string& source, char separator); -#if BOOST_HAS_REGEX == 1 - void DecodeDataUriScheme(std::string& mime, - std::string& content, - const std::string& source); -#endif - void MakeDirectory(const std::string& path); bool IsExistingFile(const std::string& path);