8 #ifndef SkSVGAttributeParser_DEFINED
9 #define SkSVGAttributeParser_DEFINED
13 #include "include/private/base/SkNoncopyable.h"
15 #include "src/base/SkTLazy.h"
35 result.set(std::move(parsedValue));
44 if (!strcmp(name, expectedName)) {
45 return parse<T>(value);
51 template <
typename PropertyT>
55 if (strcmp(name, expectedName) != 0) {
59 if (!strcmp(value,
"inherit")) {
64 auto pr = parse<typename PropertyT::ValueT>(value);
66 PropertyT result(*pr);
77 : fSelf(self), fCurPos(self->fCurPos) {}
81 fSelf->fCurPos = this->fCurPos;
85 void clear() { fSelf =
nullptr; }
90 RestoreCurPos(
const RestoreCurPos&) =
delete;
91 RestoreCurPos& operator=(
const RestoreCurPos&) =
delete;
95 void*
operator new(size_t) =
delete;
96 void*
operator new(size_t,
void*) =
delete;
101 template <
typename F>
102 bool advanceWhile(F func);
104 bool matchStringToken(
const char* token,
const char** newPos =
nullptr)
const;
105 bool matchHexToken(
const char** newPos)
const;
108 bool parseEOSToken();
109 bool parseSepToken();
110 bool parseCommaWspToken();
111 bool parseExpectedStringToken(
const char*);
113 bool parseInt32Token(int32_t*);
117 bool parseNamedColorToken(
SkColor*);
118 bool parseHexColorToken(
SkColor*);
119 bool parseColorComponentScalarToken(int32_t*);
120 bool parseColorComponentIntegralToken(int32_t*);
121 bool parseColorComponentFractionalToken(int32_t*);
122 bool parseColorComponentToken(int32_t*);
123 bool parseColorToken(
SkColor*);
124 bool parseRGBColorToken(
SkColor*);
125 bool parseRGBAColorToken(
SkColor*);
132 bool parseTranslateToken(
SkMatrix*);
140 template <
typename Func,
typename T>
141 bool parseParenthesized(
const char* prefix, Func, T* result);
143 template <
typename T>
144 bool parseList(std::vector<T>*);
146 template <
typename T,
typename TArray>
147 bool parseEnumMap(
const TArray& arr, T* result) {
148 for (
size_t i = 0; i < std::size(arr); ++i) {
149 if (this->parseExpectedStringToken(std::get<0>(arr[i]))) {
150 *result = std::get<1>(arr[i]);
161 using INHERITED = SkNoncopyable;
uint32_t SkColor
32-bit ARGB color value, unpremultiplied.
Definition: SkColor.h:37
SkColor SkSVGColorType
Definition: SkSVGTypes.h:25
int SkSVGIntegerType
Definition: SkSVGTypes.h:26
float SkScalar
Definition: SkScalar.h:14
int32_t SkUnichar
32 bit integer to hold a unicode value
Definition: SkTypes.h:167
SkMatrix holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:53
Definition: SkSVGAttributeParser.h:17
bool parsePreserveAspectRatio(SkSVGPreserveAspectRatio *)
static ParseResult< T > parse(const char *value)
Definition: SkSVGAttributeParser.h:31
SkTLazy< T > ParseResult
Definition: SkSVGAttributeParser.h:29
bool parseInteger(SkSVGIntegerType *)
bool parseViewBox(SkSVGViewBoxType *)
static ParseResult< PropertyT > parseProperty(const char *expectedName, const char *name, const char *value)
Definition: SkSVGAttributeParser.h:52
static ParseResult< T > parse(const char *expectedName, const char *name, const char *value)
Definition: SkSVGAttributeParser.h:41
SkSVGAttributeParser(const char[])
bool parse(SkSVGIntegerType *v)
Definition: SkSVGAttributeParser.h:27
Definition: SkSVGTypes.h:177
std::vector< SkString > Vars
Definition: SkSVGTypes.h:184
Definition: SkSVGTypes.h:264
Unit
Definition: SkSVGTypes.h:118
Light weight class for managing strings.
Definition: SkString.h:118
SkRect holds four float coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:582
Definition: SkSVGTypes.h:585