11#ifndef OPENXLSX_XLSTYLES_INTERNAL_HPP
12#define OPENXLSX_XLSTYLES_INTERNAL_HPP
18#include <fmt/format.h>
29 if (not source.
empty()) {
49 fp.append(attr.name());
51 fp.append(attr.value());
56 if (child.type() == pugi::node_pcdata) {
57 std::string_view v(child.value());
59 bool isWhitespace = std::all_of(v.begin(), v.end(), [](
char c) { return std::isspace(static_cast<unsigned char>(c)); });
60 if (isWhitespace)
continue;
67 fp.append(child.name());
90 template<
typename E,
size_t N>
93 for (
const auto& kv : mapping) {
94 if (kv.str == str)
return kv.val;
99 template<
typename E,
size_t N>
102 for (
const auto& kv : mapping) {
103 if (kv.val == val)
return kv.str.data();
111 inline std::string
formatDoubleAsString(
double val,
int decimalPlaces = 2) {
return fmt::format(
"{:.{}f}", val, decimalPlaces); }
118 if (max <= min or absTolerance < 0.0)
119 throw XLException(
"checkAndFormatDoubleAsString: max must be greater than min and absTolerance must be >= 0.0");
120 if (val < min - absTolerance or val > max + absTolerance)
return "";
XMLAttribute first_attribute() const
Definition XLXmlParser.cpp:102
XMLNode first_child() const
Definition XLXmlParser.cpp:192
XMLNode next_sibling(const char *name_) const
Definition XLXmlParser.cpp:156
bool empty() const
Definition XLXmlParser.cpp:58
XMLNode append_copy(const XMLNode &node)
Definition XLXmlParser.cpp:427
Definition XLException.hpp:33
Definition XLXmlParser.hpp:283
bool empty() const
Definition XLXmlParser.cpp:513
XMLAttribute next_attribute() const
Definition XLXmlParser.cpp:635
Definition IXLCellProvider.hpp:24
std::string formatDoubleAsString(double val, int decimalPlaces=2)
Format val as a string with decimalPlaces.
Definition XLStyles_Internal.hpp:111
std::string xmlNodeFingerprint(const XMLNode &node)
Definition XLStyles_Internal.hpp:75
void copyXMLNode(XMLNode &destination, const XMLNode &source)
Definition XLStyles_Internal.hpp:27
constexpr E EnumFromString(std::string_view str, const EnumStringMap< E >(&mapping)[N], E invalidVal)
Definition XLStyles_Internal.hpp:91
void xmlNodeFingerprintImpl(const XMLNode &node, std::string &fp)
Compute a canonical, deterministic string fingerprint of a pugixml subtree.
Definition XLStyles_Internal.hpp:45
std::string checkAndFormatDoubleAsString(double val, double min, double max, double absTolerance, int decimalPlaces=2)
Check that a double value is within range, and format it as a string with decimalPlaces.
Definition XLStyles_Internal.hpp:116
OpenXLSX_xml_node XMLNode
Definition XLXmlParser.hpp:64
constexpr const char * EnumToString(E val, const EnumStringMap< E >(&mapping)[N], const char *invalidStr)
Definition XLStyles_Internal.hpp:100
Definition XLStyles_Internal.hpp:85
std::string_view str
Definition XLStyles_Internal.hpp:86
E val
Definition XLStyles_Internal.hpp:87