Documented most of the still relevant tools
This commit is contained in:
@@ -10,8 +10,29 @@ namespace Dawn {
|
||||
template<typename T>
|
||||
class XmlParser {
|
||||
protected:
|
||||
/**
|
||||
* Get the required attributes for this Xml Node to have.
|
||||
*
|
||||
* @return Vector of strings of required attribute keys.
|
||||
*/
|
||||
virtual std::vector<std::string> getRequiredAttributes() = 0;
|
||||
|
||||
/**
|
||||
* Return optional attributes with defaults for this node to have.
|
||||
*
|
||||
* @return Key-Value Pair of optional attributes and defaults.
|
||||
*/
|
||||
virtual std::map<std::string, std::string> getOptionalAttributes() = 0;
|
||||
|
||||
/**
|
||||
* Callback to be invoked upon successful parse of this node.
|
||||
*
|
||||
* @param node Node that was parsed.
|
||||
* @param values KVP of values from the required and optional attrs.
|
||||
* @param output Templated output of the parse from this method.
|
||||
* @param error Pointer to a string to write-out any errors.
|
||||
* @return Non 0 for error, 0 for success.
|
||||
*/
|
||||
virtual int32_t onParse(
|
||||
Xml *node,
|
||||
std::map<std::string, std::string> values,
|
||||
@@ -20,18 +41,38 @@ namespace Dawn {
|
||||
) = 0;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Common parse method to parse a duration from a value string.
|
||||
*
|
||||
* @param duration Duration string to parse.
|
||||
* @return The parsed duration.
|
||||
*/
|
||||
static std::string parseDuration(std::string duration) {
|
||||
std::string dur = duration;
|
||||
if(dur.find('.') == std::string::npos) dur += ".0";
|
||||
return dur + "f";
|
||||
}
|
||||
|
||||
/**
|
||||
* Common parse method to parse an easing from a value string.
|
||||
*
|
||||
* @param e Easing string to parse.
|
||||
* @return The parsed ease.
|
||||
*/
|
||||
static std::string parseEase(std::string e) {
|
||||
if(e == "out-quad") return "&easeOutQuad";
|
||||
if(e == "linear") return "&easeLinear";
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles parsing of an Xml node.
|
||||
*
|
||||
* @param xml Xml node to parse.
|
||||
* @param output Output struct to put the output data.
|
||||
* @param error Pointer to the string for errors to be stored.
|
||||
* @return 0 for success, otherwise for error.
|
||||
*/
|
||||
int32_t parse(Xml *xml, T *output, std::string *error) {
|
||||
std::map<std::string, std::string> values;
|
||||
|
||||
|
Reference in New Issue
Block a user