BrailleTutorNS::Charset Class Reference

A two-way mapping between cell dot patterns and Unicode letters/strings. More...

#include <Charset.h>

Collaboration diagram for BrailleTutorNS::Charset:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Charset (const GlyphMapping &my_name)
 Constructor. Creates a new empty mapping.
void clear ()
 Clear out the entire mapping.
unsigned int size ()
 The number of entries in this mapping.
const GlyphMappinggetName () const
 Retrieve the name of this character set.
void setName (const GlyphMapping &my_name)
 Set the name of this character set.
void set (const unsigned char &dots, const GlyphMapping &letter)
 Set or reset an individual mapping.
const GlyphMappingoperator[] (const unsigned char &dots) const
 Retrieve the letter onto which the dot pattern argument is mapped.
const unsigned char & operator[] (const GlyphMapping &letter) const
 Retrieve the dot pattern onto which the letter argument is mapped.
DotsMirror mir () const
 Facilitates lookup/retrieval of mirrored dot patterns.
std::vector
< unsigned int > 
read (std::istream &in)
std::vector
< unsigned int > 
read (const std::string &filename)
void write (std::ostream &out) const
 Write a mapping to a UTF-8 output stream.
void write (const std::string &filename) const

Static Public Member Functions

static Charset fromStream (std::istream &in)
static Charset fromFile (const std::string &filename)
static const CharsetdefaultCharset ()
 Returns const reference to a default character set.


Detailed Description

A two-way mapping between cell dot patterns and Unicode letters/strings.

Contains a two-way mapping between cell dot patterns and Unicode letters/strings represented by the patterns. Note that Unicode strings will be truncated to a fixed length in IOEvent objects.


Member Function Documentation

static Charset BrailleTutorNS::Charset::fromStream ( std::istream &  in  )  [inline, static]

Named constructor. Loads a character set from a wide input stream. Errors are silently ignored.

static Charset BrailleTutorNS::Charset::fromFile ( const std::string &  filename  )  [inline, static]

Named constructor. Loads a character set from a file. Errors are silently ignored.

void BrailleTutorNS::Charset::set ( const unsigned char &  dots,
const GlyphMapping letter 
)

Set or reset an individual mapping.

Sets or resets an individual mapping. To clear out a mapping, either set the first parameter to INVALID_DOTS or the second parameter to the empty GlyphMapping (e.g. GlyphMapping()).

const GlyphMapping& BrailleTutorNS::Charset::operator[] ( const unsigned char &  dots  )  const [inline]

Retrieve the letter onto which the dot pattern argument is mapped.

Retrieve the letter onto which the dot pattern argument is mapped. An empty GlyphMapping indicates that there is no letter for the dot pattern.

const unsigned char& BrailleTutorNS::Charset::operator[] ( const GlyphMapping letter  )  const [inline]

Retrieve the dot pattern onto which the letter argument is mapped.

Retrieve the dot pattern onto which the letter argument is mapped. The value INVALID_DOTS indicates that no such mapping exists.

DotsMirror BrailleTutorNS::Charset::mir (  )  const

Facilitates lookup/retrieval of mirrored dot patterns.

On the Braille Tutor, braille cell dot patterns are mirrored about the vertical axis. This routine facilitates dot pattern <-> Unicode string conversion (i.e. the operator[] operations) with the dot patterns mirrored. The calling convention for this routine is like so:

See also IOEvent.cc in the library source for examples.

std::vector<unsigned int> BrailleTutorNS::Charset::read ( std::istream &  in  ) 

Load a mapping from a UTF-8 input stream. Returns line numbers where errors were encountered.

std::vector<unsigned int> BrailleTutorNS::Charset::read ( const std::string &  filename  ) 

Load a mapping from a file. Returns line numbers where errors were encountered. For portability, only throws BT_EIO BTExceptions.

void BrailleTutorNS::Charset::write ( const std::string &  filename  )  const

Write a mapping to a file. For portability, only throws BT_EIO BTExceptions.


The documentation for this class was generated from the following file:
Generated on Fri Nov 16 14:50:26 2007 for Braille Tutor Interface Library by  doxygen 1.5.3