1#ifndef OPENXLSX_XLSTYLES_INTERNAL_HPP
2#define OPENXLSX_XLSTYLES_INTERNAL_HPP
19 if (not source.empty()) {
21 for (
XMLNode child = source.first_child(); not child.empty(); child = child.next_sibling()) destination.append_copy(child);
23 for (
XMLAttribute attr = source.first_attribute(); not attr.empty(); attr = attr.next_attribute())
24 destination.append_copy(attr);
39 for (
XMLAttribute attr = node.first_attribute(); attr; attr = attr.next_attribute())
40 fp += attr.
name() + std::string(
"=") + attr.value() +
';';
42 for (
XMLNode child = node.first_child(); child; child = child.next_sibling()) {
43 if (child.type() == pugi::node_pcdata) {
44 std::string_view v(child.value());
46 bool isWhitespace = std::all_of(v.begin(), v.end(), [](
char c) { return std::isspace(static_cast<unsigned char>(c)); });
47 if (isWhitespace)
continue;
48 fp +=
'[' + std::string(child.value()) +
']';
64 template<
typename E,
size_t N>
67 for (
const auto& kv : mapping) {
68 if (kv.str == str)
return kv.val;
73 template<
typename E,
size_t N>
76 for (
const auto& kv : mapping) {
77 if (kv.val == val)
return kv.str.data();
85 inline std::string
formatDoubleAsString(
double val,
int decimalPlaces = 2) {
return fmt::format(
"{:.{}f}", val, decimalPlaces); }
92 if (max <= min or absTolerance < 0.0)
93 throw XLException(
"checkAndFormatDoubleAsString: max must be greater than min and absTolerance must be >= 0.0");
94 if (val < min - absTolerance or val > max + absTolerance)
return "";
Definition XLXmlParser.hpp:84
const pugi::char_t * name() const
get node name while stripping namespace, if so configured (name_begin > 0)
Definition XLXmlParser.hpp:135
Definition XLException.hpp:23
Definition IZipArchive.hpp:18
std::string formatDoubleAsString(double val, int decimalPlaces=2)
Format val as a string with decimalPlaces.
Definition XLStyles_Internal.hpp:85
std::string xmlNodeFingerprint(const XMLNode &node)
Compute a canonical, deterministic string fingerprint of a pugixml subtree.
Definition XLStyles_Internal.hpp:35
void copyXMLNode(XMLNode &destination, const XMLNode &source)
Definition XLStyles_Internal.hpp:17
constexpr E EnumFromString(std::string_view str, const EnumStringMap< E >(&mapping)[N], E invalidVal)
Definition XLStyles_Internal.hpp:65
pugi::xml_attribute XMLAttribute
Definition XLXmlParser.hpp:64
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:90
constexpr const char * EnumToString(E val, const EnumStringMap< E >(&mapping)[N], const char *invalidStr)
Definition XLStyles_Internal.hpp:74
Definition XLStyles_Internal.hpp:59
std::string_view str
Definition XLStyles_Internal.hpp:60
E val
Definition XLStyles_Internal.hpp:61