#include <polymorph.h>
Inheritance diagram for PolymorphBase< T >:
This serves as a base type to Polymorph, to allow specializations of Polymorph to override some of this functionality.
Definition at line 40 of file polymorph.h.
Public Types | |
typedef T | value_type |
typedef PolymorphBase< value_type > | self |
Public Methods | |
PolymorphBase (const value_type val) | |
PolymorphBase (value_type *ptr) | |
virtual bool | operator< (const Typeless &o) const |
Polymorphic comparison operator. | |
virtual bool | operator> (const Typeless &o) const |
Polymorphic comparison operator. | |
bool | operator< (const self &o) const |
bool | operator> (const self &o) const |
bool | operator< (const value_type &o) const |
bool | operator> (const value_type &o) const |
self & | operator= (const value_type &o) |
Typeless & | set (const Typeless &o) |
Polymorphic assignment operator. | |
const value_type & | operator * () const |
value_type * | valueptr () const |
Returns a pointer to the underlying value; use with caution. | |
virtual string | stringrep (String::StreamFormat format=String::StreamFormat()) const |
Returns a string representation of the current value of this object. | |
virtual string | typestring () const |
Returns a string representation of the datatype of this object. | |
virtual Typeless * | parse (const StringParser &parser, const string &s) const |
Returns the result of parsing the given string with the given parser. | |
virtual Typeless * | clone () const |
Constructs an identical copy of self and returns it. | |
virtual Typeless * | duplicate () const |
Same as clone except that the result is guaranteed to have an independent copy of the underlying value. | |
Static Public Methods | |
void | set_typestring (const char *str) |
By default, typestring() returns the value of typeid().name() for a given type, which is implementation-dependent; for templates such as strings it is often very ugly. | |
Protected Attributes | |
AllocatingPointer< value_type > | p |
Static Protected Attributes | |
const char * | name_str = 0 |
|
Constructs an identical copy of self and returns it. Due to Cray C++'s variance from the C++ standard, cannot use actual type as the return value (or it wouldn't match the protype in Typeless.) Implements Typeless. Reimplemented in Polymorph< T >, and Polymorph< string >. Definition at line 98 of file polymorph.h. |
|
Returns the result of parsing the given string with the given parser. The actual type of the result is a Polymorph<value_type>, which is a derived type of this one. (Otherwise each derived specialization would need to replicate this routine, changing only the returned value's type.) Implements Typeless. Definition at line 87 of file polymorph.h. |
|
Polymorphic assignment operator. This version accepts identical types only. One could imagine supporting arbitrary types by printing the o value to a string and then parsing it into our type, but that would be pretty kludgy. In any case, the aborting assertion here should probably be eliminated somehow. Implements Typeless. Definition at line 162 of file polymorph.h. References PolymorphBase< T >::p. |
|
By default, typestring() returns the value of typeid().name() for a given type, which is implementation-dependent; for templates such as strings it is often very ugly. If the typestring is shown to the user, you can use this call to override the default with something prettier or possibly something domain-specific. Definition at line 79 of file polymorph.h. Referenced by cmdparam_init_hook(). |
|
Returns a string representation of the datatype of this object. The value is not guaranteed to be anything particularly useful, one cannot count on any implementation more specific than the one here. Reimplemented from Typeless. Definition at line 70 of file polymorph.h. |