diff OrthancFramework/Sources/RestApi/RestApiGetCall.cpp @ 4834:bec432ee1094

download of numpy arrays from the REST API
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 26 Nov 2021 19:03:32 +0100
parents 7053502fbf97
children 43e613a7756b
line wrap: on
line diff
--- a/OrthancFramework/Sources/RestApi/RestApiGetCall.cpp	Thu Nov 25 19:05:41 2021 +0100
+++ b/OrthancFramework/Sources/RestApi/RestApiGetCall.cpp	Fri Nov 26 19:03:32 2021 +0100
@@ -24,6 +24,9 @@
 #include "../PrecompiledHeaders.h"
 #include "RestApiGetCall.h"
 
+#include "../OrthancException.h"
+#include "../SerializationToolbox.h"
+
 namespace Orthanc
 {
   bool RestApiGetCall::ParseJsonRequest(Json::Value& result) const
@@ -38,4 +41,31 @@
 
     return true;
   }
+
+  
+  bool RestApiGetCall::GetBooleanArgument(const std::string& name,
+                                          bool defaultValue) const
+  {
+    HttpToolbox::Arguments::const_iterator found = getArguments_.find(name);
+
+    bool value;
+    
+    if (found == getArguments_.end())
+    {
+      return defaultValue;
+    }
+    else if (found->second.empty())
+    {
+      return true;
+    }
+    else if (SerializationToolbox::ParseBoolean(value, found->second))
+    {
+      return value;
+    }
+    else
+    {
+      throw OrthancException(ErrorCode_ParameterOutOfRange, "Expected a Boolean for GET argument \"" +
+                             name + "\", found: " + found->second);
+    }
+  }
 }