p3dIntObject.cxx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Filename: p3dIntObject.cxx
  2. // Created by: drose (30Jun09)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. #include "p3dIntObject.h"
  15. ////////////////////////////////////////////////////////////////////
  16. // Function: P3DIntObject::Constructor
  17. // Access: Public
  18. // Description:
  19. ////////////////////////////////////////////////////////////////////
  20. P3DIntObject::
  21. P3DIntObject(int value) : _value(value) {
  22. }
  23. ////////////////////////////////////////////////////////////////////
  24. // Function: P3DIntObject::Copy Constructor
  25. // Access: Public
  26. // Description:
  27. ////////////////////////////////////////////////////////////////////
  28. P3DIntObject::
  29. P3DIntObject(const P3DIntObject &copy) :
  30. P3DObject(copy),
  31. _value(copy._value)
  32. {
  33. }
  34. ////////////////////////////////////////////////////////////////////
  35. // Function: P3DIntObject::get_type
  36. // Access: Public, Virtual
  37. // Description: Returns the fundamental type of this kind of object.
  38. ////////////////////////////////////////////////////////////////////
  39. P3D_object_type P3DIntObject::
  40. get_type() {
  41. return P3D_OT_int;
  42. }
  43. ////////////////////////////////////////////////////////////////////
  44. // Function: P3DIntObject::get_bool
  45. // Access: Public, Virtual
  46. // Description: Returns the object value coerced to a boolean, if
  47. // possible.
  48. ////////////////////////////////////////////////////////////////////
  49. bool P3DIntObject::
  50. get_bool() {
  51. return (_value != 0);
  52. }
  53. ////////////////////////////////////////////////////////////////////
  54. // Function: P3DIntObject::get_int
  55. // Access: Public, Virtual
  56. // Description: Returns the object value coerced to an integer, if
  57. // possible.
  58. ////////////////////////////////////////////////////////////////////
  59. int P3DIntObject::
  60. get_int() {
  61. return _value;
  62. }
  63. ////////////////////////////////////////////////////////////////////
  64. // Function: P3DIntObject::make_string
  65. // Access: Public, Virtual
  66. // Description: Fills the indicated C++ string object with the value
  67. // of this object coerced to a string.
  68. ////////////////////////////////////////////////////////////////////
  69. void P3DIntObject::
  70. make_string(string &value) {
  71. ostringstream strm;
  72. strm << _value;
  73. value = strm.str();
  74. }