OpenXLSX 1.9.1
Loading...
Searching...
No Matches
OpenXLSX::XLXmlData Class Referencefinal

The XLXmlData class encapsulates the properties and behaviour of the .xml files in an .xlsx file zip package. Objects of the XLXmlData type are intended to be stored centrally in an XLDocument object, from where they can be retrieved by other objects that encapsulates the behaviour of Excel elements, such as XLWorkbook and XLWorksheet. More...

#include <XLXmlData.hpp>

Public Member Functions

 XLXmlData ()=default
 Default constructor. All member variables are default constructed. Except for the raw XML data, none of the member variables can be modified after construction. Hence, objects created using the default constructor can only serve as null objects and targets for the move assignemnt operator.
 
 XLXmlData (XLDocument *parentDoc, const std::string &xmlPath, const std::string &xmlId="", XLContentType xmlType=XLContentType::Unknown)
 Constructor. This constructor creates objects with the given parameters. the xmlId and the xmlType parameters have default values. These are only useful for relationship (.rels) files and the [Content_Types].xml file located in the root directory of the zip package.
 
 ~XLXmlData ()
 Default destructor. The XLXmlData does not manage any dynamically allocated resources, so a default destructor will suffice.
 
bool valid () const
 check whether class is linked to a valid XML document
 
 XLXmlData (const XLXmlData &other)=delete
 Copy constructor. The m_xmlDoc data member is a XMLDocument object, which is non-copyable. Hence, the XLXmlData objects have a explicitly deleted copy constructor.
 
 XLXmlData (XLXmlData &&other) noexcept=default
 Move constructor. All data members are trivially movable. Hence an explicitly defaulted move constructor is sufficient.
 
XLXmlDataoperator= (const XLXmlData &other)=delete
 Copy assignment operator. The m_xmlDoc data member is a XMLDocument object, which is non-copyable. Hence, the XLXmlData objects have a explicitly deleted copy assignment operator.
 
XLXmlDataoperator= (XLXmlData &&other) noexcept=default
 Move assignment operator. All data members are trivially movable. Hence an explicitly defaulted move constructor is sufficient.
 
void setRawData (const std::string &data)
 Set the raw data for the underlying XML document. Being able to set the XML data directly is useful when creating a new file using a XML file template. E.g., when creating a new worksheet, the XML code for a minimum viable XLWorksheet object can be added using this function.
 
std::string getRawData (XLXmlSavingDeclaration savingDeclaration=XLXmlSavingDeclaration{}) const
 Get the raw data for the underlying XML document. This function will retrieve the raw XML text data from the underlying XMLDocument object. This will mainly be used when saving data to the .xlsx package using the save function in the XLDocument class.
 
XLDocumentgetParentDoc ()
 Access the parent XLDocument object.
 
const XLDocumentgetParentDoc () const
 Access the parent XLDocument object.
 
std::string getXmlPath () const
 Retrieve the path of the XML data in the .xlsx zip archive.
 
std::string getXmlID () const
 Retrieve the relationship ID of the XML file.
 
XLContentType getXmlType () const
 Retrieve the type represented by the XML data.
 
XMLDocumentgetXmlDocument ()
 Access the underlying XMLDocument object.
 
const XMLDocumentgetXmlDocument () const
 Access the underlying XMLDocument object.
 
bool empty () const
 Test whether there is an XML file linked to this object.
 

Data Fields

bool m_isStreamed {false}
 
std::string m_streamFilePath
 

Detailed Description

The XLXmlData class encapsulates the properties and behaviour of the .xml files in an .xlsx file zip package. Objects of the XLXmlData type are intended to be stored centrally in an XLDocument object, from where they can be retrieved by other objects that encapsulates the behaviour of Excel elements, such as XLWorkbook and XLWorksheet.

Constructor & Destructor Documentation

◆ XLXmlData() [1/4]

OpenXLSX::XLXmlData::XLXmlData ( )
default

Default constructor. All member variables are default constructed. Except for the raw XML data, none of the member variables can be modified after construction. Hence, objects created using the default constructor can only serve as null objects and targets for the move assignemnt operator.

◆ XLXmlData() [2/4]

XLXmlData::XLXmlData ( XLDocument parentDoc,
const std::string &  xmlPath,
const std::string &  xmlId = "",
XLContentType  xmlType = XLContentType::Unknown 
)

Constructor. This constructor creates objects with the given parameters. the xmlId and the xmlType parameters have default values. These are only useful for relationship (.rels) files and the [Content_Types].xml file located in the root directory of the zip package.

Parameters
parentDocA pointer to the parent XLDocument object.
xmlPathA std::string with the file path in zip package.
xmlIdA std::string with the relationship ID of the file (used in the XLRelationships class)
xmlTypeThe type of object the XML file represents, e.g. XLWorkbook or XLWorksheet.

◆ ~XLXmlData()

XLXmlData::~XLXmlData ( )
default

Default destructor. The XLXmlData does not manage any dynamically allocated resources, so a default destructor will suffice.

◆ XLXmlData() [3/4]

OpenXLSX::XLXmlData::XLXmlData ( const XLXmlData other)
delete

Copy constructor. The m_xmlDoc data member is a XMLDocument object, which is non-copyable. Hence, the XLXmlData objects have a explicitly deleted copy constructor.

Parameters
other

◆ XLXmlData() [4/4]

OpenXLSX::XLXmlData::XLXmlData ( XLXmlData &&  other)
defaultnoexcept

Move constructor. All data members are trivially movable. Hence an explicitly defaulted move constructor is sufficient.

Parameters
other

Member Function Documentation

◆ empty()

bool OpenXLSX::XLXmlData::empty ( ) const

Test whether there is an XML file linked to this object.

Returns
true if there is no underlying XML file, otherwise false

◆ getParentDoc() [1/2]

XLDocument * XLXmlData::getParentDoc ( )

Access the parent XLDocument object.

Returns
A pointer to the parent XLDocument object.

◆ getParentDoc() [2/2]

const XLDocument * XLXmlData::getParentDoc ( ) const

Access the parent XLDocument object.

Returns
A const pointer to the parent XLDocument object.

◆ getRawData()

std::string XLXmlData::getRawData ( XLXmlSavingDeclaration  savingDeclaration = XLXmlSavingDeclaration{}) const

Get the raw data for the underlying XML document. This function will retrieve the raw XML text data from the underlying XMLDocument object. This will mainly be used when saving data to the .xlsx package using the save function in the XLDocument class.

Parameters
savingDeclaration@optional specify an XML saving declaration to use
Returns
A std::string with the raw XML text data.
Note
Default encoding for pugixml xml_document::save is pugi::encoding_auto, becomes pugi::encoding_utf8

◆ getXmlDocument() [1/2]

XMLDocument * XLXmlData::getXmlDocument ( )

Access the underlying XMLDocument object.

Returns
A pointer to the XMLDocument object.

◆ getXmlDocument() [2/2]

const XMLDocument * XLXmlData::getXmlDocument ( ) const

Access the underlying XMLDocument object.

Returns
A const pointer to the XMLDocument object.

◆ getXmlID()

std::string XLXmlData::getXmlID ( ) const

Retrieve the relationship ID of the XML file.

Returns
A std::string with the relationship ID.

◆ getXmlPath()

std::string XLXmlData::getXmlPath ( ) const

Retrieve the path of the XML data in the .xlsx zip archive.

Returns
A std::string with the path.

◆ getXmlType()

XLContentType XLXmlData::getXmlType ( ) const

Retrieve the type represented by the XML data.

Returns
A XLContentType getValue representing the type.

◆ operator=() [1/2]

XLXmlData & OpenXLSX::XLXmlData::operator= ( const XLXmlData other)
delete

Copy assignment operator. The m_xmlDoc data member is a XMLDocument object, which is non-copyable. Hence, the XLXmlData objects have a explicitly deleted copy assignment operator.

◆ operator=() [2/2]

XLXmlData & OpenXLSX::XLXmlData::operator= ( XLXmlData &&  other)
defaultnoexcept

Move assignment operator. All data members are trivially movable. Hence an explicitly defaulted move constructor is sufficient.

Parameters
otherthe XLXmlData object to be moved from.
Returns
A reference to the moved-to object.

◆ setRawData()

void XLXmlData::setRawData ( const std::string &  data)

Set the raw data for the underlying XML document. Being able to set the XML data directly is useful when creating a new file using a XML file template. E.g., when creating a new worksheet, the XML code for a minimum viable XLWorksheet object can be added using this function.

Parameters
dataA std::string with the raw XML text.

◆ valid()

bool OpenXLSX::XLXmlData::valid ( ) const
inline

check whether class is linked to a valid XML document

Returns
true if the class should have a link to valid data
false if accessing any other properties / methods could cause a segmentation fault

Field Documentation

◆ m_isStreamed

bool OpenXLSX::XLXmlData::m_isStreamed {false}

◆ m_streamFilePath

std::string OpenXLSX::XLXmlData::m_streamFilePath

The documentation for this class was generated from the following files: