Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

AlphIO.cpp

Go to the documentation of this file.
00001 // AlphIO.cpp
00002 //
00004 //
00005 // Copyright (c) 2002 Iain Murray
00006 //
00008 
00009 
00010 
00011 #include "AlphIO.h"
00012 
00013 using namespace Dasher;
00014 using namespace std;
00015 
00016 CAlphIO::CAlphIO(string SystemLocation, string UserLocation)
00017         : BlankInfo(), 
00018           SystemLocation(SystemLocation), 
00019           UserLocation(UserLocation),
00020           CData("")
00021 {
00022         CreateDefault();
00023 }
00024 
00025 
00026 void CAlphIO::GetAlphabets(std::vector< std::string > * AlphabetList) const
00027 {
00028         AlphabetList->clear();
00029         
00030         typedef std::map<std::string, AlphInfo>::const_iterator CI;
00031         CI End = Alphabets.end();
00032         
00033         for (CI Cur=Alphabets.begin(); Cur!=End; Cur++)
00034                 AlphabetList->push_back( (*Cur).second.AlphID);
00035 }
00036 
00037 
00038 const CAlphIO::AlphInfo& CAlphIO::GetInfo(const std::string& AlphID)
00039 {
00040         if (AlphID=="")
00041                 return Alphabets["Default"];
00042         else {
00043                 // AlphInfo& CurInfo = Alphabets[AlphID];
00044                 Alphabets[AlphID].AlphID = AlphID; // Ensure consistency
00045                 return Alphabets[AlphID];
00046         }
00047 }
00048 
00049 
00050 void CAlphIO::SetInfo(const AlphInfo& NewInfo)
00051 {
00052         Alphabets[NewInfo.AlphID] = NewInfo;
00053 }
00054 
00055 
00056 void CAlphIO::Delete(const std::string& AlphID)
00057 {
00058         if (Alphabets.find(AlphID)!=Alphabets.end()) {
00059                 Alphabets.erase(AlphID);
00060         }
00061 }
00062 
00063 
00064 void CAlphIO::CreateDefault()
00065 {
00066         // TODO I appreciate these strings should probably be in a resource file.
00067         // Not urgent though as this is not intended to be used. It's just a
00068         // last ditch effort in case file I/O totally fails.
00069         AlphInfo& Default = Alphabets["Default"];
00070         Default.AlphID = "Default";
00071         Default.Type = Opts::Western;
00072         Default.Mutable = false;
00073         Default.Orientation = Opts::LeftToRight;
00074         Default.SpaceCharacter.Display = "_";
00075         Default.SpaceCharacter.Text = " ";
00076         Default.TrainingFile = "training_english_GB.txt";
00077         string Chars = "abcdefghijklmnopqrstuvwxyz";
00078         Default.Groups.resize(1);
00079         Default.Groups[0].Description = "Lower case Latin letters";
00080         Default.Groups[0].Characters.resize(Chars.size());
00081         for (unsigned int i=0; i<Chars.size(); i++) {
00082                 Default.Groups[0].Characters[i].Text = Chars[i];
00083                 Default.Groups[0].Characters[i].Display = Chars[i];
00084         }
00085 }

Generated on Sat Nov 5 16:16:00 2005 for OPIE by  doxygen 1.4.2