Panda3D
eggNamedObject.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 eggNamedObject.cxx
10  * @author drose
11  * @date 1999-01-16
12  */
13 
14 #include "eggNamedObject.h"
15 #include "eggMiscFuncs.h"
16 
17 #include "indent.h"
18 
19 TypeHandle EggNamedObject::_type_handle;
20 
21 /**
22  *
23  */
24 void EggNamedObject::
25 output(std::ostream &out) const {
26  out << get_type();
27  if (has_name()) {
28  out << " " << get_name();
29  }
30 }
31 
32 /**
33  * Writes the first line of the egg object, e.g. "<Group> group_name {" or
34  * some such. It automatically enquotes the name if it contains any special
35  * characters. egg_keyword is the keyword that begins the line, e.g.
36  * "<Group>".
37  */
39 write_header(std::ostream &out, int indent_level, const char *egg_keyword) const {
40  indent(out, indent_level) << egg_keyword << " ";
41 
42  if (has_name()) {
43  enquote_string(out, get_name()) << " {\n";
44  } else {
45  out << "{\n";
46  }
47 }
void write_header(std::ostream &out, int indent_level, const char *egg_keyword) const
Writes the first line of the egg object, e.g.
ostream & enquote_string(ostream &out, const string &str, int indent_level, bool always_quote)
Writes the string to the indicated output stream.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition: indent.cxx:20
bool has_name() const
Returns true if the Namable has a nonempty name set, false if the name is empty.
Definition: namable.I:44
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.