Panda3D
 All Classes Functions Variables Enumerations
eggNamedObject.cxx
1 // Filename: eggNamedObject.cxx
2 // Created by: drose (16Jan99)
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 
15 #include "eggNamedObject.h"
16 #include "eggMiscFuncs.h"
17 
18 #include "indent.h"
19 
20 TypeHandle EggNamedObject::_type_handle;
21 
22 ////////////////////////////////////////////////////////////////////
23 // Function: EggNamedObject::output
24 // Access: Public
25 // Description:
26 ////////////////////////////////////////////////////////////////////
27 void EggNamedObject::
28 output(ostream &out) const {
29  out << get_type();
30  if (has_name()) {
31  out << " " << get_name();
32  }
33 }
34 
35 ////////////////////////////////////////////////////////////////////
36 // Function: EggNamedObject::write_header
37 // Access: Public
38 // Description: Writes the first line of the egg object,
39 // e.g. "<Group> group_name {" or some such. It
40 // automatically enquotes the name if it contains any
41 // special characters. egg_keyword is the keyword that
42 // begins the line, e.g. "<Group>".
43 ////////////////////////////////////////////////////////////////////
45 write_header(ostream &out, int indent_level, const char *egg_keyword) const {
46  indent(out, indent_level) << egg_keyword << " ";
47 
48  if (has_name()) {
49  enquote_string(out, get_name()) << " {\n";
50  } else {
51  out << "{\n";
52  }
53 }
void write_header(ostream &out, int indent_level, const char *egg_keyword) const
Writes the first line of the egg object, e.g.
bool has_name() const
Returns true if the Namable has a nonempty name set, false if the name is empty.
Definition: namable.I:75
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85