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

dtool/src/cppparser/cppNameComponent.cxx

Go to the documentation of this file.
00001 // Filename: cppNameComponent.cxx
00002 // Created by:  drose (12Nov99)
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 "cppNameComponent.h"
00021 #include "cppTemplateParameterList.h"
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //     Function: CPPNameComponent::Constructor
00025 //       Access: Public
00026 //  Description:
00027 ////////////////////////////////////////////////////////////////////
00028 CPPNameComponent::
00029 CPPNameComponent(const string &name) :
00030   _name(name)
00031 {
00032   _templ = (CPPTemplateParameterList *)NULL;
00033 }
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //     Function: CPPNameComponent::Equivalence Operator
00037 //       Access: Public
00038 //  Description:
00039 ////////////////////////////////////////////////////////////////////
00040 bool CPPNameComponent::
00041 operator == (const CPPNameComponent &other) const {
00042   if (_name != other._name) {
00043     return false;
00044   }
00045   if (_templ == NULL && other._templ == NULL) {
00046     return true;
00047   }
00048   if (_templ == NULL || other._templ == NULL) {
00049     return false;
00050   }
00051   if (*_templ != *other._templ) {
00052     return false;
00053   }
00054 
00055   return true;
00056 }
00057 
00058 ////////////////////////////////////////////////////////////////////
00059 //     Function: CPPNameComponent::Nonequivalence Operator
00060 //       Access: Public
00061 //  Description:
00062 ////////////////////////////////////////////////////////////////////
00063 bool CPPNameComponent::
00064 operator != (const CPPNameComponent &other) const {
00065   return !(*this == other);
00066 }
00067 
00068 ////////////////////////////////////////////////////////////////////
00069 //     Function: CPPNameComponent::Ordering Operator
00070 //       Access: Public
00071 //  Description:
00072 ////////////////////////////////////////////////////////////////////
00073 bool CPPNameComponent::
00074 operator < (const CPPNameComponent &other) const {
00075   if (_name != other._name) {
00076     return _name < other._name;
00077   }
00078   if (_templ == NULL && other._templ == NULL) {
00079     return false;
00080   }
00081   if (_templ == NULL || other._templ == NULL) {
00082     return _templ < other._templ;
00083   }
00084   return (*_templ) < (*other._templ);
00085 }
00086 
00087 ////////////////////////////////////////////////////////////////////
00088 //     Function: CPPNameComponent::output
00089 //       Access: Public
00090 //  Description:
00091 ////////////////////////////////////////////////////////////////////
00092 string CPPNameComponent::
00093 get_name() const {
00094   return _name;
00095 }
00096 
00097 ////////////////////////////////////////////////////////////////////
00098 //     Function: CPPNameComponent::get_name_with_templ
00099 //       Access: Public
00100 //  Description:
00101 ////////////////////////////////////////////////////////////////////
00102 string CPPNameComponent::
00103 get_name_with_templ(CPPScope *scope) const {
00104   ostringstream strm;
00105   strm << _name;
00106   if (_templ != NULL) {
00107     strm << "< ";
00108     _templ->output(strm, scope);
00109     strm << " >";
00110   }
00111   return strm.str();
00112 }
00113 
00114 ////////////////////////////////////////////////////////////////////
00115 //     Function: CPPNameComponent::get_templ
00116 //       Access: Public
00117 //  Description:
00118 ////////////////////////////////////////////////////////////////////
00119 CPPTemplateParameterList *CPPNameComponent::
00120 get_templ() const {
00121   return _templ;
00122 }
00123 
00124 ////////////////////////////////////////////////////////////////////
00125 //     Function: CPPNameComponent::empty
00126 //       Access: Public
00127 //  Description:
00128 ////////////////////////////////////////////////////////////////////
00129 bool CPPNameComponent::
00130 empty() const {
00131   return _name.empty();
00132 }
00133 
00134 ////////////////////////////////////////////////////////////////////
00135 //     Function: CPPNameComponent::has_templ
00136 //       Access: Public
00137 //  Description:
00138 ////////////////////////////////////////////////////////////////////
00139 bool CPPNameComponent::
00140 has_templ() const {
00141   return _templ != (CPPTemplateParameterList *)NULL;
00142 }
00143 
00144 ////////////////////////////////////////////////////////////////////
00145 //     Function: CPPNameComponent::is_tbd
00146 //       Access: Public
00147 //  Description: Returns true if the name component includes a
00148 //               template parameter list that includes some
00149 //               not-yet-defined type.
00150 ////////////////////////////////////////////////////////////////////
00151 bool CPPNameComponent::
00152 is_tbd() const {
00153   if (_templ != (CPPTemplateParameterList *)NULL) {
00154     return _templ->is_tbd();
00155   }
00156   return false;
00157 }
00158 
00159 ////////////////////////////////////////////////////////////////////
00160 //     Function: CPPNameComponent::set_name
00161 //       Access: Public
00162 //  Description:
00163 ////////////////////////////////////////////////////////////////////
00164 void CPPNameComponent::
00165 set_name(const string &name) {
00166   _name = name;
00167 }
00168 
00169 ////////////////////////////////////////////////////////////////////
00170 //     Function: CPPNameComponent::append_name
00171 //       Access: Public
00172 //  Description:
00173 ////////////////////////////////////////////////////////////////////
00174 void CPPNameComponent::
00175 append_name(const string &name) {
00176   _name += name;
00177 }
00178 
00179 ////////////////////////////////////////////////////////////////////
00180 //     Function: CPPNameComponent::set_templ
00181 //       Access: Public
00182 //  Description:
00183 ////////////////////////////////////////////////////////////////////
00184 void CPPNameComponent::
00185 set_templ(CPPTemplateParameterList *templ) {
00186   _templ = templ;
00187 }
00188 
00189 ////////////////////////////////////////////////////////////////////
00190 //     Function: CPPNameComponent::output
00191 //       Access: Public
00192 //  Description:
00193 ////////////////////////////////////////////////////////////////////
00194 void CPPNameComponent::
00195 output(ostream &out) const {
00196   out << _name;
00197   if (_templ != NULL) {
00198     out << "< " << *_templ << " >";
00199   }
00200 }

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