00001 // Alphabet.h 00002 // 00004 // Alphabet.h 00005 // 00007 // 00008 // Copyright (c) 2001-2002 David Ward 00009 // 00011 00012 #ifndef __DASHER_ALPHABET_H__ 00013 #define __DASHER_ALPHABET_H__ 00014 00015 00016 #include "DasherTypes.h" 00017 00018 #include "MSVC_Unannoy.h" 00019 #include <map> 00020 #include <vector> 00021 #include "AlphabetMap.h" 00022 00023 00024 namespace Dasher {class CAlphabet;} 00025 class Dasher::CAlphabet 00026 { 00027 public: 00028 CAlphabet(); 00029 ~CAlphabet() {} 00030 00031 int GetNumberSymbols() const { return m_Characters.size();} // return size of alphabet 00032 00033 Opts::ScreenOrientations GetOrientation() {return m_Orientation;} 00034 Opts::AlphabetTypes GetType() {return m_DefaultEncoding;} 00035 std::string& GetTrainingFile() {return m_TrainingFile;} 00036 00037 symbol GetSpaceSymbol() {return m_SpaceSymbol;} 00038 const std::string& GetDisplayText(symbol i) const {return m_Display[i];} // return display string for i'th symbol 00039 const std::string& GetText(symbol i) const {return m_Characters[i];} // return string for i'th symbol 00040 const std::string& GetColour(symbol i) const {return m_Colours[i];} // return the colour for i'th symbol 00041 int GetTextColour(symbol i); // return the foreground colour for i'th symbol 00042 const std::string& GetForeground(symbol i) const {return m_Foreground[i];} // return the foreground colour for i'th symbol 00043 int get_group(symbol i) const {return m_Group[i];} // return group membership of i'th symbol 00044 00045 // Fills Symbols with the symbols corresponding to Input. {{{ Note that this 00046 // is not necessarily reversible by repeated use of GetText. Some text 00047 // may not be recognised and so discarded. If IsMore is true then Input 00048 // is truncated to any final characters that were not used due to ambiguous 00049 // continuation. If IsMore is false Input is assumed to be all the available 00050 // text and so a symbol will be returned for a final "a" even if "ae" is 00051 // defined as its own symbol. }}} 00052 void GetSymbols(std::vector<symbol>* Symbols, std::string* Input, bool IsMore); 00053 00054 void dump() const; // diagnostic 00055 00056 protected: 00057 // Add the characters that can appear in Nodes 00058 void AddChar(const std::string NewCharacter, const std::string Display, const std::string Colour, const std::string Foreground); // add single char to the alphabet 00059 void StartNewGroup(); 00060 00061 // Alphabet language parameters 00062 void SetSpaceSymbol() {m_SpaceSymbol=m_Characters.size()-1;} // We can set the space symbol to be the last character added 00063 void SetSpaceSymbol(symbol SpaceSymbol) {m_SpaceSymbol=SpaceSymbol;} // ...or any desired symbol. 00064 void SetOrientation(Opts::ScreenOrientations Orientation) {m_Orientation=Orientation;} 00065 void SetLanguage(Opts::AlphabetTypes Group) {m_DefaultEncoding=Group;} 00066 void SetTrainingFile(std::string TrainingFile) {m_TrainingFile=TrainingFile;} 00067 private: 00068 Opts::AlphabetTypes m_DefaultEncoding; 00069 Opts::ScreenOrientations m_Orientation; 00070 symbol m_SpaceSymbol; 00071 std::string m_TrainingFile; 00072 00073 std::vector<std::string> m_Characters; // stores the characters 00074 std::vector<std::string> m_Display; // stores how the characters are visually represented in the Dasher nodes 00075 std::vector<std::string> m_Colours; // stores the colour of the characters 00076 std::vector<std::string> m_Foreground; // stores the colour of the character foreground 00077 std::vector<int> m_Group; // stores the group indicators - e.g. caps, numbers, punctuation 00078 int m_Groups; // number of groups 00079 alphabet_map TextMap; 00080 }; 00081 00082 00083 #endif // ifndef __DASHER_ALPHABET_H__
1.4.2