MCPcopy Create free account
hub / github.com/Snapchat/Valdi / parsePercent

Method parsePercent

valdi/src/valdi/runtime/Attributes/ValueConverters.cpp:107–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107std::optional<PercentValue> ValueConverter::parsePercent(AttributeParser& parser) {
108 auto d = parser.parseDimension();
109 if (!d) {
110 return std::nullopt;
111 }
112
113 if (d.value().unit == Dimension::Unit::Percent) {
114 return PercentValue(d.value().value, true);
115 } else {
116 return PercentValue(d.value().value, false);
117 }
118}
119
120Result<PercentValue> ValueConverter::toPercent(const Value& value) {
121 if (value.isNumber()) {

Callers

nothing calls this directly

Calls 3

PercentValueClass · 0.85
parseDimensionMethod · 0.80
valueMethod · 0.65

Tested by

no test coverage detected