template the parser

This commit is contained in:
Konstantin Käfer
2014-06-16 17:00:25 +02:00
parent e3b9e9abf6
commit 3cd1b8f07c
2 changed files with 59 additions and 90 deletions

View File

@@ -41,21 +41,20 @@ private:
PropertyFilterExpression parseFilterOrExpression(JSVal value);
bool parseBoolean(JSVal value);
std::string parseString(JSVal value);
JSVal replaceConstant(JSVal value);
Color parseColor(JSVal value);
Value parseValue(JSVal value);
FunctionProperty::fn parseFunctionType(JSVal type);
FunctionProperty parseFunction(JSVal value);
template <typename T>
T parse(JSVal value);
template <typename T>
inline void parse(const char *property_name, ClassPropertyKey key, ClassProperties &klass, JSVal value) {
if (value.HasMember(property_name)) {
klass.emplace(key, parse<T>(value[property_name]));
}
}
void parseTransition(const char *property_name, ClassPropertyKey key, ClassProperties &klass, JSVal value);
void parseColor(const char *property_name, ClassPropertyKey key, ClassProperties &klass, JSVal value);
void parseFunction(const char *property_name, ClassPropertyKey key, ClassProperties &klass, JSVal value);
void parseString(const char *property_name, ClassPropertyKey key, ClassProperties &klass, JSVal value);
void parseBoolean(const char *property_name, ClassPropertyKey key, ClassProperties &klass, JSVal value);
void parseTranslateAnchor(const char *property_name, ClassPropertyKey key, ClassProperties &klass, JSVal value);
void parseFunctionArray(const char *property_name, const std::vector<ClassPropertyKey> &keys, ClassProperties &klass, JSVal value);