xFileDataDef.cxx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // Filename: xFileDataDef.cxx
  2. // Created by: drose (03Oct04)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #include "xFileDataDef.h"
  19. #include "indent.h"
  20. TypeHandle XFileDataDef::_type_handle;
  21. ////////////////////////////////////////////////////////////////////
  22. // Function: XFileDataDef::Destructor
  23. // Access: Public, Virtual
  24. // Description:
  25. ////////////////////////////////////////////////////////////////////
  26. XFileDataDef::
  27. ~XFileDataDef() {
  28. clear();
  29. }
  30. ////////////////////////////////////////////////////////////////////
  31. // Function: XFileDataDef::clear
  32. // Access: Public, Virtual
  33. // Description:
  34. ////////////////////////////////////////////////////////////////////
  35. void XFileDataDef::
  36. clear() {
  37. XFileNode::clear();
  38. _array_def.clear();
  39. }
  40. ////////////////////////////////////////////////////////////////////
  41. // Function: XFileDataDef::add_array_def
  42. // Access: Public
  43. // Description: Adds an additional array dimension to the data
  44. // description.
  45. ////////////////////////////////////////////////////////////////////
  46. void XFileDataDef::
  47. add_array_def(const XFileArrayDef &array_def) {
  48. _array_def.push_back(array_def);
  49. }
  50. ////////////////////////////////////////////////////////////////////
  51. // Function: XFileDataDef::write_text
  52. // Access: Public, Virtual
  53. // Description: Writes a suitable representation of this node to an
  54. // .x file in text mode.
  55. ////////////////////////////////////////////////////////////////////
  56. void XFileDataDef::
  57. write_text(ostream &out, int indent_level) const {
  58. indent(out, indent_level);
  59. if (!_array_def.empty()) {
  60. out << "array ";
  61. }
  62. switch (_type) {
  63. case T_word:
  64. out << "WORD";
  65. break;
  66. case T_dword:
  67. out << "DWORD";
  68. break;
  69. case T_float:
  70. out << "FLOAT";
  71. break;
  72. case T_double:
  73. out << "DOUBLE";
  74. break;
  75. case T_char:
  76. out << "CHAR";
  77. break;
  78. case T_uchar:
  79. out << "UCHAR";
  80. break;
  81. case T_sword:
  82. out << "SWORD";
  83. break;
  84. case T_sdword:
  85. out << "SDWORD";
  86. break;
  87. case T_string:
  88. out << "STRING";
  89. break;
  90. case T_cstring:
  91. out << "CSTRING";
  92. break;
  93. case T_unicode:
  94. out << "UNICODE";
  95. break;
  96. case T_template:
  97. out << _template->get_name();
  98. break;
  99. }
  100. if (has_name()) {
  101. out << " " << get_name();
  102. }
  103. ArrayDef::const_iterator ai;
  104. for (ai = _array_def.begin(); ai != _array_def.end(); ++ai) {
  105. (*ai).output(out);
  106. }
  107. out << ";\n";
  108. }