Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

dtool/src/cppparser/cppNamespace.cxx

Go to the documentation of this file.
00001 // Filename: cppNamespace.cxx
00002 // Created by:  drose (16Nov99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 
00020 #include "cppNamespace.h"
00021 #include "cppIdentifier.h"
00022 #include "cppScope.h"
00023 #include "indent.h"
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //     Function: CPPNamespace::Constructor
00027 //       Access: Public
00028 //  Description:
00029 ////////////////////////////////////////////////////////////////////
00030 CPPNamespace::
00031 CPPNamespace(CPPIdentifier *ident, CPPScope *scope, const CPPFile &file) :
00032   CPPDeclaration(file),
00033   _ident(ident), _scope(scope)
00034 {
00035 }
00036 
00037 ////////////////////////////////////////////////////////////////////
00038 //     Function: CPPNamespace::get_simple_name
00039 //       Access: Public
00040 //  Description:
00041 ////////////////////////////////////////////////////////////////////
00042 string CPPNamespace::
00043 get_simple_name() const {
00044   if (_ident == NULL) {
00045     return "";
00046   }
00047   return _ident->get_simple_name();
00048 }
00049 
00050 ////////////////////////////////////////////////////////////////////
00051 //     Function: CPPNamespace::get_local_name
00052 //       Access: Public
00053 //  Description:
00054 ////////////////////////////////////////////////////////////////////
00055 string CPPNamespace::
00056 get_local_name(CPPScope *scope) const {
00057   if (_ident == NULL) {
00058     return "";
00059   }
00060   return _ident->get_local_name(scope);
00061 }
00062 
00063 ////////////////////////////////////////////////////////////////////
00064 //     Function: CPPNamespace::get_fully_scoped_name
00065 //       Access: Public
00066 //  Description:
00067 ////////////////////////////////////////////////////////////////////
00068 string CPPNamespace::
00069 get_fully_scoped_name() const {
00070   if (_ident == NULL) {
00071     return "";
00072   }
00073   return _ident->get_fully_scoped_name();
00074 }
00075 
00076 ////////////////////////////////////////////////////////////////////
00077 //     Function: CPPNamespace::get_scope
00078 //       Access: Public
00079 //  Description:
00080 ////////////////////////////////////////////////////////////////////
00081 CPPScope *CPPNamespace::
00082 get_scope() const {
00083   return _scope;
00084 }
00085 
00086 ////////////////////////////////////////////////////////////////////
00087 //     Function: CPPNamespace::output
00088 //       Access: Public, Virtual
00089 //  Description:
00090 ////////////////////////////////////////////////////////////////////
00091 void CPPNamespace::
00092 output(ostream &out, int indent_level, CPPScope *scope, bool complete) const {
00093   if (!complete && _ident != NULL) {
00094     // If we have a name, use it.
00095     out << "namespace " << _ident->get_local_name(scope);
00096 
00097   } else {
00098     if (_ident != NULL) {
00099       out << "namespace " << _ident->get_local_name(scope) << " {\n";
00100     } else {
00101       out << "namespace {\n";
00102     }
00103 
00104     _scope->write(out, indent_level + 2, _scope);
00105     indent(out, indent_level) << "}";
00106   }
00107 }
00108 
00109 ////////////////////////////////////////////////////////////////////
00110 //     Function: CPPNamespace::get_subtype
00111 //       Access: Public, Virtual
00112 //  Description:
00113 ////////////////////////////////////////////////////////////////////
00114 CPPDeclaration::SubType CPPNamespace::
00115 get_subtype() const {
00116   return ST_namespace;
00117 }
00118 
00119 ////////////////////////////////////////////////////////////////////
00120 //     Function: CPPNamespace::as_namespace
00121 //       Access: Public, Virtual
00122 //  Description:
00123 ////////////////////////////////////////////////////////////////////
00124 CPPNamespace *CPPNamespace::
00125 as_namespace() {
00126   return this;
00127 }

Generated on Thu May 1 22:12:52 2003 for DTool by doxygen1.3