Panda3D
Loading...
Searching...
No Matches
xFileDataObjectInteger.cxx
Go to the documentation of this file.
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 xFileDataObjectInteger.cxx
10 * @author drose
11 * @date 2004-10-07
12 */
13
15#include "string_utils.h"
16#include "indent.h"
17
18TypeHandle XFileDataObjectInteger::_type_handle;
19
20/**
21 *
22 */
23XFileDataObjectInteger::
24XFileDataObjectInteger(const XFileDataDef *data_def, int value) :
25 XFileDataObject(data_def),
26 _value(value)
27{
28}
29
30/**
31 * Writes a suitable representation of this node to an .x file in text mode.
32 */
34output_data(std::ostream &out) const {
35 out << _value;
36}
37
38/**
39 * Writes a suitable representation of this node to an .x file in text mode.
40 */
42write_data(std::ostream &out, int indent_level, const char *separator) const {
43 indent(out, indent_level)
44 << _value << separator << "\n";
45}
46
47/**
48 * Sets the object's value as an integer, if this is legal.
49 */
50void XFileDataObjectInteger::
51set_int_value(int int_value) {
52 _value = int_value;
53}
54
55/**
56 * Returns the object's representation as an integer, if it has one.
57 */
58int XFileDataObjectInteger::
59get_int_value() const {
60 return _value;
61}
62
63/**
64 * Returns the object's representation as a double, if it has one.
65 */
66double XFileDataObjectInteger::
67get_double_value() const {
68 return _value;
69}
70
71/**
72 * Returns the object's representation as a string, if it has one.
73 */
74std::string XFileDataObjectInteger::
75get_string_value() const {
76 return format_string(_value);
77}
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
A definition of a single data element appearing within a template record.
virtual void output_data(std::ostream &out) const
Writes a suitable representation of this node to an .x file in text mode.
virtual void write_data(std::ostream &out, int indent_level, const char *separator) const
Writes a suitable representation of this node to an .x file in text mode.
The abstract base class for a number of different types of data elements that may be stored in the X ...
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition indent.cxx:20
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.