OpenXLSX 1.12.1
Modern C++ Excel Library (Fork of OpenXLSX by Kenneth Troldal Balslev)
Loading...
Searching...
No Matches
XLXmlHelpers.hpp File Reference

Layer-2 OOXML DOM idioms built on the frozen XLXmlParser substrate. More...

#include <initializer_list>
#include <string>
#include <string_view>
#include <type_traits>
#include <vector>
#include "XLXmlParser.hpp"

Go to the source code of this file.

Namespaces

namespace  OpenXLSX

Functions

int OpenXLSX::findStringInVector (std::string_view nodeName, std::vector< std::string_view > const &nodeOrder)
 Index of nodeName in nodeOrder, or SORT_INDEX_NOT_FOUND.
void OpenXLSX::copyLeadingWhitespaces (XMLNode &parent, XMLNode fromNode, XMLNode toNode)
 Copy leading pcdata (whitespace) siblings from fromNode before toNode.
XMLNode OpenXLSX::ensureChild (XMLNode &parent, const char *nodeName, std::vector< std::string_view > const &nodeOrder={}, bool force_ns=false)
 Ensure a child element named nodeName exists under parent and return it.
XMLNode OpenXLSX::ensureChild (XMLNode &parent, std::string const &nodeName, std::vector< std::string_view > const &nodeOrder={}, bool force_ns=false)
XMLNode OpenXLSX::ensureChildPath (XMLNode &parent, std::initializer_list< const char * > path)
 Ensure a chain of simple (unordered) child elements exists.
XMLAttribute OpenXLSX::ensureAttr (XMLNode &node, const char *attrName, const char *defaultVal="")
 Ensure attribute exists; write defaultVal only when creating.
XMLAttribute OpenXLSX::ensureAttr (XMLNode &node, std::string const &attrName, std::string const &defaultVal)
XMLAttribute OpenXLSX::setAttr (XMLNode &node, const char *attrName, const char *attrVal)
 Ensure attribute exists and always set its value (string).
XMLAttribute OpenXLSX::setAttr (XMLNode &node, const char *attrName, std::string_view attrVal)
XMLAttribute OpenXLSX::setAttr (XMLNode &node, const char *attrName, std::string const &attrVal)
XMLAttribute OpenXLSX::setAttr (XMLNode &node, std::string const &attrName, std::string const &attrVal)
template<typename T, typename = std::enable_if_t<std::is_arithmetic_v<T>>>
XMLAttribute OpenXLSX::setAttr (XMLNode &node, const char *attrName, T attrVal)
 Ensure attribute exists and set a numeric / bool value via XMLAttribute::set_value overloads.
XMLAttribute OpenXLSX::setAttrBool01 (XMLNode &node, const char *attrName, bool value)
 Excel-style boolean attribute as "1" / "0".
XMLAttribute OpenXLSX::setAttrBoolTF (XMLNode &node, const char *attrName, bool value)
 Boolean attribute as "true" / "false".
XMLAttribute OpenXLSX::ensureChildAttr (XMLNode &parent, const char *nodeName, const char *attrName, const char *attrDefaultVal, std::vector< std::string_view > const &nodeOrder={})
 Ensure child nodeName exists and return its attribute attrName (create with default).
XMLAttribute OpenXLSX::ensureChildAttr (XMLNode &parent, std::string const &nodeName, std::string const &attrName, std::string const &attrDefaultVal, std::vector< std::string_view > const &nodeOrder={})
XMLAttribute OpenXLSX::setChildAttr (XMLNode &parent, const char *nodeName, const char *attrName, const char *attrVal, bool removeAttributes=XLKeepAttributes, std::vector< std::string_view > const &nodeOrder={})
 Ensure child exists, optionally clear its attributes, then set attrName.
XMLAttribute OpenXLSX::setChildAttr (XMLNode &parent, std::string const &nodeName, std::string const &attrName, std::string const &attrVal, bool removeAttributes=XLKeepAttributes, std::vector< std::string_view > const &nodeOrder={})
XMLAttribute OpenXLSX::setVal (XMLNode &node, const char *value)
 Set the @val attribute on node.
XMLAttribute OpenXLSX::setVal (XMLNode &node, std::string_view value)
XMLAttribute OpenXLSX::setChildVal (XMLNode &parent, const char *childName, const char *value, std::vector< std::string_view > const &nodeOrder={})
 Ensure child childName exists under parent and set its @val attribute.
XMLAttribute OpenXLSX::setChildVal (XMLNode &parent, const char *childName, std::string_view value, std::vector< std::string_view > const &nodeOrder={})
XMLNode OpenXLSX::setChildText (XMLNode &parent, const char *childName, std::string_view text, std::vector< std::string_view > const &nodeOrder={})
 Ensure child exists (optional order) and set its text content.
bool OpenXLSX::getBoolAttributeWhenOmittedMeansTrue (XMLNode &parent, const char *tagName, const char *attrName="val")
 Bool tag with omitted @val meaning true (legacy OOXML quirk).
bool OpenXLSX::getBoolAttributeWhenOmittedMeansTrue (XMLNode &parent, std::string const &tagName, std::string const &attrName="val")
XMLNode OpenXLSX::appendAndGetNode (XMLNode &parent, std::string const &nodeName, std::vector< std::string_view > const &nodeOrder={}, bool force_ns=false)
XMLAttribute OpenXLSX::appendAndGetAttribute (XMLNode &node, std::string const &attrName, std::string const &attrDefaultVal)
XMLAttribute OpenXLSX::appendAndSetAttribute (XMLNode &node, std::string const &attrName, std::string const &attrVal)
XMLAttribute OpenXLSX::appendAndGetNodeAttribute (XMLNode &parent, std::string const &nodeName, std::string const &attrName, std::string const &attrDefaultVal, std::vector< std::string_view > const &nodeOrder={})
XMLAttribute OpenXLSX::appendAndSetNodeAttribute (XMLNode &parent, std::string const &nodeName, std::string const &attrName, std::string const &attrVal, bool removeAttributes=XLKeepAttributes, std::vector< std::string_view > const &nodeOrder={})

Variables

constexpr bool OpenXLSX::XLRemoveAttributes = true
constexpr bool OpenXLSX::XLKeepAttributes = false
constexpr int OpenXLSX::SORT_INDEX_NOT_FOUND = -1

Detailed Description

Layer-2 OOXML DOM idioms built on the frozen XLXmlParser substrate.

Design rules:

  • Depends only on XLXmlParser (no Styles / Document / Cell types).
  • Pure inline helpers; no second DOM model.
  • Prefer ensureChild / setAttr names for new code; appendAnd* aliases keep source compat.
  • XLXmlParser surface (child / attribute / append_*) stays stable; add domain semantics here.