MCPcopy Create free account
hub / github.com/Tencent/tgfx / parseLengthUnitToken

Method parseLengthUnitToken

src/svg/SVGAttributeParser.cpp:229–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229bool SVGAttributeParser::parseLengthUnitToken(SVGLength::Unit& unit) {
230 struct Unit {
231 Unit(std::string name, SVGLength::Unit u) : unitName(std::move(name)), unit(u) {
232 }
233 std::string unitName;
234 SVGLength::Unit unit;
235 };
236
237 static const std::array<Unit, 9> unitInfo = {
238 Unit("%", SVGLength::Unit::Percentage), Unit("em", SVGLength::Unit::EMS),
239 Unit("ex", SVGLength::Unit::EXS), Unit("px", SVGLength::Unit::PX),
240 Unit("cm", SVGLength::Unit::CM), Unit("mm", SVGLength::Unit::MM),
241 Unit("in", SVGLength::Unit::IN), Unit("pt", SVGLength::Unit::PT),
242 Unit("pc", SVGLength::Unit::PC),
243 };
244
245 return std::any_of(unitInfo.begin(), unitInfo.end(), [&](const Unit& item) {
246 if (this->parseExpectedStringToken(item.unitName.data())) {
247 unit = item.unit;
248 return true;
249 }
250 return false;
251 });
252}
253
254// https://www.w3.org/TR/SVG11/types.html#DataTypeColor
255bool SVGAttributeParser::parseNamedColorToken(Color* c) {

Callers 1

parseMethod · 0.95

Calls 5

UnitClass · 0.70
beginMethod · 0.45
endMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected