daeTinyXMLPlugin.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright 2007 Sony Computer Entertainment Inc.
  3. *
  4. * Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this
  5. * file except in compliance with the License. You may obtain a copy of the License at:
  6. * http://research.scea.com/scea_shared_source_license.html
  7. *
  8. * Unless required by applicable law or agreed to in writing, software distributed under the License
  9. * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  10. * implied. See the License for the specific language governing permissions and limitations under the
  11. * License.
  12. */
  13. #ifndef __DAE_TINYXMLPLUGIN__
  14. #define __DAE_TINYXMLPLUGIN__
  15. #include <vector>
  16. #include <list>
  17. #include <dae/daeElement.h>
  18. #include <dae/daeURI.h>
  19. #include <dae/daeIOPluginCommon.h>
  20. #ifndef TINYXML2_INCLUDED
  21. #include <tinyxml2.h>
  22. #endif
  23. class daeTinyXMLPlugin : public daeIOPluginCommon
  24. {
  25. public:
  26. // Constructor / destructor
  27. /**
  28. * Constructor.
  29. */
  30. DLLSPEC daeTinyXMLPlugin();
  31. /**
  32. * Destructor.
  33. */
  34. virtual DLLSPEC ~daeTinyXMLPlugin();
  35. // Operations
  36. virtual DLLSPEC daeInt write(const daeURI& name, daeDocument *document, daeBool replace);
  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. * getOption retrieves the value of an option from this IOPlugin. Which options a plugin supports is
  50. * dependent on the plugin itself.
  51. * @param option The option to get.
  52. * @return Returns the string value of the option or NULL if option is not valid.
  53. */
  54. virtual DLLSPEC daeString getOption( daeString option );
  55. private:
  56. tinyxml2::XMLDocument* m_doc;
  57. std::list<tinyxml2::XMLElement*> m_elements;
  58. virtual daeElementRef readFromFile(const daeURI& uri);
  59. virtual daeElementRef readFromMemory(daeString buffer, const daeURI& baseUri);
  60. daeElementRef readElement(tinyxml2::XMLElement* tinyXmlElement, daeElement* parentElement);
  61. void writeElement( daeElement* element );
  62. void writeAttribute( daeMetaAttribute* attr, daeElement* element );
  63. void writeValue( daeElement* element );
  64. };
  65. #endif //__DAE_TINYXMLPLUGIN__