[dasher: 18/43] RM AlphIO/ColourIO output functions (Delete, SetInfo, Save) + DashIntf wrappers



commit 4b495b0e32d48e6985ca2b382e59bbc0a0680860
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date:   Mon Jun 13 18:24:54 2011 +0100

    RM AlphIO/ColourIO output functions (Delete, SetInfo, Save) + DashIntf wrappers
    
    As they are "No longer supported", not called, claim to be broken, and atm
     there are no plans to reimplement Alphabet/Colour-scheme editing within Dasher.

 Src/DasherCore/Alphabet/AlphIO.cpp     |  178 +-------------------------------
 Src/DasherCore/Alphabet/AlphIO.h       |   12 +--
 Src/DasherCore/ColourIO.cpp            |   36 +------
 Src/DasherCore/ColourIO.h              |    8 +--
 Src/DasherCore/DasherInterfaceBase.cpp |    8 --
 Src/DasherCore/DasherInterfaceBase.h   |   15 ---
 6 files changed, 6 insertions(+), 251 deletions(-)
---
diff --git a/Src/DasherCore/Alphabet/AlphIO.cpp b/Src/DasherCore/Alphabet/AlphIO.cpp
index a9fdc1e..5339bd3 100644
--- a/Src/DasherCore/Alphabet/AlphIO.cpp
+++ b/Src/DasherCore/Alphabet/AlphIO.cpp
@@ -36,8 +36,8 @@ static char THIS_FILE[] = __FILE__;
 #endif
 #endif
 
-CAlphIO::CAlphIO(std::string SystemLocation, std::string UserLocation, std::vector<std::string> &Filenames)
-: SystemLocation(SystemLocation), UserLocation(UserLocation), Filenames(Filenames), LoadMutable(false), CData("") {
+CAlphIO::CAlphIO(const std::string &SystemLocation, const std::string &UserLocation, const std::vector<std::string> &Filenames)
+: LoadMutable(false), CData("") {
   Alphabets["Default"]=CreateDefault();
 
   typedef pair < Opts::AlphabetTypes, std::string > AT;
@@ -115,180 +115,6 @@ const CAlphInfo *CAlphIO::GetInfo(const std::string &AlphID) {
   }
 }
 
-void CAlphIO::SetInfo(const CAlphInfo *NewInfo) {
-  Alphabets[NewInfo->AlphID] = NewInfo;
-  Save(NewInfo->AlphID);
-}
-
-void CAlphIO::Delete(const std::string &AlphID) {
-  map<std::string, const CAlphInfo *>::iterator it = Alphabets.find(AlphID);
-  if(it != Alphabets.end()) {
-    delete it->second;
-    Alphabets.erase(it);
-    Save("");
-  }
-}
-
-void CAlphIO::Save(const std::string &AlphID) {
-  // TODO: We cannot reliably output XML at the moment this will have
-  // to be re-implemented if we ever decide that we need to do this
-  // again
-
-
-  // Write an XML file containing all the alphabets that have been defined.
-  // I am not going to indent the XML file as it will just bloat it, and it
-  // is very simple. There are line breaks though as it is very hard to read
-  // without. I'm going to ignore AlphID and save all alphabets as the
-  // overhead doesn't seem to matter and it makes things much easier.
-  char Number[sizeof(int)];
-  FILE *Output;
-  std::string Filename = UserLocation + "alphabet.xml";
-  if((Output = fopen(Filename.c_str(), "w")) == (FILE *) 0) {
-    // could not open file
-  }
-
-  fwrite("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", sizeof(char), 39, Output);
-  fwrite("<!DOCTYPE alphabets SYSTEM \"alphabet.dtd\">\n", sizeof(char), 43, Output);
-  fwrite("<?xml-stylesheet type=\"text/xsl\" href=\"alphabet.xsl\"?>\n", sizeof(char), 55, Output);
-  fwrite("<alphabets>\n", sizeof(char), 12, Output);
-
-  typedef std::map < std::string, const CAlphInfo * >::const_iterator CI;
-  CI End = Alphabets.end();
-  for(CI Cur = Alphabets.begin(); Cur != End; Cur++) {
-    CAlphInfo Info = *(Cur->second);      // Take a copy so that special characters can be escaped
-
-    if(Info.Mutable == false)   // this is a system alphabet, not one we write
-      continue;
-
-    fwrite("<alphabet name=\"", sizeof(char), 16, Output);
-    XML_Escape(Info.AlphID, true);
-    fwrite(Info.AlphID.c_str(), sizeof(char), Info.AlphID.size(), Output);
-    fwrite("\">\n", sizeof(char), 3, Output);
-
-    fwrite("<orientation type=\"", sizeof(char), 19, Output);
-    switch (Info.Orientation) {
-    case Opts::RightToLeft:
-      fwrite("RL", sizeof(char), 2, Output);
-      break;
-    case Opts::TopToBottom:
-      fwrite("TB", sizeof(char), 2, Output);
-      break;
-    case Opts::BottomToTop:
-      fwrite("BT", sizeof(char), 2, Output);
-      break;
-    case Opts::LeftToRight:
-      // deliberate fall through
-    default:
-      fwrite("LR", sizeof(char), 2, Output);
-      break;
-    }
-    fwrite("\"/>\n", sizeof(char), 4, Output);
-
-    // TODO Encoding properly
-    fwrite("<encoding type=\"", sizeof(char), 16, Output);
-    fwrite(TtoS[Info.Type].c_str(), sizeof(char), TtoS[Info.Type].size(), Output);
-    fwrite("\"/>\n", sizeof(char), 4, Output);
-
-    fwrite("<palette>", sizeof(char), 9, Output);
-    XML_Escape(Info.PreferredColours, false);
-    fwrite(Info.PreferredColours.c_str(), sizeof(char), Info.PreferredColours.size(), Output);
-    fwrite("</palette>\n", sizeof(char), 11, Output);
-
-    fwrite("<train>", sizeof(char), 7, Output);
-    XML_Escape(Info.TrainingFile, false);
-    fwrite(Info.TrainingFile.c_str(), sizeof(char), Info.TrainingFile.size(), Output);
-    fwrite("</train>\n", sizeof(char), 9, Output);
-
-    fwrite("<gamemode>", sizeof(char), 10, Output);
-    XML_Escape(Info.GameModeFile, false);
-    fwrite(Info.GameModeFile.c_str(), sizeof(char), Info.GameModeFile.size(), Output);
-    fwrite("</gamemode>\n", sizeof(char), 12, Output);
-
-    //TODO presumably should write out characters & groups at some point?!
-    // In which case, must exclude para/space, as these written out here:
-
-    // Write out the space character
-    if (Info.iSpaceCharacter!=0) {
-      CAlphInfo::character &spC(Info.m_vCharacters[Info.iSpaceCharacter]);
-      fwrite("<space d=\"", sizeof(char), 10, Output);
-      XML_Escape(spC.Display, true);
-      fwrite(spC.Display.c_str(), sizeof(char), spC.Display.size(), Output);
-      fwrite("\" t=\"", sizeof(char), 5, Output);
-      XML_Escape(spC.Text, true);
-      fwrite(spC.Text.c_str(), sizeof(char), spC.Text.size(), Output);
-      fwrite("\" b=\"", sizeof(char), 5, Output);
-      sprintf(Number, "%d", spC.Colour);
-      fwrite(Number, sizeof(char), strlen(Number), Output);
-      fwrite("\"/>\n", sizeof(char), 4, Output);
-    }
-
-    // Write out the paragraph character
-    if (Info.iParagraphCharacter!=-1) {
-      CAlphInfo::character para(Info.m_vCharacters[Info.iParagraphCharacter]);
-      fwrite("<paragraph d=\"", sizeof(char), 14, Output);
-      XML_Escape(para.Display, true);
-      fwrite(para.Display.c_str(), sizeof(char), para.Display.size(), Output);
-      fwrite("\" t=\"", sizeof(char), 5, Output);
-      XML_Escape(para.Text, true);
-      fwrite(para.Text.c_str(), sizeof(char), para.Text.size(), Output);
-      fwrite("\" b=\"", sizeof(char), 5, Output);
-      sprintf(Number, "%d", para.Colour);
-      fwrite(Number, sizeof(char), strlen(Number), Output);
-      fwrite("\"/>\n", sizeof(char), 4, Output);
-    }
-
-    // Write out the control character
-    if (Info.ControlCharacter) {
-      fwrite("<control d=\"", sizeof(char), 12, Output);
-      XML_Escape(Info.ControlCharacter->Display, true);
-      fwrite(Info.ControlCharacter->Display.c_str(), sizeof(char), Info.ControlCharacter->Display.size(), Output);
-      fwrite("\" t=\"", sizeof(char), 5, Output);
-      XML_Escape(Info.ControlCharacter->Text, true);
-      fwrite(Info.ControlCharacter->Text.c_str(), sizeof(char), Info.ControlCharacter->Text.size(), Output);
-      fwrite("\" b=\"", sizeof(char), 5, Output);
-      sprintf(Number, "%d", Info.ControlCharacter->Colour);
-      fwrite(Number, sizeof(char), strlen(Number), Output);
-      fwrite("\"/>\n", sizeof(char), 4, Output);
-    }
-
-    //    typedef vector < AlphInfo::group >::iterator gi;
-//     gi LG = Info.Groups.end();
-//     for(gi CG = Info.Groups.begin(); CG != LG; CG++) {
-//       fwrite("<group name=\"", sizeof(char), 13, Output);
-//       XML_Escape(CG->Description, true);
-//       fwrite(CG->Description.c_str(), sizeof(char), CG->Description.size(), Output);
-//       fwrite("\" b=\"", sizeof(char), 5, Output);
-//       sprintf(Number, "%d", CG->Colour);
-//       fwrite(Number, sizeof(char), strlen(Number), Output);
-//       fwrite("\">\n", sizeof(char), 3, Output);
-
-//       // Iterate over CG->Characters
-//       typedef vector < AlphInfo::character >::iterator ci;
-//       ci LC = CG->Characters.end();
-//       for(ci CC = CG->Characters.begin(); CC != LC; CC++) {
-//         fwrite("<s d=\"", sizeof(char), 6, Output);
-//         XML_Escape(CC->Display, true);
-//         fwrite(CC->Display.c_str(), sizeof(char), CC->Display.size(), Output);
-//         fwrite("\" t=\"", sizeof(char), 5, Output);
-//         XML_Escape(CC->Text, true);
-//         fwrite(CC->Text.c_str(), sizeof(char), CC->Text.size(), Output);
-//         fwrite("\" b=\"", sizeof(char), 5, Output);
-//         sprintf(Number, "%d", CC->Colour);
-//         fwrite(Number, sizeof(char), strlen(Number), Output);
-//         fwrite("\"/>\n", sizeof(char), 4, Output);
-//       }
-
-//       fwrite("</group>\n", sizeof(char), 9, Output);
-//     }
-
-    fwrite("</alphabet>\n", sizeof(char), 12, Output);
-  }
-
-  fwrite("</alphabets>\n", sizeof(char), 13, Output);
-
-  fclose(Output);
-}
-
 CAlphInfo *CAlphIO::CreateDefault() {
   // TODO I appreciate these strings should probably be in a resource file.
   // Not urgent though as this is not intended to be used. It's just a
diff --git a/Src/DasherCore/Alphabet/AlphIO.h b/Src/DasherCore/Alphabet/AlphIO.h
index 092a6dd..cd47489 100644
--- a/Src/DasherCore/Alphabet/AlphIO.h
+++ b/Src/DasherCore/Alphabet/AlphIO.h
@@ -47,29 +47,19 @@ namespace Dasher {
 /// object per alphabet at this time, and stores them in a map from AlphID
 /// string until shutdown/destruction. (CAlphIO is a friend of CAlphInfo,
 /// so can create/manipulate instances.)
-///
-/// Note the alphabet-management functions (SetInfo, Delete, Save, and
-/// hence the mutability of alphabets loaded) don't seem to be fully
-/// implemented...
 class Dasher::CAlphIO : private AbstractXMLParser {
 public:
 
-  CAlphIO(std::string SystemLocation, std::string UserLocation, std::vector < std::string > &Filenames);
+  CAlphIO(const std::string &SystemLocation, const std::string &UserLocation, const std::vector < std::string > &Filenames);
   ~CAlphIO();
   void GetAlphabets(std::vector < std::string > *AlphabetList) const;
   std::string GetDefault();
   const CAlphInfo *GetInfo(const std::string & AlphID);
-  void SetInfo(const CAlphInfo *NewInfo);
-  void Delete(const std::string & AlphID);
 private:
   CAlphInfo::character *SpaceCharacter, *ParagraphCharacter;
   std::vector<SGroupInfo *> m_vGroups;
-  std::string SystemLocation;
-  std::string UserLocation;
   std::map < std::string, const CAlphInfo* > Alphabets; // map short names (file names) to descriptions. We own all the values but it's easier this way...
-  std::vector < std::string > Filenames;
 
-  void Save(const std::string & AlphID);
   CAlphInfo *CreateDefault();         // Give the user an English alphabet rather than nothing if anything goes horribly wrong.
 
   void DeleteAlphabet(CAlphInfo *Alphabet);
diff --git a/Src/DasherCore/ColourIO.cpp b/Src/DasherCore/ColourIO.cpp
index fff8658..1b68df1 100644
--- a/Src/DasherCore/ColourIO.cpp
+++ b/Src/DasherCore/ColourIO.cpp
@@ -23,8 +23,8 @@ static char THIS_FILE[] = __FILE__;
 
 // TODO: Share information with AlphIO class?
 
-CColourIO::CColourIO(std::string SystemLocation, std::string UserLocation, std::vector<std::string> &Filenames)
-:BlankInfo(), SystemLocation(SystemLocation), UserLocation(UserLocation), Filenames(Filenames), LoadMutable(false), CData("") {
+CColourIO::CColourIO(const std::string &SystemLocation, const std::string &UserLocation, std::vector<std::string> &Filenames)
+:BlankInfo(), LoadMutable(false), CData("") {
   CreateDefault();
 
   LoadMutable = false;
@@ -68,38 +68,6 @@ const CColourIO::ColourInfo & CColourIO::GetInfo(const std::string &ColourID) {
   }
 }
 
-void CColourIO::SetInfo(const ColourInfo &NewInfo) {
-  Colours[NewInfo.ColourID] = NewInfo;
-  Save(NewInfo.ColourID);
-}
-
-void CColourIO::Delete(const std::string &ColourID) {
-  if(Colours.find(ColourID) != Colours.end()) {
-    Colours.erase(ColourID);
-    Save("");
-  }
-}
-
-void CColourIO::Save(const std::string &ColourID) {
-  // Write an XML file containing all the colours that have been defined.
-  // I am not going to indent the XML file as it will just bloat it, and it
-  // is very simple. There are line breaks though as it is very hard to read
-  // without. I'm going to ignore ColourID and save all alphabets as the
-  // overhead doesn't seem to matter and it makes things much easier.
-
-  FILE *Output;
-  std::string Filename = UserLocation + "colours.xml";
-  if((Output = fopen(Filename.c_str(), "w")) == (FILE *) 0) {
-    // could not open file
-  }
-
-  fwrite("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", sizeof(char), 39, Output);
-  fwrite("<!DOCTYPE alphabets SYSTEM \"colours.dtd\">\n", sizeof(char), 43, Output);
-  fwrite("<?xml-stylesheet type=\"text/xsl\" href=\"colours.xsl\"?>\n", sizeof(char), 55, Output);
-  fwrite("<colours>\n", sizeof(char), 12, Output);
-  fclose(Output);
-}
-
 void CColourIO::CreateDefault() {
   // TODO: Urgh - replace with a table
 
diff --git a/Src/DasherCore/ColourIO.h b/Src/DasherCore/ColourIO.h
index e77ba69..1d03e58 100644
--- a/Src/DasherCore/ColourIO.h
+++ b/Src/DasherCore/ColourIO.h
@@ -39,19 +39,13 @@ public:
     std::vector < int >Blues;
   };
 
-  CColourIO(std::string SystemLocation, std::string UserLocation, std::vector < std::string > &Filenames);
+  CColourIO(const std::string &SystemLocation, const std::string &UserLocation, std::vector < std::string > &Filenames);
   void GetColours(std::vector < std::string > *ColourList) const;
   const ColourInfo & GetInfo(const std::string & ColourID);
-  void SetInfo(const ColourInfo & NewInfo);
-  void Delete(const std::string & ColourID);
 private:
   ColourInfo BlankInfo;
-  std::string SystemLocation;
-  std::string UserLocation;
   std::map < std::string, ColourInfo > Colours; // map short names (file names) to descriptions
-  std::vector < std::string > Filenames;
 
-  void Save(const std::string & ColourID);
   void CreateDefault();         // Give the user a default colour scheme rather than nothing if anything goes horribly wrong.
 
   // XML handling:
diff --git a/Src/DasherCore/DasherInterfaceBase.cpp b/Src/DasherCore/DasherInterfaceBase.cpp
index 9bee70e..d8f045e 100644
--- a/Src/DasherCore/DasherInterfaceBase.cpp
+++ b/Src/DasherCore/DasherInterfaceBase.cpp
@@ -698,14 +698,6 @@ const CAlphInfo *CDasherInterfaceBase::GetInfo(const std::string &AlphID) {
   return m_AlphIO->GetInfo(AlphID);
 }
 
-void CDasherInterfaceBase::SetInfo(const CAlphInfo *NewInfo) {
-  m_AlphIO->SetInfo(NewInfo);
-}
-
-void CDasherInterfaceBase::DeleteAlphabet(const std::string &AlphID) {
-  m_AlphIO->Delete(AlphID);
-}
-
 double CDasherInterfaceBase::GetCurCPM() {
   //
   return 0;
diff --git a/Src/DasherCore/DasherInterfaceBase.h b/Src/DasherCore/DasherInterfaceBase.h
index 0d4de6b..f88c289 100644
--- a/Src/DasherCore/DasherInterfaceBase.h
+++ b/Src/DasherCore/DasherInterfaceBase.h
@@ -92,23 +92,8 @@ public:
     return m_pSettingsStore;
   }
 
-  ///
-  /// \deprecated In situ alphabet editing is no longer supported
-  /// \todo Document this
-  ///
-
   const CAlphInfo *GetInfo(const std::string & AlphID);
 
-  /// \todo Document this
-
-  void SetInfo(const CAlphInfo *NewInfo);
-
-  /// \todo Document this
-
-  void DeleteAlphabet(const std::string & AlphID);
-
-  /// Gets a pointer to the object doing user logging
-
   CUserLogBase* GetUserLogPtr();
 
   // @}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]