You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

115 lines
3.8 KiB

  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2012, assimp team
  5. All rights reserved.
  6. Redistribution and use of this software in source and binary forms,
  7. with or without modification, are permitted provided that the
  8. following conditions are met:
  9. * Redistributions of source code must retain the above
  10. copyright notice, this list of conditions and the
  11. following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the
  14. following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. * Neither the name of the assimp team, nor the names of its
  17. contributors may be used to endorse or promote products
  18. derived from this software without specific prior
  19. written permission of the assimp team.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. ----------------------------------------------------------------------
  32. */
  33. /** @file FBXDocumentUtil.h
  34. * @brief FBX internal utilities used by the DOM reading code
  35. */
  36. #ifndef INCLUDED_AI_FBX_DOCUMENT_UTIL_H
  37. #define INCLUDED_AI_FBX_DOCUMENT_UTIL_H
  38. namespace Assimp {
  39. namespace FBX {
  40. namespace Util {
  41. /* DOM/Parse error reporting - does not return */
  42. AI_WONT_RETURN void DOMError(const std::string& message, const Token& token) AI_WONT_RETURN_SUFFIX;
  43. AI_WONT_RETURN void DOMError(const std::string& message, const Element* element = NULL) AI_WONT_RETURN_SUFFIX;
  44. // does return
  45. void DOMWarning(const std::string& message, const Token& token);
  46. void DOMWarning(const std::string& message, const Element* element = NULL);
  47. // fetch a property table and the corresponding property template
  48. boost::shared_ptr<const PropertyTable> GetPropertyTable(const Document& doc,
  49. const std::string& templateName,
  50. const Element &element,
  51. const Scope& sc,
  52. bool no_warn = false);
  53. // ------------------------------------------------------------------------------------------------
  54. template <typename T>
  55. inline const T* ProcessSimpleConnection(const Connection& con,
  56. bool is_object_property_conn,
  57. const char* name,
  58. const Element& element,
  59. const char** propNameOut = NULL)
  60. {
  61. if (is_object_property_conn && !con.PropertyName().length()) {
  62. DOMWarning("expected incoming " + std::string(name) +
  63. " link to be an object-object connection, ignoring",
  64. &element
  65. );
  66. return NULL;
  67. }
  68. else if (!is_object_property_conn && con.PropertyName().length()) {
  69. DOMWarning("expected incoming " + std::string(name) +
  70. " link to be an object-property connection, ignoring",
  71. &element
  72. );
  73. return NULL;
  74. }
  75. if(is_object_property_conn && propNameOut) {
  76. // note: this is ok, the return value of PropertyValue() is guaranteed to
  77. // remain valid and unchanged as long as the document exists.
  78. *propNameOut = con.PropertyName().c_str();
  79. }
  80. const Object* const ob = con.SourceObject();
  81. if(!ob) {
  82. DOMWarning("failed to read source object for incoming" + std::string(name) +
  83. " link, ignoring",
  84. &element);
  85. return NULL;
  86. }
  87. return dynamic_cast<const T*>(ob);
  88. }
  89. } //!Util
  90. } //!FBX
  91. } //!Assimp
  92. #endif