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_TINYXMLPLUGIN__
10#define __DAE_TINYXMLPLUGIN__
11
12#include <vector>
13#include <list>
14#include <dae/daeElement.h>
15#include <dae/daeURI.h>
16#include <dae/daeIOPluginCommon.h>
17
18class TiXmlDocument;
19class TiXmlElement;
20
21class daeTinyXMLPlugin : public daeIOPluginCommon
22{
23public:
24	// Constructor / destructor
25	/**
26	 * Constructor.
27	 */
28	DLLSPEC daeTinyXMLPlugin();
29	/**
30	 * Destructor.
31	 */
32	virtual DLLSPEC ~daeTinyXMLPlugin();
33
34	// Operations
35	virtual DLLSPEC daeInt write(const daeURI& name, daeDocument *document, daeBool replace);
36
37	/**
38	 * setOption allows you to set options for this IOPlugin. Which options a plugin supports is
39	 * dependent on the plugin itself. There is currently no list of options that plugins are
40	 * suggested to implement. daeLibXML2Plugin supports only one option, "saveRawBinary". Set to
41	 * "true" to save float_array data as a .raw binary file. The daeRawResolver will convert the
42	 * data back into COLLADA domFloat_array elements upon load.
43	 * @param option The option to set.
44	 * @param value The value to set the option.
45	 * @return Returns DAE_OK upon success.
46	 */
47	virtual DLLSPEC daeInt setOption( daeString option, daeString value );
48
49	/**
50	 * getOption retrieves the value of an option from this IOPlugin. Which options a plugin supports is
51	 * dependent on the plugin itself.
52	 * @param option The option to get.
53	 * @return Returns the string value of the option or NULL if option is not valid.
54	 */
55	virtual DLLSPEC daeString getOption( daeString option );
56
57private:
58	TiXmlDocument*  m_doc;
59	std::list<TiXmlElement*>  m_elements;
60
61	virtual daeElementRef readFromFile(const daeURI& uri);
62	virtual daeElementRef readFromMemory(daeString buffer, const daeURI& baseUri);
63	daeElementRef readElement(TiXmlElement* tinyXmlElement, daeElement* parentElement);
64
65	void writeElement( daeElement* element );
66	void writeAttribute( daeMetaAttribute* attr, daeElement* element );
67	void writeValue( daeElement* element );
68};
69
70#endif //__DAE_TINYXMLPLUGIN__
71