lestes::lang::cplus::lex::encoder_ascii7 Class Reference

7 bit ASCII encoder. More...

#include <encoder_ascii7.hh>

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

lestes::lang::cplus::lex::encoder lestes::lang::cplus::lex::ucn_filter lestes::std::object lestes::std::mem::keystone List of all members.

Public Member Functions

ptr< ucn_tokenread (void)
 Reads next token.

Static Public Member Functions

static ptr< encoder_ascii7create (void)
 Returns new instance.

Protected Member Functions

 encoder_ascii7 (void)
 Creates the object.
virtual void gc_mark (void)
 Marks the object.

Private Member Functions

 encoder_ascii7 (const encoder_ascii7 &)
 Hides copy constructor.
encoder_ascii7operator= (const encoder_ascii7 &)
 Hides assignment operator.

Private Attributes

srp< ucn_tokenbad
 Flag of correctness of the stream and also eof token.

Detailed Description

7 bit ASCII encoder.

Performs encoding from 7 bit ASCII character set into internal source character set. Expects the input filter to return external characters in ASCII 7 bit, which are encoded into internal representation.

Definition at line 55 of file encoder_ascii7.hh.


Constructor & Destructor Documentation

lestes::lang::cplus::lex::encoder_ascii7::encoder_ascii7 ( void   )  [protected]

Creates the object.

Creates the encoder.

Definition at line 53 of file encoder_ascii7.cc.

Referenced by create().

00054 {
00055 }

lestes::lang::cplus::lex::encoder_ascii7::encoder_ascii7 ( const encoder_ascii7  )  [private]

Hides copy constructor.


Member Function Documentation

ptr< ucn_token > lestes::lang::cplus::lex::encoder_ascii7::read ( void   )  [virtual]

Reads next token.

Reads next token. Performs encoding from 7 bit ASCII character set. Checks whether the input contains valid characters. If error is encountered, it returns token with type ucn_token::TOK_ERROR.

Precondition:
Input into the filter is set.
Returns:
The next token encoded from 7 bit ASCII.

Token with type ucn_token::TOK_ERROR if the source character is invalid (out of range).

Token with type ucn_token::TOK_EOF in case of previous error.

Implements lestes::lang::cplus::lex::ucn_filter.

Definition at line 66 of file encoder_ascii7.cc.

References lestes::lang::cplus::lex::ucn_token::create_error(), lestes::lang::cplus::lex::ucn_filter::input_read(), lestes::lang::cplus::lex::invalid_ascii_character, and lestes::lang::cplus::lex::ucn_token::TOK_NOT_EOF.

00067 {
00068         ptr<ucn_token> t = input_read();
00069         ulint x = character::extract_value(t->value_get());
00070         ucn_token_type utt = t->type_get();
00071 
00072         if (utt == ucn_token::TOK_NOT_EOF) {
00073                 // check that the value is in range 0..127
00074                 if ((x & 0x7F) != x) {
00075                         // TODO report error: value out of range for ASCII
00076                         t = ucn_token::create_error(invalid_ascii_character->format());
00077                 } else {
00078                         // encode value in source charset
00079                         t = t->clone_value(character::create_internal(x));
00080                 }
00081         }
00082 
00083         return t;
00084 }

ptr< encoder_ascii7 > lestes::lang::cplus::lex::encoder_ascii7::create ( void   )  [static]

Returns new instance.

Returns new instance of the encoder.

Returns:
The new instance.

Definition at line 99 of file encoder_ascii7.cc.

References encoder_ascii7().

Referenced by lestes::lang::cplus::lex::evaluator::push_stream().

00100 {
00101         return new encoder_ascii7();
00102 }

void lestes::lang::cplus::lex::encoder_ascii7::gc_mark ( void   )  [protected, virtual]

Marks the object.

Marks the object.

Reimplemented from lestes::lang::cplus::lex::ucn_filter.

Definition at line 89 of file encoder_ascii7.cc.

References bad, and lestes::lang::cplus::lex::ucn_filter::gc_mark().

00090 {
00091         bad.gc_mark();
00092         encoder::gc_mark();
00093 }

encoder_ascii7& lestes::lang::cplus::lex::encoder_ascii7::operator= ( const encoder_ascii7  )  [private]

Hides assignment operator.


Member Data Documentation

srp<ucn_token> lestes::lang::cplus::lex::encoder_ascii7::bad [private]

Flag of correctness of the stream and also eof token.

Definition at line 68 of file encoder_ascii7.hh.

Referenced by gc_mark().


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