OpenXLSX 1.12.1
Modern C++ Excel Library (Fork of OpenXLSX by Kenneth Troldal Balslev)
Loading...
Searching...
No Matches
OpenXLSX::XLRelationships Class Reference

#include <XLRelationships.hpp>

Inheritance diagram for OpenXLSX::XLRelationships:
OpenXLSX::XLXmlFile

Public Member Functions

 XLRelationships ()=default
 XLRelationships (gsl::not_null< XLXmlData * > xmlData, std::string pathTo)
 ~XLRelationships ()
 XLRelationships (const XLRelationships &other)=default
 XLRelationships (XLRelationships &&other) noexcept=default
XLRelationships & operator= (const XLRelationships &other)=default
XLRelationships & operator= (XLRelationships &&other) noexcept=default
XLRelationshipItem relationshipById (std::string_view id) const
XLRelationshipItem relationshipByTarget (std::string_view target, bool throwIfNotFound=true) const
std::vector< XLRelationshipItem > relationships () const
void deleteRelationship (std::string_view relID)
void deleteRelationship (const XLRelationshipItem &item)
XLRelationshipItem addRelationship (XLRelationshipType type, std::string_view target, bool isExternal=false)
 Create and append a new relationship.
bool targetExists (std::string_view target) const
bool idExists (std::string_view id) const
void print (std::basic_ostream< char > &ostr) const
 Serialize the underlying XML to a stream.
Public Member Functions inherited from OpenXLSX::XLXmlFile
 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
XLXmlFile & operator= (const XLXmlFile &other)=default
 The copy assignment operator. The default implementation has been used.
XLXmlFile & operator= (XLXmlFile &&other) noexcept=default
 The move assignment operator. The default implementation has been used.
XLDocument & parentDoc ()
 This function provides access to the parent XLDocument object.
const XLDocument & parentDoc () const
 This function provides access to the parent XLDocument object.
XLPackageServices & package ()
 Narrow package-services port (archive, managed XML parts, relationships, content types).
const XLPackageServices & package () const
XLPackagePartFactory & partFactory ()
 Narrow package-part factory port (chart / drawing / image / slicer / sheet accessories).
const XLPackagePartFactory & partFactory () const
const XLSharedStringTable & sharedStringTable () const
 Read-only shared string table (SST) port.
const XLSharedStrings & sharedStrings () const
 Full workbook SST (including getOrCreate / append).
XMLDocument & xmlDocument ()
 This function provides access to the underlying XMLDocument object.
const XMLDocument & xmlDocument () 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.
const XLXmlData * xmlDataPart () const noexcept
 Access the underlying XLXmlData pointer.
XLXmlData * xmlDataPart () noexcept

Additional Inherited Members

Protected Member Functions inherited from OpenXLSX::XLXmlFile
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 inherited from OpenXLSX::XLXmlFile
XLXmlData * m_xmlData {nullptr}

Constructor & Destructor Documentation

◆ XLRelationships() [1/4]

OpenXLSX::XLRelationships::XLRelationships ( )
default

◆ XLRelationships() [2/4]

XLRelationships::XLRelationships ( gsl::not_null< XLXmlData * > xmlData,
std::string pathTo )
explicit
Parameters
xmlDataManaged XML data source.
pathToPath to the .rels file, used to resolve relative targets to absolute paths.

Creates a XLRelationships object. The pathTo will be verified and stored to resolve relationship targets as absolute paths within the XLSX archive.

◆ ~XLRelationships()

XLRelationships::~XLRelationships ( )
default

◆ XLRelationships() [3/4]

OpenXLSX::XLRelationships::XLRelationships ( const XLRelationships & other)
default

◆ XLRelationships() [4/4]

OpenXLSX::XLRelationships::XLRelationships ( XLRelationships && other)
defaultnoexcept

Member Function Documentation

◆ addRelationship()

XLRelationshipItem XLRelationships::addRelationship ( XLRelationshipType type,
std::string_view target,
bool isExternal = false )

Create and append a new relationship.

Parameters
isExternalMarking as 'External' prevents path normalization issues for URIs.

Adds a new relationship. Handles whitespace preservation to maintain consistent XML formatting.

◆ deleteRelationship() [1/2]

void XLRelationships::deleteRelationship ( const XLRelationshipItem & item)

◆ deleteRelationship() [2/2]

void XLRelationships::deleteRelationship ( std::string_view relID)

◆ idExists()

bool XLRelationships::idExists ( std::string_view id) const
nodiscard

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ print()

void XLRelationships::print ( std::basic_ostream< char > & ostr) const

Serialize the underlying XML to a stream.

Print the underlying XML using pugixml::xml_node::print

◆ relationshipById()

XLRelationshipItem XLRelationships::relationshipById ( std::string_view id) const
nodiscard

◆ relationshipByTarget()

XLRelationshipItem XLRelationships::relationshipByTarget ( std::string_view target,
bool throwIfNotFound = true ) const
nodiscard
Parameters
targetThe Target path to look up.
throwIfNotFoundIf false, returns an empty XLRelationshipItem on failure.

Returns the XLRelationshipItem with the requested target. Performance: Normalizes paths before comparison to ensure consistency between relative and absolute references.

◆ relationships()

std::vector< XLRelationshipItem > XLRelationships::relationships ( ) const
nodiscard

◆ targetExists()

bool XLRelationships::targetExists ( std::string_view target) const
nodiscard

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