daeIOPluginCommon.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_IO_PLUGIN_COMMON__
  14. #define __DAE_IO_PLUGIN_COMMON__
  15. #include <vector>
  16. #include <dae/daeElement.h>
  17. #include <dae/daeURI.h>
  18. #include <dae/daeMetaAttribute.h>
  19. #include <dae/daeIOPlugin.h>
  20. class daeMetaElement;
  21. class daeDocument;
  22. /**
  23. * The @c daeIOPluginCommon class was created to serve as a base class for the common functionality
  24. * between the daeLIBXMLPlugin and daeTinyXMLPlugin classes.
  25. */
  26. class DLLSPEC daeIOPluginCommon : public daeIOPlugin {
  27. public:
  28. /**
  29. * Constructor.
  30. */
  31. daeIOPluginCommon();
  32. /**
  33. * Destructor.
  34. */
  35. virtual ~daeIOPluginCommon();
  36. virtual daeInt setMeta(daeMetaElement *topMeta);
  37. // Database setup
  38. virtual void setDatabase(daeDatabase* database);
  39. // Operations
  40. virtual daeInt read(const daeURI& uri, daeString docBuffer);
  41. protected:
  42. daeDatabase* database;
  43. // On failure, these functions return NULL
  44. virtual daeElementRef readFromFile(const daeURI& uri) = 0;
  45. virtual daeElementRef readFromMemory(daeString buffer, const daeURI& baseUri) = 0;
  46. // Reading support for subclasses
  47. typedef std::pair<daeString, daeString> attrPair;
  48. daeElementRef beginReadElement(daeElement* parentElement,
  49. daeString elementName,
  50. const std::vector<attrPair>& attributes,
  51. daeInt lineNumber);
  52. bool readElementText(daeElement* element, daeString text, daeInt elementLineNumber);
  53. private:
  54. daeMetaElement* topMeta;
  55. };
  56. #endif //__DAE_IO_PLUGIN_COMMON__