• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright 2006 Sony Computer Entertainment Inc.
3 *
4 * Licensed under the MIT Open Source License, for details please see license.txt or the website
5 * http://www.opensource.org/licenses/mit-license.php
6 *
7 */
8 
9 #ifndef __DAE_IO_PLUGIN_COMMON__
10 #define __DAE_IO_PLUGIN_COMMON__
11 
12 #include <vector>
13 #include <dae/daeElement.h>
14 #include <dae/daeURI.h>
15 #include <dae/daeMetaAttribute.h>
16 #include <dae/daeIOPlugin.h>
17 
18 class daeMetaElement;
19 class daeDocument;
20 
21 /**
22  * The @c daeIOPluginCommon class was created to serve as a base class for the common functionality
23  * between the daeLIBXMLPlugin and daeTinyXMLPlugin classes.
24  */
25 class DLLSPEC daeIOPluginCommon : public daeIOPlugin {
26 public:
27 	/**
28 	 * Constructor.
29 	 */
30 	daeIOPluginCommon();
31 	/**
32 	 * Destructor.
33 	 */
34 	virtual ~daeIOPluginCommon();
35 
36 	virtual daeInt setMeta(daeMetaElement *topMeta);
37 
38 	// Database setup
39 	virtual void setDatabase(daeDatabase* database);
40 
41 	// Operations
42 	virtual daeInt read(const daeURI& uri, daeString docBuffer);
43 
44 protected:
45 	daeDatabase* database;
46 
47 	// On failure, these functions return NULL
48 	virtual daeElementRef readFromFile(const daeURI& uri) = 0;
49 	virtual daeElementRef readFromMemory(daeString buffer, const daeURI& baseUri) = 0;
50 
51 	// Reading support for subclasses
52 	typedef std::pair<daeString, daeString> attrPair;
53 	daeElementRef beginReadElement(daeElement* parentElement,
54 	                               daeString elementName,
55 	                               const std::vector<attrPair>& attributes,
56 	                               daeInt lineNumber);
57 	bool readElementText(daeElement* element, daeString text, daeInt elementLineNumber);
58 
59 private:
60 	daeMetaElement* topMeta;
61 };
62 
63 #endif //__DAE_IO_PLUGIN_COMMON__
64