OpenXLSX 1.9.1
Loading...
Searching...
No Matches
OpenXLSX::XLXmlFile Class Reference

The XLXmlFile class provides an interface for derived classes to use. It functions as an ancestor to all classes which are represented by an .xml file in an .xlsx package. More...

#include <XLXmlFile.hpp>

Inheritance diagram for OpenXLSX::XLXmlFile:
OpenXLSX::XLSheetBase< XLChartsheet > OpenXLSX::XLSheetBase< XLWorksheet > OpenXLSX::XLAppProperties OpenXLSX::XLChart OpenXLSX::XLComments OpenXLSX::XLContentTypes OpenXLSX::XLCustomProperties OpenXLSX::XLDrawing OpenXLSX::XLPersons OpenXLSX::XLPivotCacheDefinition OpenXLSX::XLPivotCacheRecords OpenXLSX::XLPivotTable OpenXLSX::XLProperties OpenXLSX::XLRelationships OpenXLSX::XLSharedStrings OpenXLSX::XLSheet OpenXLSX::XLSheetBase< T, typename > OpenXLSX::XLStyles OpenXLSX::XLTable OpenXLSX::XLThreadedComments OpenXLSX::XLVmlDrawing OpenXLSX::XLWorkbook

Public Member Functions

 XLXmlFile ()=default
 Default constructor.
 
std::string xmlData (XLXmlSavingDeclaration savingDeclaration=XLXmlSavingDeclaration{}) const
 Method for getting the XML data represented by the object.
 
 XLXmlFile (XLXmlData *xmlData)
 Constructor. Creates an object based on the xmlData input.
 
 XLXmlFile (const XLXmlFile &other)=default
 Copy constructor. Default implementation used.
 
 XLXmlFile (XLXmlFile &&other) noexcept=default
 Move constructor. Default implementation used.
 
 ~XLXmlFile ()=default
 Destructor. Default implementation used.
 
bool valid () const
 check whether class is linked to a valid XML file
 
XLXmlFileoperator= (const XLXmlFile &other)=default
 The copy assignment operator. The default implementation has been used.
 
XLXmlFileoperator= (XLXmlFile &&other) noexcept=default
 The move assignment operator. The default implementation has been used.
 
XLDocumentparentDoc ()
 This function provides access to the parent XLDocument object.
 
const XLDocumentparentDoc () const
 This function provides access to the parent XLDocument object.
 
XMLDocumentxmlDocument ()
 This function provides access to the underlying XMLDocument object.
 
const XMLDocumentxmlDocument () const
 This function provides access to the underlying XMLDocument object.
 
std::string getXmlPath () const
 Retrieve the path of the XML data in the .xlsx zip archive via m_xmlData->getXmlPath.
 

Protected Member Functions

void setXmlData (std::string_view xmlData)
 Provide the XML data represented by the object.
 
std::string relationshipID () const
 This function returns the relationship ID (the ID used in the XLRelationships objects) for the object.
 

Protected Attributes

XLXmlDatam_xmlData {nullptr}
 

Detailed Description

The XLXmlFile class provides an interface for derived classes to use. It functions as an ancestor to all classes which are represented by an .xml file in an .xlsx package.

Warning
The XLXmlFile class is not intended to be instantiated on it's own, but to provide an interface for derived classes. Also, it should not be used polymorphically. For that reason, the destructor is not declared virtual.

Constructor & Destructor Documentation

◆ XLXmlFile() [1/4]

OpenXLSX::XLXmlFile::XLXmlFile ( )
default

Default constructor.

◆ XLXmlFile() [2/4]

XLXmlFile::XLXmlFile ( XLXmlData xmlData)
explicit

Constructor. Creates an object based on the xmlData input.

Parameters
xmlDataAn XLXmlData object with the XML data to be represented by the object.

The constructor creates a new object with the parent XLDocument and the file path as input, with an optional input being a std::string with the XML data. If the XML data is provided by a string, any file with the same path in the .zip file will be overwritten upon saving of the document. If no xmlData is provided, the data will be read from the .zip file, using the given path.

◆ XLXmlFile() [3/4]

OpenXLSX::XLXmlFile::XLXmlFile ( const XLXmlFile other)
default

Copy constructor. Default implementation used.

Parameters
otherThe object to copy.

◆ XLXmlFile() [4/4]

OpenXLSX::XLXmlFile::XLXmlFile ( XLXmlFile &&  other)
defaultnoexcept

Move constructor. Default implementation used.

Parameters
otherThe object to move.

◆ ~XLXmlFile()

OpenXLSX::XLXmlFile::~XLXmlFile ( )
default

Destructor. Default implementation used.

Member Function Documentation

◆ getXmlPath()

std::string XLXmlFile::getXmlPath ( ) const

Retrieve the path of the XML data in the .xlsx zip archive via m_xmlData->getXmlPath.

Returns
A std::string with the path. Empty string if m_xmlData is nullptr

provide access to the underlying XLXmlData::getXmlPath() function

◆ operator=() [1/2]

XLXmlFile & OpenXLSX::XLXmlFile::operator= ( const XLXmlFile other)
default

The copy assignment operator. The default implementation has been used.

Parameters
otherThe object to copy.
Returns
A reference to the new object.

◆ operator=() [2/2]

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

The move assignment operator. The default implementation has been used.

Parameters
otherThe object to move.
Returns
A reference to the new object.

◆ parentDoc() [1/2]

XLDocument & XLXmlFile::parentDoc ( )

This function provides access to the parent XLDocument object.

Returns
A reference to the parent XLDocument object.

◆ parentDoc() [2/2]

const XLDocument & XLXmlFile::parentDoc ( ) const

This function provides access to the parent XLDocument object.

Returns
A const reference to the parent XLDocument object.

◆ relationshipID()

std::string XLXmlFile::relationshipID ( ) const
protected

This function returns the relationship ID (the ID used in the XLRelationships objects) for the object.

Returns
A std::string with the ID. Not all spreadsheet objects may have a relationship ID. In those cases an empty string is returned.

◆ setXmlData()

void XLXmlFile::setXmlData ( std::string_view  xmlData)
protected

Provide the XML data represented by the object.

Parameters
xmlDataA std::string_view with the XML data.

This method sets the XML data with a std::string as input. The underlying XMLDocument reads the data. When envoking the load_string method in PugiXML, the flag 'parse_ws_pcdata' is passed along with the default flags. This will enable parsing of whitespace characters. If not set, Excel cells with only spaces will be returned as empty strings, which is not what we want. The downside is that whitespace characters such as \n and \t in the input xml file may mess up the parsing.

◆ valid()

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

check whether class is linked to a valid XML file

Returns
true if the class should have a link to valid data
false if accessing any other sheet properties / methods could cause a segmentation fault
Note
for example, if an XLSheet is created with a default constructor, XLSheetBase::valid() (derived from XLXmlFile) would return false

◆ xmlData()

std::string XLXmlFile::xmlData ( XLXmlSavingDeclaration  savingDeclaration = XLXmlSavingDeclaration{}) const

Method for getting the XML data represented by the object.

Parameters
savingDeclaration@optional specify an XML saving declaration to use
Returns
A std::string with the XML data.

This method retrieves the underlying XML data as a std::string.

◆ xmlDocument() [1/2]

XMLDocument & XLXmlFile::xmlDocument ( )

This function provides access to the underlying XMLDocument object.

Returns
A reference to the XMLDocument object.

This method returns a pointer to the underlying XMLDocument resource.

◆ xmlDocument() [2/2]

const XMLDocument & XLXmlFile::xmlDocument ( ) const

This function provides access to the underlying XMLDocument object.

Returns
A const reference to the XMLDocument object.

This method returns a pointer to the underlying XMLDocument resource as const.

Field Documentation

◆ m_xmlData

XLXmlData* OpenXLSX::XLXmlFile::m_xmlData {nullptr}
protected

The underlying XML data object.


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