OpenXLSX 1.9.1
Loading...
Searching...
No Matches
XLCommandQuery.hpp
Go to the documentation of this file.
1#ifndef OPENXLSX_XLCOMMANDQUERY_HPP
2#define OPENXLSX_XLCOMMANDQUERY_HPP
3
4#ifdef _MSC_VER // conditionally enable MSVC specific pragmas to avoid other compilers warning about unknown pragmas
5# pragma warning(push)
6# pragma warning(disable : 4251)
7# pragma warning(disable : 4275)
8#endif // _MSC_VER
9
10// ===== External Includes ===== //
11#include <any>
12#include <cstdint> // uint8_t
13#include <map>
14#include <string>
15
16namespace OpenXLSX
17{
38
43 {
44 public:
49 explicit XLCommand(XLCommandType type) : m_type(type) {}
50
58 template<typename T>
59 XLCommand& setParam(const std::string& param, T value)
60 {
61 m_params[param] = value;
62 return *this;
63 }
64
71 template<typename T>
72 T getParam(const std::string& param) const
73 { return std::any_cast<T>(m_params.at(param)); }
74
79 XLCommandType type() const { return m_type; }
80
81 private:
82 XLCommandType m_type; /*< */
83 std::map<std::string, std::any> m_params; /*< */
84 };
85
101
106 {
107 public:
112 explicit XLQuery(XLQueryType type) : m_type(type) {}
113
121 template<typename T>
122 XLQuery& setParam(const std::string& param, T value)
123 {
124 m_params[param] = value;
125 return *this;
126 }
127
134 template<typename T>
135 T getParam(const std::string& param) const
136 { return std::any_cast<T>(m_params.at(param)); }
137
144 template<typename T>
146 {
147 m_result = value;
148 return *this;
149 }
150
156 template<typename T>
157 T result() const
158 { return std::any_cast<T>(m_result); }
159
164 XLQueryType type() const { return m_type; }
165
166 private:
167 XLQueryType m_type; /*< */
168 std::any m_result; /*< */
169 std::map<std::string, std::any> m_params; /*< */
170 };
171
172} // namespace OpenXLSX
173
174#ifdef _MSC_VER // conditionally enable MSVC specific pragmas to avoid other compilers warning about unknown pragmas
175# pragma warning(pop)
176#endif // _MSC_VER
177
178#endif // OPENXLSX_XLCOMMANDQUERY_HPP
Definition XLCommandQuery.hpp:43
XLCommand & setParam(const std::string &param, T value)
Definition XLCommandQuery.hpp:59
XLCommand(XLCommandType type)
Definition XLCommandQuery.hpp:49
XLCommandType type() const
Definition XLCommandQuery.hpp:79
T getParam(const std::string &param) const
Definition XLCommandQuery.hpp:72
Definition XLCommandQuery.hpp:106
XLQueryType type() const
Definition XLCommandQuery.hpp:164
XLQuery(XLQueryType type)
Definition XLCommandQuery.hpp:112
T getParam(const std::string &param) const
Definition XLCommandQuery.hpp:135
XLQuery & setResult(T value)
Definition XLCommandQuery.hpp:145
T result() const
Definition XLCommandQuery.hpp:157
XLQuery & setParam(const std::string &param, T value)
Definition XLCommandQuery.hpp:122
Definition IZipArchive.hpp:18
XLQueryType
Definition XLCommandQuery.hpp:89
XLCommandType
Definition XLCommandQuery.hpp:21