comparison Core/Lua/LuaContext.h @ 4026:05a363186da6

ORTHANC_BUILDING_FRAMEWORK_LIBRARY, Orthanc::InitializeFramework()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 09 Jun 2020 16:26:57 +0200
parents f9863630ec7f
children 100fbe970762
comparison
equal deleted inserted replaced
4019:bf35c4628777 4026:05a363186da6
42 42
43 #if !defined(ORTHANC_HAS_EMBEDDED_RESOURCES) 43 #if !defined(ORTHANC_HAS_EMBEDDED_RESOURCES)
44 # error Macro ORTHANC_HAS_EMBEDDED_RESOURCES must be defined 44 # error Macro ORTHANC_HAS_EMBEDDED_RESOURCES must be defined
45 #endif 45 #endif
46 46
47 #if !defined(ORTHANC_ENABLE_CURL)
48 # error Macro ORTHANC_ENABLE_CURL must be defined
49 #endif
50
47 #if ORTHANC_ENABLE_LUA == 0 51 #if ORTHANC_ENABLE_LUA == 0
48 # error The Lua support is disabled, cannot include this file 52 # error The Lua support is disabled, cannot include this file
49 #endif 53 #endif
50 54
51 #if ORTHANC_HAS_EMBEDDED_RESOURCES == 1 55 #if ORTHANC_HAS_EMBEDDED_RESOURCES == 1
52 # include <EmbeddedResources.h> // Autogenerated file 56 # include <EmbeddedResources.h> // Autogenerated file
53 #endif 57 #endif
54 58
55 #include "../HttpClient.h" 59 #if ORTHANC_ENABLE_CURL == 1
60 # include "../HttpClient.h"
61 #endif
56 62
57 extern "C" 63 extern "C"
58 { 64 {
59 #include <lua.h> 65 #include <lua.h>
60 } 66 }
61 67
62 #include <boost/noncopyable.hpp> 68 #include <boost/noncopyable.hpp>
69 #include <json/value.h>
63 70
64 namespace Orthanc 71 namespace Orthanc
65 { 72 {
66 class ORTHANC_PUBLIC LuaContext : public boost::noncopyable 73 class ORTHANC_PUBLIC LuaContext : public boost::noncopyable
67 { 74 {
68 private: 75 private:
69 friend class LuaFunctionCall; 76 friend class LuaFunctionCall;
70 77
71 lua_State *lua_; 78 lua_State *lua_;
72 std::string log_; 79 std::string log_;
80
81 #if ORTHANC_ENABLE_CURL == 1
73 HttpClient httpClient_; 82 HttpClient httpClient_;
83 #endif
74 84
75 static int PrintToLog(lua_State *state); 85 static int PrintToLog(lua_State *state);
76 static int ParseJson(lua_State *state); 86 static int ParseJson(lua_State *state);
77 static int DumpJson(lua_State *state); 87 static int DumpJson(lua_State *state);
78 88
89 #if ORTHANC_ENABLE_CURL == 1
79 static int SetHttpCredentials(lua_State *state); 90 static int SetHttpCredentials(lua_State *state);
80
81 static int CallHttpPostOrPut(lua_State *state, 91 static int CallHttpPostOrPut(lua_State *state,
82 HttpMethod method); 92 HttpMethod method);
83 static int CallHttpGet(lua_State *state); 93 static int CallHttpGet(lua_State *state);
84 static int CallHttpPost(lua_State *state); 94 static int CallHttpPost(lua_State *state);
85 static int CallHttpPut(lua_State *state); 95 static int CallHttpPut(lua_State *state);
86 static int CallHttpDelete(lua_State *state); 96 static int CallHttpDelete(lua_State *state);
97 #endif
87 98
88 bool AnswerHttpQuery(lua_State* state); 99 bool AnswerHttpQuery(lua_State* state);
89 100
90 void ExecuteInternal(std::string* output, 101 void ExecuteInternal(std::string* output,
91 const std::string& command); 102 const std::string& command);
120 void Execute(EmbeddedResources::FileResourceId resource); 131 void Execute(EmbeddedResources::FileResourceId resource);
121 #endif 132 #endif
122 133
123 bool IsExistingFunction(const char* name); 134 bool IsExistingFunction(const char* name);
124 135
136 #if ORTHANC_ENABLE_CURL == 1
125 void SetHttpCredentials(const char* username, 137 void SetHttpCredentials(const char* username,
126 const char* password) 138 const char* password)
127 { 139 {
128 httpClient_.SetCredentials(username, password); 140 httpClient_.SetCredentials(username, password);
129 } 141 }
142 #endif
130 143
131 void RegisterFunction(const char* name, 144 void RegisterFunction(const char* name,
132 lua_CFunction func); 145 lua_CFunction func);
133 146
134 void SetGlobalVariable(const char* name, 147 void SetGlobalVariable(const char* name,