OpenXLSX 1.12.1
Modern C++ Excel Library (Fork of OpenXLSX by Kenneth Troldal Balslev)
Loading...
Searching...
No Matches
XLCommandQuery.hpp
Go to the documentation of this file.
1/*
2 * OpenXLSX-NX - Modern High-Performance C++ Excel Library
3 *
4 * Original work Copyright (c) 2018-2025, Kenneth Troldal Balslev and OpenXLSX contributors
5 * Modified work Copyright (c) 2026, Curry Tang and OpenXLSX-NX contributors
6 *
7 * Distributed under the BSD 3-Clause License.
8 * See LICENSE.md in the project root or https://opensource.org/licenses/BSD-3-Clause
9 */
10
11#ifndef OPENXLSX_XLCOMMANDQUERY_HPP
12#define OPENXLSX_XLCOMMANDQUERY_HPP
13
14#ifdef _MSC_VER // conditionally enable MSVC specific pragmas to avoid other compilers warning about unknown pragmas
15# pragma warning(push)
16# pragma warning(disable : 4251)
17# pragma warning(disable : 4275)
18#endif // _MSC_VER
19
20// ===== External Includes ===== //
21#include <any>
22#include <cstdint> // uint8_t
23#include <map>
24#include <string>
25
26namespace OpenXLSX
27{
48
53 {
54 public:
59 explicit XLCommand(XLCommandType type) : m_type(type) {}
60
68 template<typename T>
69 XLCommand& setParam(std::string_view param, T value)
70 {
71 m_params[std::string(param)] = std::move(value);
72 return *this;
73 }
74
81 template<typename T>
82 T getParam(std::string_view param) const
83 { return std::any_cast<T>(m_params.at(std::string(param))); }
84
89 XLCommandType type() const { return m_type; }
90
91 private:
92 XLCommandType m_type; /*< */
93 std::map<std::string, std::any> m_params; /*< */
94 };
95
111
116 {
117 public:
122 explicit XLQuery(XLQueryType type) : m_type(type) {}
123
131 template<typename T>
132 XLQuery& setParam(std::string_view param, T value)
133 {
134 m_params[std::string(param)] = std::move(value);
135 return *this;
136 }
137
144 template<typename T>
145 T getParam(std::string_view param) const
146 { return std::any_cast<T>(m_params.at(std::string(param))); }
147
154 template<typename T>
156 {
157 m_result = value;
158 return *this;
159 }
160
166 template<typename T>
167 T result() const
168 { return std::any_cast<T>(m_result); }
169
174 XLQueryType type() const { return m_type; }
175
176 private:
177 XLQueryType m_type; /*< */
178 std::any m_result; /*< */
179 std::map<std::string, std::any> m_params; /*< */
180 };
181
182} // namespace OpenXLSX
183
184#ifdef _MSC_VER // conditionally enable MSVC specific pragmas to avoid other compilers warning about unknown pragmas
185# pragma warning(pop)
186#endif // _MSC_VER
187
188#endif // OPENXLSX_XLCOMMANDQUERY_HPP
XLCommand(XLCommandType type)
Definition XLCommandQuery.hpp:59
T getParam(std::string_view param) const
Definition XLCommandQuery.hpp:82
XLCommandType type() const
Definition XLCommandQuery.hpp:89
XLCommand & setParam(std::string_view param, T value)
Definition XLCommandQuery.hpp:69
XLQueryType type() const
Definition XLCommandQuery.hpp:174
XLQuery(XLQueryType type)
Definition XLCommandQuery.hpp:122
T getParam(std::string_view param) const
Definition XLCommandQuery.hpp:145
XLQuery & setResult(T value)
Definition XLCommandQuery.hpp:155
T result() const
Definition XLCommandQuery.hpp:167
XLQuery & setParam(std::string_view param, T value)
Definition XLCommandQuery.hpp:132
Definition IXLCellProvider.hpp:24
XLQueryType
Definition XLCommandQuery.hpp:99
@ QuerySheetIndex
Definition XLCommandQuery.hpp:101
@ QuerySheetType
Definition XLCommandQuery.hpp:104
@ QuerySheetVisibility
Definition XLCommandQuery.hpp:102
@ QuerySheetName
Definition XLCommandQuery.hpp:100
@ QuerySheetIsActive
Definition XLCommandQuery.hpp:103
@ QuerySharedStrings
Definition XLCommandQuery.hpp:108
@ QuerySheetRelsTarget
Definition XLCommandQuery.hpp:107
@ QuerySheetID
Definition XLCommandQuery.hpp:105
@ QueryXmlData
Definition XLCommandQuery.hpp:109
@ QuerySheetRelsID
Definition XLCommandQuery.hpp:106
XLCommandType
Definition XLCommandQuery.hpp:31
@ AddStyles
Definition XLCommandQuery.hpp:46
@ CloneSheet
Definition XLCommandQuery.hpp:45
@ AddWorksheet
Definition XLCommandQuery.hpp:42
@ DeleteSheet
Definition XLCommandQuery.hpp:44
@ SetSheetActive
Definition XLCommandQuery.hpp:35
@ ResetCalcChain
Definition XLCommandQuery.hpp:36
@ SetSheetIndex
Definition XLCommandQuery.hpp:34
@ CheckAndFixCustomProperties
Definition XLCommandQuery.hpp:40
@ SetSheetVisibility
Definition XLCommandQuery.hpp:33
@ CheckAndFixCoreProperties
Definition XLCommandQuery.hpp:38
@ AddChartsheet
Definition XLCommandQuery.hpp:43
@ CheckAndFixExtendedProperties
Definition XLCommandQuery.hpp:39
@ SetSheetName
Definition XLCommandQuery.hpp:32
@ AddSharedStrings
Definition XLCommandQuery.hpp:41
@ SetFullCalcOnLoad
Definition XLCommandQuery.hpp:37