metadata.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (assimp)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2012, assimp team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the assimp team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the assimp team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. /** @file metadata.h
  35. * @brief Defines the data structures for holding node meta information.
  36. */
  37. #ifndef __AI_METADATA_H_INC__
  38. #define __AI_METADATA_H_INC__
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. // -------------------------------------------------------------------------------
  43. /**
  44. * Container for holding metadata.
  45. *
  46. * Metadata is a key-value store using string keys and values.
  47. */
  48. // -------------------------------------------------------------------------------
  49. struct aiMetadata
  50. {
  51. /** Length of the mKeys and mValues arrays, respectively */
  52. unsigned int mNumProperties;
  53. /** Arrays of keys, may not be NULL. Entries in this array may not be NULL as well. */
  54. C_STRUCT aiString** mKeys;
  55. /** Arrays of values, may not be NULL. Entries in this array may be NULL if the
  56. * corresponding property key has no assigned value. */
  57. C_STRUCT aiString** mValues;
  58. #ifdef __cplusplus
  59. /** Constructor */
  60. aiMetadata()
  61. {
  62. // set all members to zero by default
  63. mKeys = NULL;
  64. mValues = NULL;
  65. mNumProperties = 0;
  66. }
  67. /** Destructor */
  68. ~aiMetadata()
  69. {
  70. if (mKeys && mValues) {
  71. for (unsigned i=0; i<mNumProperties; ++i) {
  72. if (mKeys[i]) {
  73. delete mKeys[i];
  74. }
  75. if (mValues[i]) {
  76. delete mValues[i];
  77. }
  78. }
  79. delete [] mKeys;
  80. delete [] mValues;
  81. }
  82. }
  83. inline bool Get(const aiString& key, aiString& value)
  84. {
  85. for (unsigned i=0; i<mNumProperties; ++i) {
  86. if (mKeys[i] && *mKeys[i]==key) {
  87. value=*mValues[i];
  88. return true;
  89. }
  90. }
  91. return false;
  92. }
  93. #endif // __cplusplus
  94. };
  95. #ifdef __cplusplus
  96. } //extern "C" {
  97. #endif
  98. #endif // __AI_METADATA_H_INC__