interrogateElement.cxx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * PANDA 3D SOFTWARE
  3. * Copyright (c) Carnegie Mellon University. All rights reserved.
  4. *
  5. * All use of this software is subject to the terms of the revised BSD
  6. * license. You should have received a copy of this license along
  7. * with this source code in a file named "LICENSE."
  8. *
  9. * @file interrogateElement.cxx
  10. * @author drose
  11. * @date 2000-08-11
  12. */
  13. #include "interrogateElement.h"
  14. #include "interrogateDatabase.h"
  15. #include "indexRemapper.h"
  16. #include "interrogate_datafile.h"
  17. /**
  18. * Formats the InterrogateElement data for output to a data file.
  19. */
  20. void InterrogateElement::
  21. output(std::ostream &out) const {
  22. InterrogateComponent::output(out);
  23. out << _flags << " "
  24. << _type << " "
  25. << _getter << " "
  26. << _setter << " "
  27. << _has_function << " "
  28. << _clear_function << " "
  29. << _del_function << " "
  30. << _length_function << " "
  31. << _insert_function << " "
  32. << _getkey_function << " ";
  33. idf_output_string(out, _scoped_name);
  34. idf_output_string(out, _comment, '\n');
  35. }
  36. /**
  37. * Reads the data file as previously formatted by output().
  38. */
  39. void InterrogateElement::
  40. input(std::istream &in) {
  41. InterrogateComponent::input(in);
  42. in >> _flags >> _type >> _getter >> _setter;
  43. if (InterrogateDatabase::get_file_minor_version() >= 1) {
  44. in >> _has_function >> _clear_function;
  45. if (InterrogateDatabase::get_file_minor_version() >= 2) {
  46. in >> _del_function >> _length_function;
  47. if (InterrogateDatabase::get_file_minor_version() >= 3) {
  48. in >> _insert_function >> _getkey_function;
  49. }
  50. }
  51. }
  52. idf_input_string(in, _scoped_name);
  53. idf_input_string(in, _comment);
  54. }
  55. /**
  56. * Remaps all internal index numbers according to the indicated map. This
  57. * called from InterrogateDatabase::remap_indices().
  58. */
  59. void InterrogateElement::
  60. remap_indices(const IndexRemapper &remap) {
  61. _type = remap.map_from(_type);
  62. _getter = remap.map_from(_getter);
  63. _setter = remap.map_from(_setter);
  64. _has_function = remap.map_from(_has_function);
  65. _clear_function = remap.map_from(_clear_function);
  66. _del_function = remap.map_from(_del_function);
  67. _insert_function = remap.map_from(_insert_function);
  68. _getkey_function = remap.map_from(_getkey_function);
  69. _length_function = remap.map_from(_length_function);
  70. }