c++ - Template auto-generated code, not a type -
i'm attempting generate class can read type of serialized xsd/xml code. since have 1000 different data defintions, love make xmlloader
class generic.
however, in auto-generated serialized code, way obtain pointer in-memory data difficult me grasp.
the code:
template <class xmltype> class xmlloader { public: xmlloader(const std::string &filename, const std::string &xsd) : filename(filename), xsd(xsd) { try { this->initialize(); } catch (const xml_schema::exception &e) { error("unable parse [%s], aborting\n", filename.c_str()); } catch (const std::invalid_argument &e) { error("unable locate [%s], aborting\n", std::string(component::getjarssxsddirectory() + xsd).c_str()); } } std::auto_ptr<xmltype> xmlinstance; private: void initialize() { std::string schema = component::getjarssxsddirectory() + xsd; if (!application::validatepath(schema)) { throw std::invalid_argument("xsd cannot found"); } xml_schema::properties props; props.no_namespace_schema_location(schema); xmlinstance = std::auto_ptr<xmltype > (xmltype_(filename, 0, props)); } std::string filename; std::string xsd; };
the problem lies line: xmlinstance = std::auto_ptr<xmltype > (xmltype_(filename, 0, props));
if hand, like:
xmlinstance = std::auto_ptr<xmltype>(xmltype_(filename, 0, props));
notice _
function on xmltype.
when try template this, compiler states xmltype_
isn't type, nor included in argument template.
since xmltype_
isn't type, it's function generated xsd serializer, how can pass through template? i've never encountered before.
any ideas?
Comments
Post a Comment