OpenXLSX 1.9.1
Loading...
Searching...
No Matches
XLContentTypes.hpp
Go to the documentation of this file.
1#ifndef OPENXLSX_XLCONTENTTYPES_HPP
2#define OPENXLSX_XLCONTENTTYPES_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 <cstdint> // uint8_t
12#include <gsl/pointers>
13#include <memory>
14#include <string>
15#include <string_view>
16#include <vector>
17
18// ===== OpenXLSX Includes ===== //
19#include "OpenXLSX-Exports.hpp"
20#include "XLXmlFile.hpp"
21#include "XLXmlParser.hpp"
22
23namespace OpenXLSX
24{
61
68
69 class OPENXLSX_EXPORT XLContentItem
70 {
71 friend class XLContentTypes;
72
73 public: // ---------- Public Member Functions ---------- //
75
76 explicit XLContentItem(const XMLNode& node);
77
78 ~XLContentItem() = default;
79
80 XLContentItem(const XLContentItem& other);
81
82 XLContentItem(XLContentItem&& other) noexcept;
83
84 XLContentItem& operator=(const XLContentItem& other);
85
87
88 XLContentType type() const;
89
90 std::string path() const;
91
92 private:
93 std::unique_ptr<XMLNode> m_contentNode;
94 };
95
96 // XLContentTypes Class
97
101 class OPENXLSX_EXPORT XLContentTypes : public XLXmlFile
102 {
103 public: // ---------- Public Member Functions ---------- //
105
106 explicit XLContentTypes(gsl::not_null<XLXmlData*> xmlData);
107
108 ~XLContentTypes() = default;
109
111
113
115
117
123 bool hasDefault(std::string_view extension) const;
124
130 bool hasOverride(std::string_view path) const;
131
137 void addDefault(std::string_view extension, std::string_view contentType);
138
144 void addOverride(std::string_view path, XLContentType type);
145
151 void updateOverride(std::string_view path, XLContentType type);
152
153 void deleteOverride(std::string_view path);
154
155 void deleteOverride(const XLContentItem& item);
156
161 void deleteDefault(std::string_view extension);
162
163 XLContentItem contentItem(std::string_view path);
164
165 std::vector<XLContentItem> getContentItems();
166
167 private: // ---------- Private Member Variables ---------- //
168 };
169} // namespace OpenXLSX
170
171#ifdef _MSC_VER // conditionally enable MSVC specific pragmas to avoid other compilers warning about unknown pragmas
172# pragma warning(pop)
173#endif // _MSC_VER
174
175#endif // OPENXLSX_XLCONTENTTYPES_HPP
XLXmlData * xmlData
Definition XLDocument.cpp:1422
Definition XLXmlParser.hpp:84
Definition XLContentTypes.hpp:70
XLContentItem(XLContentItem &&other) noexcept
XLContentItem & operator=(XLContentItem &&other) noexcept
The purpose of this class is to load, store add and save item in the [Content_Types]....
Definition XLContentTypes.hpp:102
XLContentTypes & operator=(XLContentTypes &&other) noexcept
XLContentTypes(XLContentTypes &&other) noexcept
XLContentTypes(const XLContentTypes &other)
XLContentTypes & operator=(const XLContentTypes &other)
The XLXmlFile class provides an interface for derived classes to use. It functions as an ancestor to ...
Definition XLXmlFile.hpp:42
Definition IZipArchive.hpp:18
std::string XLContentTypeToString(XLContentType type)
utility function: determine the name of an XLContentType value
XLContentType
Definition XLContentTypes.hpp:28