#pragma once #include "Utils.h" #include "PaletteList.h" #include "VariationList.h" #include "Ember.h" #ifdef __APPLE__ #include #endif /// /// XmlToEmber and Locale classes. /// namespace EmberNs { /// /// Convenience class for setting and resetting the locale. /// It's set up in the constructor and restored in the destructor. /// This relieves the caller of having to manually do it everywhere. /// class EMBER_API Locale { public: Locale(int category = LC_NUMERIC, const char* loc = "C"); ~Locale(); private: int m_Category; string m_NewLocale; string m_OriginalLocale; }; /// /// Class for reading Xml files into ember objects. /// This class derives from EmberReport, so the caller is able /// to retrieve a text dump of error information if any errors occur. /// Since this class contains a VariationList object, it's important to declare one /// instance and reuse it for the duration of the program instead of creating and deleting /// them as local variables. /// Template argument expected to be float or double. /// template class EMBER_API XmlToEmber : public EmberReport { public: XmlToEmber(); template class C> bool Parse(byte* buf, const char* filename, C, Alloc>& embers, bool useDefaults = true); template class C> bool Parse(const char* filename, C, Alloc>& embers, bool useDefaults = true); template bool Aton(const char* str, valT& val); static vector m_FlattenNames; private: template class C> void ScanForEmberNodes(xmlNode* curNode, char* parentFile, C, Alloc>& embers, bool useDefaults); bool ParseEmberElement(xmlNode* emberNode, Ember& currentEmber); bool AttToEmberMotionFloat(xmlAttrPtr att, const char* attStr, eEmberMotionParam param, EmberMotion& motion); bool ParseXform(xmlNode* childNode, Xform& xform, bool motion, bool fromEmber); static string GetCorrectedParamName(const unordered_map& names, const char* name); static string GetCorrectedVariationName(vector, vector>>& vec, xmlAttrPtr att); static bool XmlContainsTag(xmlAttrPtr att, const char* name); bool ParseHexColors(char* colstr, Ember& ember, size_t numColors, intmax_t chan); template bool ParseAndAssign(const xmlChar* name, const char* attStr, const char* str, valT& val, bool& b); static bool m_Init; static unordered_map m_BadParamNames; static vector, vector>> m_BadVariationNames; shared_ptr> m_VariationList;//The variation list used to make copies of variations to populate the embers with. PaletteList m_PaletteList; }; }