diff Core/Toolbox.cpp @ 800:ecedd89055db

generation of DICOM images from PNG files
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 06 May 2014 16:33:40 +0200
parents 203157cb4fde
children 4689e400e0fa
line wrap: on
line diff
--- a/Core/Toolbox.cpp	Tue May 06 12:55:41 2014 +0200
+++ b/Core/Toolbox.cpp	Tue May 06 16:33:40 2014 +0200
@@ -803,5 +803,26 @@
 
     result.push_back(currentItem);
   }
+
+
+  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];
+      content = what[2];
+    }
+    else
+    {
+      throw OrthancException(ErrorCode_BadFileFormat);
+    }
+  }
+
 }