diff Core/Toolbox.h @ 2140:aa4b8895cd23

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 09 Nov 2016 16:12:47 +0100
parents 595cf22b3e7e
children a260a8ad83f1
line wrap: on
line diff
--- a/Core/Toolbox.h	Wed Nov 09 15:25:09 2016 +0100
+++ b/Core/Toolbox.h	Wed Nov 09 16:12:47 2016 +0100
@@ -72,12 +72,6 @@
   {
     void USleep(uint64_t microSeconds);
 
-#if ORTHANC_SANDBOXED == 0
-    ServerBarrierEvent ServerBarrier(const bool& stopFlag);
-
-    ServerBarrierEvent ServerBarrier();
-#endif
-
     void ToUpperCase(std::string& s);  // Inplace version
 
     void ToLowerCase(std::string& s);  // Inplace version
@@ -88,24 +82,6 @@
     void ToLowerCase(std::string& result,
                      const std::string& source);
 
-#if ORTHANC_SANDBOXED == 0
-    void ReadFile(std::string& content,
-                  const std::string& path);
-
-    bool ReadHeader(std::string& header,
-                    const std::string& path,
-                    size_t headerSize);
-
-    void WriteFile(const std::string& content,
-                   const std::string& path);
-
-    void WriteFile(const void* content,
-                   size_t size,
-                   const std::string& path);
-
-    void RemoveFile(const std::string& path);
-#endif
-
     void SplitUriComponents(UriComponents& components,
                             const std::string& uri);
   
@@ -121,10 +97,6 @@
     std::string FlattenUri(const UriComponents& components,
                            size_t fromLevel = 0);
 
-#if ORTHANC_SANDBOXED == 0
-    uint64_t GetFileSize(const std::string& path);
-#endif
-
 #if ORTHANC_ENABLE_MD5 == 1
     void ComputeMD5(std::string& result,
                     const std::string& data);
@@ -164,12 +136,6 @@
                              const std::string& content);
 #endif
 
-#if ORTHANC_SANDBOXED == 0
-    std::string GetPathToExecutable();
-
-    std::string GetDirectoryOfExecutable();
-#endif
-
     std::string ConvertToUtf8(const std::string& source,
                               Encoding sourceEncoding);
 
@@ -183,13 +149,6 @@
 
     std::string StripSpaces(const std::string& source);
 
-#if BOOST_HAS_DATE_TIME == 1
-    std::string GetNowIsoString();
-
-    void GetNowDicom(std::string& date,
-                     std::string& time);
-#endif
-
     // In-place percent-decoding for URL
     void UrlDecode(std::string& s);
 
@@ -203,12 +162,6 @@
                         const std::string& source,
                         char separator);
 
-#if ORTHANC_SANDBOXED == 0
-    void MakeDirectory(const std::string& path);
-
-    bool IsExistingFile(const std::string& path);
-#endif
-
 #if ORTHANC_ENABLE_PUGIXML == 1
     void JsonToXml(std::string& target,
                    const Json::Value& source,
@@ -216,11 +169,6 @@
                    const std::string& arrayElement = "item");
 #endif
 
-#if ORTHANC_SANDBOXED == 0
-    void ExecuteSystemCommand(const std::string& command,
-                              const std::vector<std::string>& arguments);
-#endif
-
     bool IsInteger(const std::string& str);
 
     void CopyJsonWithoutComments(Json::Value& target,
@@ -229,15 +177,6 @@
     bool StartsWith(const std::string& str,
                     const std::string& prefix);
 
-#if ORTHANC_SANDBOXED == 0
-    int GetProcessId();
-
-    bool IsRegularFile(const std::string& path);
-#endif
-
-    FILE* OpenFile(const std::string& path,
-                   FileMode mode);
-
     void UriEncode(std::string& target,
                    const std::string& source);
 
@@ -257,4 +196,57 @@
                                              const std::string& key,
                                              unsigned int defaultValue);
   }
+
+
+#if ORTHANC_SANDBOXED == 0
+  namespace SystemToolbox
+  {
+    ServerBarrierEvent ServerBarrier(const bool& stopFlag);
+
+    ServerBarrierEvent ServerBarrier();
+
+    void ReadFile(std::string& content,
+                  const std::string& path);
+
+    bool ReadHeader(std::string& header,
+                    const std::string& path,
+                    size_t headerSize);
+
+    void WriteFile(const void* content,
+                   size_t size,
+                   const std::string& path);
+
+    void WriteFile(const std::string& content,
+                   const std::string& path);
+
+    void RemoveFile(const std::string& path);
+
+    uint64_t GetFileSize(const std::string& path);
+
+    void MakeDirectory(const std::string& path);
+
+    bool IsExistingFile(const std::string& path);
+
+    std::string GetPathToExecutable();
+
+    std::string GetDirectoryOfExecutable();
+
+    void ExecuteSystemCommand(const std::string& command,
+                              const std::vector<std::string>& arguments);
+
+    int GetProcessId();
+
+    bool IsRegularFile(const std::string& path);
+
+    FILE* OpenFile(const std::string& path,
+                   FileMode mode);
+
+#if BOOST_HAS_DATE_TIME == 1
+    std::string GetNowIsoString();
+
+    void GetNowDicom(std::string& date,
+                     std::string& time);
+#endif
+  }
+#endif /* ORTHANC_SANDBOXED */
 }