lestes::lang::cplus::lex::token_value Class Reference

Token value. More...

#include <token_value.hh>

Inheritance diagram for lestes::lang::cplus::lex::token_value:

lestes::std::object lestes::std::mem::keystone List of all members.

Public Types

typedef ucn_string content_type
 Type of content.

Public Member Functions

ucn_string content_get (void) const
 Returns content.
bool equals (const ptr< token_value > &other) const
 Tests equality.
bool less_than (const ptr< token_value > &other) const
 Tests inequality.
ulint hash (void) const
 returns hash of the content

Static Public Member Functions

static ptr< token_valuecreate (const content_type &a_content)
 Returns object initialized with content.

Private Types

typedef ::lestes::std::map<
content_type, srp< token_value >,
compare_content
shared_type
 Type of structure for sharing instances.

Private Member Functions

 token_value (const content_type &a_content)
 Creates object with content.

Private Attributes

content_type content
 The representation of the value.

Static Private Attributes

static ptr< shared_typeshared = token_value::shared_type::create()
 Structure for sharing instances.

Classes

struct  compare_content
 Less than comparator. More...
struct  compare_less
 Less than comparator for token_value. More...

Detailed Description

Token value.

Represents token value, wrapping ucn_string. The object is constant and shared.

Definition at line 51 of file token_value.hh.


Member Typedef Documentation

typedef ucn_string lestes::lang::cplus::lex::token_value::content_type

Type of content.

Definition at line 54 of file token_value.hh.

typedef ::lestes::std::map<content_type,srp<token_value>,compare_content> lestes::lang::cplus::lex::token_value::shared_type [private]

Type of structure for sharing instances.

Definition at line 80 of file token_value.hh.


Constructor & Destructor Documentation

lestes::lang::cplus::lex::token_value::token_value ( const content_type a_content  )  [private]

Creates object with content.

Constructs object, initializes with a_content.

Postcondition:
is_equal(content,a_content)
Parameters:
a_content The initialization value.

Definition at line 46 of file token_value.cc.

00046                                                      :
00047         content(a_content)
00048 {
00049 }


Member Function Documentation

ptr< token_value > lestes::lang::cplus::lex::token_value::create ( const content_type a_content  )  [static]

Returns object initialized with content.

Returns new token value, initializes with a_content.

Parameters:
a_content The initialization value.

Definition at line 56 of file token_value.cc.

References shared.

Referenced by lestes::lang::cplus::lex::ucn_token_buffer::extract_bad_literal(), lestes::lang::cplus::lex::ucn_token_buffer::extract_invalid_ucn(), lestes::lang::cplus::lex::ucn_token_buffer::extract_ordinary(), lestes::lang::cplus::lex::ucn_token_buffer::extract_simple_ucn(), lestes::lang::cplus::lex::ucn_token_buffer::extract_ucn_literal(), lestes::lang::cplus::lex::ucn_token_buffer::extract_until(), lestes::lang::cplus::lex::string_joiner::join_sequence(), lestes::lang::cplus::lex::evaluator::parse_include(), lestes::lang::cplus::lex::macro::parse_name(), lestes::lang::cplus::lex::stringifier::process(), lestes::lang::cplus::lex::concat::process(), lestes::lang::cplus::lex::evaluator::process_directive(), lestes::lang::cplus::lex::preprocessor::read(), and lestes::lang::cplus::lex::string_translator::translate().

00057 {
00058         // singleton-like factory
00059         shared_type::iterator it = shared->find(a_content);
00060         if (it != shared->end()) return (*it).second;
00061         ptr<token_value> nju = new token_value(a_content);
00062         shared->insert(shared_type::value_type(a_content,nju));
00063         return nju;
00064         // TODO pt remove return ptr<token_value>(new token_value(a_content));
00065 }

token_value::content_type lestes::lang::cplus::lex::token_value::content_get ( void   )  const

Returns content.

Returns content of value object.

Returns:
The content of the object.

Definition at line 81 of file token_value.cc.

References content.

Referenced by less_than().

00082 {
00083         return content;
00084 }

bool lestes::lang::cplus::lex::token_value::equals ( const ptr< token_value > &  other  )  const

Tests equality.

Tests equality. Because of sharing instances, only pointers are compared.

Parameters:
other The token value to compare to.
Returns:
true If both contents are equal.

Definition at line 72 of file token_value.cc.

00073 {
00074         return other == this;
00075 }

bool lestes::lang::cplus::lex::token_value::less_than ( const ptr< token_value > &  other  )  const

Tests inequality.

Compares to other token value. The content is compared with < operator.

Parameters:
other The token value to compare.
Returns:
true If the other is not null and the content compares less.

Definition at line 101 of file token_value.cc.

References content_get(), and lestes::is_less().

00102 {
00103         return other && is_less(content_get(),other->content_get());
00104 }

ulint lestes::lang::cplus::lex::token_value::hash ( void   )  const

returns hash of the content

Returns hash value of content.

Returns:
The hash value.

Definition at line 90 of file token_value.cc.

00091 {
00092         // TODO compute hash from content
00093         return 0;
00094 }


Member Data Documentation

content_type lestes::lang::cplus::lex::token_value::content [private]

The representation of the value.

Definition at line 74 of file token_value.hh.

Referenced by content_get().

ptr< token_value::shared_type > lestes::lang::cplus::lex::token_value::shared = token_value::shared_type::create() [static, private]

Structure for sharing instances.

Structure for sharing instances of token value having the same content.

Definition at line 83 of file token_value.hh.

Referenced by create().


The documentation for this class was generated from the following files:
Generated on Mon Feb 12 18:24:19 2007 for lestes by doxygen 1.5.1-20070107