Jpp  18.3.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | List of all members
JLANG::JTypeInfo Class Reference

This class is a wrapper around the STL type_info class. More...

#include <JTypeInfo.hh>

Inheritance diagram for JLANG::JTypeInfo:
JLANG::JComparable< JTypeInfo >

Public Member Functions

 JTypeInfo ()
 Default constructor. More...
 
 JTypeInfo (const std::type_info &type)
 Constructor. More...
 
const std::type_info & get () const
 Get type information. More...
 
bool less (const JTypeInfo &that) const
 Less than operation. More...
 
bool before (const JTypeInfo &type) const
 Evaluate order. More...
 
const char * name () const
 Get type name. More...
 

Private Attributes

const std::type_info * pType
 

Detailed Description

This class is a wrapper around the STL type_info class.

It is possible to create a list of objects of this class.

Source code is taken from reference: A. Alexandrescu, Modern C++ Design, Addison Wesley.

Definition at line 27 of file JTypeInfo.hh.

Constructor & Destructor Documentation

JLANG::JTypeInfo::JTypeInfo ( )
inline

Default constructor.

Definition at line 34 of file JTypeInfo.hh.

35  {
36  class JNullType {};
37 
38  pType = &typeid(JNullType);
39  }
Auxiliary class for no type definition.
Definition: JNullType.hh:19
const std::type_info * pType
Definition: JTypeInfo.hh:102
JLANG::JTypeInfo::JTypeInfo ( const std::type_info &  type)
inline

Constructor.

Parameters
typetype information

Definition at line 47 of file JTypeInfo.hh.

47  :
48  pType(&type)
49  {}
const std::type_info * pType
Definition: JTypeInfo.hh:102

Member Function Documentation

const std::type_info& JLANG::JTypeInfo::get ( ) const
inline

Get type information.

Returns
type information

Definition at line 57 of file JTypeInfo.hh.

58  {
59  if (pType == NULL)
60  THROW(JTypeInformationException, "No type information.");
61  else
62  return *pType;
63  }
Exception for absence of type information.
Definition: JException.hh:646
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
const std::type_info * pType
Definition: JTypeInfo.hh:102
bool JLANG::JTypeInfo::less ( const JTypeInfo that) const
inline

Less than operation.

Parameters
thatobject to be compared
Returns
true if this type information less than that type information; else false

Definition at line 72 of file JTypeInfo.hh.

73  {
74  return get().before(that.get()) != 0;
75  }
bool before(const JTypeInfo &type) const
Evaluate order.
Definition: JTypeInfo.hh:84
const std::type_info & get() const
Get type information.
Definition: JTypeInfo.hh:57
bool JLANG::JTypeInfo::before ( const JTypeInfo type) const
inline

Evaluate order.

Parameters
typetype information
Returns
true if this type before given type; else false

Definition at line 84 of file JTypeInfo.hh.

85  {
86  return get().before(type.get()) != 0;
87  }
bool before(const JTypeInfo &type) const
Evaluate order.
Definition: JTypeInfo.hh:84
const std::type_info & get() const
Get type information.
Definition: JTypeInfo.hh:57
const char* JLANG::JTypeInfo::name ( ) const
inline

Get type name.

Returns
type name

Definition at line 95 of file JTypeInfo.hh.

96  {
97  return get().name();
98  }
const char * name() const
Get type name.
Definition: JTypeInfo.hh:95

Member Data Documentation

const std::type_info* JLANG::JTypeInfo::pType
private

Definition at line 102 of file JTypeInfo.hh.


The documentation for this class was generated from the following file: