diff Orthanc/Core/Toolbox.h @ 141:9362080e5e3d

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 15 Jul 2016 12:00:11 +0200
parents d73006baca3f
children d850500b8ca6
line wrap: on
line diff
--- a/Orthanc/Core/Toolbox.h	Thu Jun 30 20:45:54 2016 +0200
+++ b/Orthanc/Core/Toolbox.h	Fri Jul 15 12:00:11 2016 +0200
@@ -47,17 +47,13 @@
   {
   };
 
-  enum ServerBarrierEvent
-  {
-    ServerBarrierEvent_Stop,
-    ServerBarrierEvent_Reload  // SIGHUP signal: reload configuration file
-  };
-
   namespace Toolbox
   {
+#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
     ServerBarrierEvent ServerBarrier(const bool& stopFlag);
 
     ServerBarrierEvent ServerBarrier();
+#endif
 
     void ToUpperCase(std::string& s);  // Inplace version
 
@@ -69,23 +65,35 @@
     void ToLowerCase(std::string& result,
                      const std::string& source);
 
+#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
     void ReadFile(std::string& content,
                   const std::string& path);
+#endif
 
+#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
     bool ReadHeader(std::string& header,
                     const std::string& path,
                     size_t headerSize);
+#endif
 
+#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
     void WriteFile(const std::string& content,
                    const std::string& path);
+#endif
 
+#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
     void WriteFile(const void* content,
                    size_t size,
                    const std::string& path);
+#endif
 
+#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
     void USleep(uint64_t microSeconds);
+#endif
 
+#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
     void RemoveFile(const std::string& path);
+#endif
 
     void SplitUriComponents(UriComponents& components,
                             const std::string& uri);
@@ -102,7 +110,9 @@
     std::string FlattenUri(const UriComponents& components,
                            size_t fromLevel = 0);
 
+#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
     uint64_t GetFileSize(const std::string& path);
+#endif
 
 #if !defined(ORTHANC_ENABLE_MD5) || ORTHANC_ENABLE_MD5 == 1
     void ComputeMD5(std::string& result,
@@ -143,9 +153,11 @@
                              const std::string& content);
 #endif
 
+#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
     std::string GetPathToExecutable();
 
     std::string GetDirectoryOfExecutable();
+#endif
 
     std::string ConvertToUtf8(const std::string& source,
                               Encoding sourceEncoding);
@@ -177,9 +189,13 @@
                         const std::string& source,
                         char separator);
 
+#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
     void MakeDirectory(const std::string& path);
+#endif
 
+#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
     bool IsExistingFile(const std::string& path);
+#endif
 
 #if ORTHANC_PUGIXML_ENABLED == 1
     void JsonToXml(std::string& target,
@@ -188,8 +204,10 @@
                    const std::string& arrayElement = "item");
 #endif
 
+#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
     void ExecuteSystemCommand(const std::string& command,
                               const std::vector<std::string>& arguments);
+#endif
 
     bool IsInteger(const std::string& str);
 
@@ -201,6 +219,30 @@
 
     int GetProcessId();
 
+#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1
     bool IsRegularFile(const std::string& path);
+#endif
+
+    FILE* OpenFile(const std::string& path,
+                   FileMode mode);
+
+    void UriEncode(std::string& target,
+                   const std::string& source);
+
+    std::string GetJsonStringField(const ::Json::Value& json,
+                                   const std::string& key,
+                                   const std::string& defaultValue);
+
+    bool GetJsonBooleanField(const ::Json::Value& json,
+                             const std::string& key,
+                             bool defaultValue);
+
+    int GetJsonIntegerField(const ::Json::Value& json,
+                            const std::string& key,
+                            int defaultValue);
+
+    unsigned int GetJsonUnsignedIntegerField(const ::Json::Value& json,
+                                             const std::string& key,
+                                             unsigned int defaultValue);
   }
 }