diff --git a/source/svgelement.cpp b/source/svgelement.cpp index 942ce97..7d62cc6 100644 --- a/source/svgelement.cpp +++ b/source/svgelement.cpp @@ -10,7 +10,7 @@ namespace lunasvg { -ElementID elementid(const std::string_view& name) +ElementID elementid(std::string_view name) { static const struct { std::string_view name; @@ -129,7 +129,7 @@ SVGElement::SVGElement(Document* document, ElementID id) { } -bool SVGElement::hasAttribute(const std::string_view& name) const +bool SVGElement::hasAttribute(std::string_view name) const { auto id = propertyid(name); if(id == PropertyID::Unknown) @@ -137,7 +137,7 @@ bool SVGElement::hasAttribute(const std::string_view& name) const return hasAttribute(id); } -const std::string& SVGElement::getAttribute(const std::string_view& name) const +const std::string& SVGElement::getAttribute(std::string_view name) const { auto id = propertyid(name); if(id == PropertyID::Unknown) @@ -145,7 +145,7 @@ const std::string& SVGElement::getAttribute(const std::string_view& name) const return getAttribute(id); } -bool SVGElement::setAttribute(const std::string_view& name, const std::string& value) +bool SVGElement::setAttribute(std::string_view name, const std::string& value) { auto id = propertyid(name); if(id == PropertyID::Unknown) @@ -326,7 +326,7 @@ Rect SVGElement::paintBoundingBox() const return m_paintBoundingBox; } -SVGMarkerElement* SVGElement::getMarker(const std::string_view& id) const +SVGMarkerElement* SVGElement::getMarker(std::string_view id) const { auto element = rootElement()->getElementById(id); if(element && element->id() == ElementID::Marker) @@ -334,7 +334,7 @@ SVGMarkerElement* SVGElement::getMarker(const std::string_view& id) const return nullptr; } -SVGClipPathElement* SVGElement::getClipper(const std::string_view& id) const +SVGClipPathElement* SVGElement::getClipper(std::string_view id) const { auto element = rootElement()->getElementById(id); if(element && element->id() == ElementID::ClipPath) @@ -342,7 +342,7 @@ SVGClipPathElement* SVGElement::getClipper(const std::string_view& id) const return nullptr; } -SVGMaskElement* SVGElement::getMasker(const std::string_view& id) const +SVGMaskElement* SVGElement::getMasker(std::string_view id) const { auto element = rootElement()->getElementById(id); if(element && element->id() == ElementID::Mask) @@ -350,7 +350,7 @@ SVGMaskElement* SVGElement::getMasker(const std::string_view& id) const return nullptr; } -SVGPaintElement* SVGElement::getPainter(const std::string_view& id) const +SVGPaintElement* SVGElement::getPainter(std::string_view id) const { auto element = rootElement()->getElementById(id); if(element && element->isPaintElement()) @@ -683,7 +683,7 @@ SVGRootElement* SVGRootElement::layoutIfNeeded() return this; } -SVGElement* SVGRootElement::getElementById(const std::string_view& id) const +SVGElement* SVGRootElement::getElementById(std::string_view id) const { auto it = m_idCache.find(id); if(it == m_idCache.end()) diff --git a/source/svgelement.h b/source/svgelement.h index 7a9c6b1..ff5d008 100644 --- a/source/svgelement.h +++ b/source/svgelement.h @@ -108,7 +108,7 @@ enum class ElementID : uint8_t { Use }; -ElementID elementid(const std::string_view& name); +ElementID elementid(std::string_view name); using SVGNodeList = std::list>; using SVGPropertyList = std::forward_list; @@ -129,9 +129,9 @@ class SVGElement : public SVGNode { SVGElement(Document* document, ElementID id); virtual ~SVGElement() = default; - bool hasAttribute(const std::string_view& name) const; - const std::string& getAttribute(const std::string_view& name) const; - bool setAttribute(const std::string_view& name, const std::string& value); + bool hasAttribute(std::string_view name) const; + const std::string& getAttribute(std::string_view name) const; + bool setAttribute(std::string_view name, const std::string& value); const Attribute* findAttribute(PropertyID id) const; bool hasAttribute(PropertyID id) const; @@ -159,10 +159,10 @@ class SVGElement : public SVGNode { virtual Rect strokeBoundingBox() const; virtual Rect paintBoundingBox() const; - SVGMarkerElement* getMarker(const std::string_view& id) const; - SVGClipPathElement* getClipper(const std::string_view& id) const; - SVGMaskElement* getMasker(const std::string_view& id) const; - SVGPaintElement* getPainter(const std::string_view& id) const; + SVGMarkerElement* getMarker(std::string_view id) const; + SVGClipPathElement* getClipper(std::string_view id) const; + SVGMaskElement* getMasker(std::string_view id) const; + SVGPaintElement* getPainter(std::string_view id) const; SVGElement* elementFromPoint(float x, float y); @@ -346,7 +346,7 @@ class SVGRootElement final : public SVGSVGElement { SVGRootElement* layoutIfNeeded(); - SVGElement* getElementById(const std::string_view& id) const; + SVGElement* getElementById(std::string_view id) const; void addElementById(const std::string& id, SVGElement* element); void layout(SVGLayoutState& state) final; diff --git a/source/svglayoutstate.cpp b/source/svglayoutstate.cpp index 24d583b..bf5b92d 100644 --- a/source/svglayoutstate.cpp +++ b/source/svglayoutstate.cpp @@ -110,7 +110,7 @@ static float parseNumberOrPercentage(std::string_view input, bool allowPercentag return value; } -static Length parseLength(const std::string_view& input, LengthNegativeMode mode, const Length& defaultValue) +static Length parseLength(std::string_view input, LengthNegativeMode mode, const Length& defaultValue) { Length value; if(!value.parse(input, mode)) @@ -118,7 +118,7 @@ static Length parseLength(const std::string_view& input, LengthNegativeMode mode return value; } -static BaselineShift parseBaselineShift(const std::string_view& input) +static BaselineShift parseBaselineShift(std::string_view input) { if(input.compare("baseline") == 0) return BaselineShift::Type::Baseline; @@ -167,7 +167,7 @@ static float parseFontSize(std::string_view input, const SVGLayoutState* state) } template -static Enum parseEnumValue(const std::string_view& input, const SVGEnumerationEntry(&entries)[N], Enum defaultValue) +static Enum parseEnumValue(std::string_view input, const SVGEnumerationEntry(&entries)[N], Enum defaultValue) { for(const auto& entry : entries) { if(input == entry.second) { @@ -178,7 +178,7 @@ static Enum parseEnumValue(const std::string_view& input, const SVGEnumerationEn return defaultValue; } -static Display parseDisplay(const std::string_view& input) +static Display parseDisplay(std::string_view input) { static const SVGEnumerationEntry entries[] = { {Display::Inline, "inline"}, @@ -188,7 +188,7 @@ static Display parseDisplay(const std::string_view& input) return parseEnumValue(input, entries, Display::Inline); } -static Visibility parseVisibility(const std::string_view& input) +static Visibility parseVisibility(std::string_view input) { static const SVGEnumerationEntry entries[] = { {Visibility::Visible, "visible"}, @@ -199,7 +199,7 @@ static Visibility parseVisibility(const std::string_view& input) return parseEnumValue(input, entries, Visibility::Visible); } -static Overflow parseOverflow(const std::string_view& input) +static Overflow parseOverflow(std::string_view input) { static const SVGEnumerationEntry entries[] = { {Overflow::Visible, "visible"}, @@ -209,7 +209,7 @@ static Overflow parseOverflow(const std::string_view& input) return parseEnumValue(input, entries, Overflow::Visible); } -static PointerEvents parsePointerEvents(const std::string_view& input) +static PointerEvents parsePointerEvents(std::string_view input) { static const SVGEnumerationEntry entries[] = { {PointerEvents::None,"none"}, @@ -228,7 +228,7 @@ static PointerEvents parsePointerEvents(const std::string_view& input) return parseEnumValue(input, entries, PointerEvents::Auto); } -static FontWeight parseFontWeight(const std::string_view& input) +static FontWeight parseFontWeight(std::string_view input) { static const SVGEnumerationEntry entries[] = { {FontWeight::Normal, "normal"}, @@ -249,7 +249,7 @@ static FontWeight parseFontWeight(const std::string_view& input) return parseEnumValue(input, entries, FontWeight::Normal); } -static FontStyle parseFontStyle(const std::string_view& input) +static FontStyle parseFontStyle(std::string_view input) { static const SVGEnumerationEntry entries[] = { {FontStyle::Normal, "normal"}, @@ -260,7 +260,7 @@ static FontStyle parseFontStyle(const std::string_view& input) return parseEnumValue(input, entries, FontStyle::Normal); } -static AlignmentBaseline parseAlignmentBaseline(const std::string_view& input) +static AlignmentBaseline parseAlignmentBaseline(std::string_view input) { static const SVGEnumerationEntry entries[] = { {AlignmentBaseline::Auto, "auto"}, @@ -280,7 +280,7 @@ static AlignmentBaseline parseAlignmentBaseline(const std::string_view& input) return parseEnumValue(input, entries, AlignmentBaseline::Auto); } -static DominantBaseline parseDominantBaseline(const std::string_view& input) +static DominantBaseline parseDominantBaseline(std::string_view input) { static const SVGEnumerationEntry entries[] = { {DominantBaseline::Auto, "auto"}, @@ -300,7 +300,7 @@ static DominantBaseline parseDominantBaseline(const std::string_view& input) return parseEnumValue(input, entries, DominantBaseline::Auto); } -static Direction parseDirection(const std::string_view& input) +static Direction parseDirection(std::string_view input) { static const SVGEnumerationEntry entries[] = { {Direction::Ltr, "ltr"}, @@ -310,7 +310,7 @@ static Direction parseDirection(const std::string_view& input) return parseEnumValue(input, entries, Direction::Ltr); } -static WritingMode parseWritingMode(const std::string_view& input) +static WritingMode parseWritingMode(std::string_view input) { static const SVGEnumerationEntry entries[] = { {WritingMode::Horizontal, "horizontal-tb"}, @@ -327,7 +327,7 @@ static WritingMode parseWritingMode(const std::string_view& input) return parseEnumValue(input, entries, WritingMode::Horizontal); } -static TextOrientation parseTextOrientation(const std::string_view& input) +static TextOrientation parseTextOrientation(std::string_view input) { static const SVGEnumerationEntry entries[] = { {TextOrientation::Mixed, "mixed"}, @@ -337,7 +337,7 @@ static TextOrientation parseTextOrientation(const std::string_view& input) return parseEnumValue(input, entries, TextOrientation::Mixed); } -static TextAnchor parseTextAnchor(const std::string_view& input) +static TextAnchor parseTextAnchor(std::string_view input) { static const SVGEnumerationEntry entries[] = { {TextAnchor::Start, "start"}, @@ -348,7 +348,7 @@ static TextAnchor parseTextAnchor(const std::string_view& input) return parseEnumValue(input, entries, TextAnchor::Start); } -static WhiteSpace parseWhiteSpace(const std::string_view& input) +static WhiteSpace parseWhiteSpace(std::string_view input) { static const SVGEnumerationEntry entries[] = { {WhiteSpace::Default, "default"}, @@ -363,7 +363,7 @@ static WhiteSpace parseWhiteSpace(const std::string_view& input) return parseEnumValue(input, entries, WhiteSpace::Default); } -static MaskType parseMaskType(const std::string_view& input) +static MaskType parseMaskType(std::string_view input) { static const SVGEnumerationEntry entries[] = { {MaskType::Luminance, "luminance"}, @@ -373,7 +373,7 @@ static MaskType parseMaskType(const std::string_view& input) return parseEnumValue(input, entries, MaskType::Luminance); } -static FillRule parseFillRule(const std::string_view& input) +static FillRule parseFillRule(std::string_view input) { static const SVGEnumerationEntry entries[] = { {FillRule::NonZero, "nonzero"}, @@ -383,7 +383,7 @@ static FillRule parseFillRule(const std::string_view& input) return parseEnumValue(input, entries, FillRule::NonZero); } -static LineCap parseLineCap(const std::string_view& input) +static LineCap parseLineCap(std::string_view input) { static const SVGEnumerationEntry entries[] = { {LineCap::Butt, "butt"}, @@ -394,7 +394,7 @@ static LineCap parseLineCap(const std::string_view& input) return parseEnumValue(input, entries, LineCap::Butt); } -static LineJoin parseLineJoin(const std::string_view& input) +static LineJoin parseLineJoin(std::string_view input) { static const SVGEnumerationEntry entries[] = { {LineJoin::Miter, "miter"}, diff --git a/source/svgparser.cpp b/source/svgparser.cpp index fa46588..183937c 100644 --- a/source/svgparser.cpp +++ b/source/svgparser.cpp @@ -102,17 +102,17 @@ inline bool operator<(const RuleData& a, const RuleData& b) { return a.isLessTha using RuleDataList = std::vector; -constexpr bool equals(const std::string_view& value, const std::string_view& subvalue) +constexpr bool equals(std::string_view value, std::string_view subvalue) { return value.compare(subvalue) == 0; } -constexpr bool contains(const std::string_view& value, const std::string_view& subvalue) +constexpr bool contains(std::string_view value, std::string_view subvalue) { return value.find(subvalue) != std::string_view::npos; } -constexpr bool includes(const std::string_view& value, const std::string_view& subvalue) +constexpr bool includes(std::string_view value, std::string_view subvalue) { if(subvalue.empty() || subvalue.length() > value.length()) return false; @@ -130,21 +130,21 @@ constexpr bool includes(const std::string_view& value, const std::string_view& s return false; } -constexpr bool startswith(const std::string_view& value, const std::string_view& subvalue) +constexpr bool startswith(std::string_view value, std::string_view subvalue) { if(subvalue.empty() || subvalue.length() > value.length()) return false; return subvalue == value.substr(0, subvalue.size()); } -constexpr bool endswith(const std::string_view& value, const std::string_view& subvalue) +constexpr bool endswith(std::string_view value, std::string_view subvalue) { if(subvalue.empty() || subvalue.length() > value.length()) return false; return subvalue == value.substr(value.size() - subvalue.size(), subvalue.size()); } -constexpr bool dashequals(const std::string_view& value, const std::string_view& subvalue) +constexpr bool dashequals(std::string_view value, std::string_view subvalue) { if(startswith(value, subvalue)) return (value.length() == subvalue.length() || value.at(subvalue.length()) == '-'); @@ -717,7 +717,7 @@ bool Document::parse(const char* data, size_t length) std::string styleSheet; SVGElement* currentElement = nullptr; int ignoring = 0; - auto handleText = [&](const std::string_view& text, bool in_cdata) { + auto handleText = [&](std::string_view text, bool in_cdata) { if(text.empty() || currentElement == nullptr || ignoring > 0) return; if(currentElement->id() != ElementID::Text && currentElement->id() != ElementID::Tspan && currentElement->id() != ElementID::Style) { diff --git a/source/svgparserutils.h b/source/svgparserutils.h index d936a7f..2cf2cf0 100644 --- a/source/svgparserutils.h +++ b/source/svgparserutils.h @@ -78,7 +78,7 @@ constexpr bool skipDelimiter(std::string_view& input, char delimiter) return false; } -constexpr bool skipString(std::string_view& input, const std::string_view& value) +constexpr bool skipString(std::string_view& input, std::string_view value) { if(input.size() >= value.size() && value == input.substr(0, value.size())) { input.remove_prefix(value.size()); diff --git a/source/svgproperty.cpp b/source/svgproperty.cpp index e9b6ea6..51c7ecc 100644 --- a/source/svgproperty.cpp +++ b/source/svgproperty.cpp @@ -6,7 +6,7 @@ namespace lunasvg { -PropertyID propertyid(const std::string_view& name) +PropertyID propertyid(std::string_view name) { static const struct { std::string_view name; @@ -67,7 +67,7 @@ PropertyID propertyid(const std::string_view& name) return it->value; } -PropertyID csspropertyid(const std::string_view& name) +PropertyID csspropertyid(std::string_view name) { static const struct { std::string_view name; diff --git a/source/svgproperty.h b/source/svgproperty.h index 59ee12d..74a23a8 100644 --- a/source/svgproperty.h +++ b/source/svgproperty.h @@ -96,8 +96,8 @@ enum class PropertyID : uint8_t { Y2 }; -PropertyID propertyid(const std::string_view& name); -PropertyID csspropertyid(const std::string_view& name); +PropertyID propertyid(std::string_view name); +PropertyID csspropertyid(std::string_view name); class SVGElement;