| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- // Filename: cppNameComponent.cxx
- // Created by: drose (12Nov99)
- //
- ////////////////////////////////////////////////////////////////////
- //
- // PANDA 3D SOFTWARE
- // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
- //
- // All use of this software is subject to the terms of the Panda 3d
- // Software license. You should have received a copy of this license
- // along with this source code; you will also find a current copy of
- // the license at http://etc.cmu.edu/panda3d/docs/license/ .
- //
- // To contact the maintainers of this program write to
- // [email protected] .
- //
- ////////////////////////////////////////////////////////////////////
- #include "cppNameComponent.h"
- #include "cppTemplateParameterList.h"
- ////////////////////////////////////////////////////////////////////
- // Function: CPPNameComponent::Constructor
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPNameComponent::
- CPPNameComponent(const string &name) :
- _name(name)
- {
- _templ = (CPPTemplateParameterList *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPNameComponent::Equivalence Operator
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- bool CPPNameComponent::
- operator == (const CPPNameComponent &other) const {
- if (_name != other._name) {
- return false;
- }
- if (_templ == NULL && other._templ == NULL) {
- return true;
- }
- if (_templ == NULL || other._templ == NULL) {
- return false;
- }
- if (*_templ != *other._templ) {
- return false;
- }
- return true;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPNameComponent::Nonequivalence Operator
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- bool CPPNameComponent::
- operator != (const CPPNameComponent &other) const {
- return !(*this == other);
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPNameComponent::Ordering Operator
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- bool CPPNameComponent::
- operator < (const CPPNameComponent &other) const {
- if (_name != other._name) {
- return _name < other._name;
- }
- if (_templ == NULL && other._templ == NULL) {
- return false;
- }
- if (_templ == NULL || other._templ == NULL) {
- return _templ < other._templ;
- }
- return (*_templ) < (*other._templ);
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPNameComponent::output
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- string CPPNameComponent::
- get_name() const {
- return _name;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPNameComponent::get_name_with_templ
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- string CPPNameComponent::
- get_name_with_templ(CPPScope *scope) const {
- ostringstream strm;
- strm << _name;
- if (_templ != NULL) {
- strm << "< ";
- _templ->output(strm, scope);
- strm << " >";
- }
- return strm.str();
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPNameComponent::get_templ
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPTemplateParameterList *CPPNameComponent::
- get_templ() const {
- return _templ;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPNameComponent::empty
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- bool CPPNameComponent::
- empty() const {
- return _name.empty();
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPNameComponent::has_templ
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- bool CPPNameComponent::
- has_templ() const {
- return _templ != (CPPTemplateParameterList *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPNameComponent::is_tbd
- // Access: Public
- // Description: Returns true if the name component includes a
- // template parameter list that includes some
- // not-yet-defined type.
- ////////////////////////////////////////////////////////////////////
- bool CPPNameComponent::
- is_tbd() const {
- if (_templ != (CPPTemplateParameterList *)NULL) {
- return _templ->is_tbd();
- }
- return false;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPNameComponent::set_name
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- void CPPNameComponent::
- set_name(const string &name) {
- _name = name;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPNameComponent::append_name
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- void CPPNameComponent::
- append_name(const string &name) {
- _name += name;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPNameComponent::set_templ
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- void CPPNameComponent::
- set_templ(CPPTemplateParameterList *templ) {
- _templ = templ;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPNameComponent::output
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- void CPPNameComponent::
- output(ostream &out) const {
- out << _name;
- if (_templ != NULL) {
- out << "< " << *_templ << " >";
- }
- }
|