OpenXLSX 1.12.1
Modern C++ Excel Library (Fork of OpenXLSX by Kenneth Troldal Balslev)
Loading...
Searching...
No Matches
XLXmlFile.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_XLXMLFILE_HPP
12#define OPENXLSX_XLXMLFILE_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 <gsl/gsl>
22
23// ===== OpenXLSX Includes ===== //
24#include "OpenXLSX-Exports.hpp"
25#include "XLXmlParser.hpp"
27
28namespace OpenXLSX
29{
30 class XLXmlData;
31 class XLDocument;
35 class XLSharedStrings;
36
41 class OPENXLSX_EXPORT XLUnsupportedElement
42 {
43 public:
45 bool empty() const { return true; }
46 std::string summary() const { return "XLUnsupportedElement"; }
47 };
48
55 class OPENXLSX_EXPORT XLXmlFile
56 {
57 public: // ===== PUBLIC MEMBER FUNCTIONS
61 XLXmlFile() = default;
62
68 std::string xmlData(XLXmlSavingDeclaration savingDeclaration = XLXmlSavingDeclaration{}) const;
69
74 explicit XLXmlFile(XLXmlData* xmlData);
75
80 XLXmlFile(const XLXmlFile& other) = default;
81
86 XLXmlFile(XLXmlFile&& other) noexcept = default;
87
91 ~XLXmlFile() = default;
92
100 bool valid() const { return m_xmlData != nullptr; }
101
107 XLXmlFile& operator=(const XLXmlFile& other) = default;
108
114 XLXmlFile& operator=(XLXmlFile&& other) noexcept = default;
115
122
128 const XLDocument& parentDoc() const;
129
135 [[nodiscard]] XLPackageServices& package();
136 [[nodiscard]] const XLPackageServices& package() const;
137
143 [[nodiscard]] XLPackagePartFactory& partFactory();
144 [[nodiscard]] const XLPackagePartFactory& partFactory() const;
145
151 [[nodiscard]] const XLSharedStringTable& sharedStringTable() const;
152
160 [[nodiscard]] const XLSharedStrings& sharedStrings() const;
161
167
172 const XMLDocument& xmlDocument() const;
173
178 std::string getXmlPath() const;
179
183 [[nodiscard]] const XLXmlData* xmlDataPart() const noexcept { return m_xmlData; }
184 [[nodiscard]] XLXmlData* xmlDataPart() noexcept { return m_xmlData; }
185
186 protected: // ===== PROTECTED MEMBER FUNCTIONS
191 void setXmlData(std::string_view xmlData);
192
198 std::string relationshipID() const;
199
200 protected: // ===== PROTECTED MEMBER VARIABLES
202 };
203} // namespace OpenXLSX
204
205#ifdef _MSC_VER // conditionally enable MSVC specific pragmas to avoid other compilers warning about unknown pragmas
206# pragma warning(pop)
207#endif // _MSC_VER
208
209#endif // OPENXLSX_XLXMLFILE_HPP
This class encapsulates the concept of an excel file. It is different from the XLWorkbook,...
Definition XLDocument.hpp:97
Abstract factory for worksheet-facing package parts.
Definition XLPackagePartFactory.hpp:53
Abstract package services port (archive + XML parts + relationships + content types).
Definition XLPackageServices.hpp:56
Abstract read-only view of the workbook shared string table.
Definition XLSharedStringTable.hpp:51
This class encapsulate the Excel concept of Shared Strings. In Excel, instead of havig individual str...
Definition XLSharedStrings.hpp:78
XLUnsupportedElement()
Definition XLXmlFile.hpp:44
std::string summary() const
Definition XLXmlFile.hpp:46
bool empty() const
Definition XLXmlFile.hpp:45
The XLXmlData class encapsulates the properties and behaviour of the .xml files in an ....
Definition XLXmlData.hpp:79
The XLXmlFile class provides an interface for derived classes to use. It functions as an ancestor to ...
Definition XLXmlFile.hpp:56
std::string getXmlPath() const
Retrieve the path of the XML data in the .xlsx zip archive via m_xmlData->getXmlPath.
Definition XLXmlFile.cpp:129
XLPackagePartFactory & partFactory()
Narrow package-part factory port (chart / drawing / image / slicer / sheet accessories).
Definition XLXmlFile.cpp:78
XLXmlData * xmlDataPart() noexcept
Definition XLXmlFile.hpp:184
~XLXmlFile()=default
Destructor. Default implementation used.
bool valid() const
check whether class is linked to a valid XML file
Definition XLXmlFile.hpp:100
XLXmlData * m_xmlData
Definition XLXmlFile.hpp:201
const XLSharedStringTable & sharedStringTable() const
Read-only shared string table (SST) port.
Definition XLXmlFile.cpp:89
XMLDocument & xmlDocument()
This function provides access to the underlying XMLDocument object.
Definition XLXmlFile.cpp:110
XLXmlFile & operator=(const XLXmlFile &other)=default
The copy assignment operator. The default implementation has been used.
XLXmlFile(XLXmlFile &&other) noexcept=default
Move constructor. Default implementation used.
const XLSharedStrings & sharedStrings() const
Full workbook SST (including getOrCreate / append).
Definition XLXmlFile.cpp:95
XLDocument & parentDoc()
This function provides access to the parent XLDocument object.
Definition XLXmlFile.cpp:61
XLXmlFile(const XLXmlFile &other)=default
Copy constructor. Default implementation used.
std::string xmlData(XLXmlSavingDeclaration savingDeclaration=XLXmlSavingDeclaration{}) const
Method for getting the XML data represented by the object.
Definition XLXmlFile.cpp:49
XLPackageServices & package()
Narrow package-services port (archive, managed XML parts, relationships, content types).
Definition XLXmlFile.cpp:67
const XLXmlData * xmlDataPart() const noexcept
Access the underlying XLXmlData pointer.
Definition XLXmlFile.hpp:183
XLXmlFile & operator=(XLXmlFile &&other) noexcept=default
The move assignment operator. The default implementation has been used.
XLXmlFile()=default
Default constructor.
The XLXmlSavingDeclaration class encapsulates the properties of an XML saving declaration,...
Definition XLXmlSavingDeclaration.hpp:29
Definition IXLCellProvider.hpp:24
OpenXLSX_xml_document XMLDocument
Definition XLXmlParser.hpp:65