daeTinyXMLPlugin.h 2.2 KB

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