00001 /* 00002 * Copyright 2006 Sony Computer Entertainment Inc. 00003 * 00004 * Licensed under the MIT Open Source License, for details please see license.txt or the website 00005 * http://www.opensource.org/licenses/mit-license.php 00006 * 00007 */ 00008 00009 #ifndef __DAE_IO_PLUGIN_COMMON__ 00010 #define __DAE_IO_PLUGIN_COMMON__ 00011 00012 #include <vector> 00013 #include <dae/daeElement.h> 00014 #include <dae/daeURI.h> 00015 #include <dae/daeMetaAttribute.h> 00016 #include <dae/daeIOPlugin.h> 00017 00018 class daeMetaElement; 00019 class daeDocument; 00020 00025 class DLLSPEC daeIOPluginCommon : public daeIOPlugin { 00026 public: 00030 daeIOPluginCommon(); 00034 virtual ~daeIOPluginCommon(); 00035 00036 virtual daeInt setMeta(daeMetaElement *topMeta); 00037 00038 // Database setup 00039 virtual void setDatabase(daeDatabase* database); 00040 00041 // Operations 00042 virtual daeInt read(const daeURI& uri, daeString docBuffer); 00043 00044 protected: 00045 daeDatabase* database; 00046 00047 // On failure, these functions return NULL 00048 virtual daeElementRef readFromFile(const daeURI& uri) = 0; 00049 virtual daeElementRef readFromMemory(daeString buffer, const daeURI& baseUri) = 0; 00050 00051 // Reading support for subclasses 00052 typedef std::pair<daeString, daeString> attrPair; 00053 daeElementRef beginReadElement(daeElement* parentElement, 00054 daeString elementName, 00055 const std::vector<attrPair>& attributes, 00056 daeInt lineNumber); 00057 bool readElementText(daeElement* element, daeString text, daeInt elementLineNumber); 00058 00059 private: 00060 daeMetaElement* topMeta; 00061 }; 00062 00063 #endif //__DAE_IO_PLUGIN_COMMON__