| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- /**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file cppNameComponent.cxx
- * @author drose
- * @date 1999-11-12
- */
- #include "cppNameComponent.h"
- #include "cppTemplateParameterList.h"
- using std::string;
- /**
- *
- */
- CPPNameComponent::
- CPPNameComponent(const string &name) :
- _name(name)
- {
- _templ = nullptr;
- }
- /**
- *
- */
- bool CPPNameComponent::
- operator == (const CPPNameComponent &other) const {
- if (_name != other._name) {
- return false;
- }
- if (_templ == nullptr && other._templ == nullptr) {
- return true;
- }
- if (_templ == nullptr || other._templ == nullptr) {
- return false;
- }
- if (*_templ != *other._templ) {
- return false;
- }
- return true;
- }
- /**
- *
- */
- bool CPPNameComponent::
- operator != (const CPPNameComponent &other) const {
- return !(*this == other);
- }
- /**
- *
- */
- bool CPPNameComponent::
- operator < (const CPPNameComponent &other) const {
- if (_name != other._name) {
- return _name < other._name;
- }
- if (_templ == nullptr && other._templ == nullptr) {
- return false;
- }
- if (_templ == nullptr || other._templ == nullptr) {
- return _templ < other._templ;
- }
- return (*_templ) < (*other._templ);
- }
- /**
- *
- */
- string CPPNameComponent::
- get_name() const {
- return _name;
- }
- /**
- *
- */
- string CPPNameComponent::
- get_name_with_templ(CPPScope *scope) const {
- std::ostringstream strm;
- strm << _name;
- if (_templ != nullptr) {
- strm << "< ";
- _templ->output(strm, scope);
- strm << " >";
- }
- return strm.str();
- }
- /**
- *
- */
- CPPTemplateParameterList *CPPNameComponent::
- get_templ() const {
- return _templ;
- }
- /**
- *
- */
- bool CPPNameComponent::
- empty() const {
- return _name.empty();
- }
- /**
- *
- */
- bool CPPNameComponent::
- has_templ() const {
- return _templ != nullptr;
- }
- /**
- * 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 != nullptr) {
- return _templ->is_tbd();
- }
- return false;
- }
- /**
- *
- */
- void CPPNameComponent::
- set_name(const string &name) {
- _name = name;
- }
- /**
- *
- */
- void CPPNameComponent::
- append_name(const string &name) {
- _name += name;
- }
- /**
- *
- */
- void CPPNameComponent::
- set_templ(CPPTemplateParameterList *templ) {
- _templ = templ;
- }
- /**
- *
- */
- void CPPNameComponent::
- output(std::ostream &out) const {
- out << _name;
- if (_templ != nullptr) {
- out << "< " << *_templ << " >";
- }
- }
|