eliot-dev
[Top][All Lists]
Advanced

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

[Eliot-dev] eliot dic/dic.cpp dic/dic.h dic/dic_search.cpp ...


From: Olivier Teulière
Subject: [Eliot-dev] eliot dic/dic.cpp dic/dic.h dic/dic_search.cpp ...
Date: Fri, 03 Jul 2009 21:40:16 +0000

CVSROOT:        /cvsroot/eliot
Module name:    eliot
Changes by:     Olivier Teulière <ipkiss>       09/07/03 21:40:16

Modified files:
        dic            : dic.cpp dic.h dic_search.cpp header.cpp 
                         header.h regexpmain.cpp 
        game           : duplicate.cpp freegame.cpp move.h turn.cpp 
        qt             : dic_tools_widget.cpp play_word_mediator.cpp 
                         player_widget.cpp training_widget.cpp 
        utils          : eliottxt.cpp 

Log message:
         - Invalid moves should be in the display form
         - Moved some code from Header to Dictionary

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/dic.cpp?cvsroot=eliot&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/dic.h?cvsroot=eliot&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/dic_search.cpp?cvsroot=eliot&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/header.cpp?cvsroot=eliot&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/header.h?cvsroot=eliot&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/regexpmain.cpp?cvsroot=eliot&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/eliot/game/duplicate.cpp?cvsroot=eliot&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/eliot/game/freegame.cpp?cvsroot=eliot&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/eliot/game/move.h?cvsroot=eliot&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/eliot/game/turn.cpp?cvsroot=eliot&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/dic_tools_widget.cpp?cvsroot=eliot&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/play_word_mediator.cpp?cvsroot=eliot&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/player_widget.cpp?cvsroot=eliot&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/training_widget.cpp?cvsroot=eliot&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/eliot/utils/eliottxt.cpp?cvsroot=eliot&r1=1.37&r2=1.38

Patches:
Index: dic/dic.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/dic.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- dic/dic.cpp 27 Jun 2009 18:09:44 -0000      1.6
+++ dic/dic.cpp 3 Jul 2009 21:40:14 -0000       1.7
@@ -27,6 +27,7 @@
 #include <cstring>
 #include <cerrno>
 #include <cctype>
+#include <boost/foreach.hpp>
 
 // For ntohl & Co.
 #ifdef WIN32
@@ -51,7 +52,7 @@
 
 
 Dictionary::Dictionary(const string &iPath)
-    : m_dawg(NULL)
+    : m_dawg(NULL), m_hasDisplay(false)
 {
     ifstream file(iPath.c_str(), ios::in | ios::binary);
 
@@ -86,6 +87,31 @@
     std::transform(lower.begin(), lower.end(), lower.begin(), towlower);
     m_allInputChars = m_header->getInputChars() + lower;
 
+    // Build the cache for the convertToDisplay() and convertFromInput()
+    // methods.
+    map<wchar_t, vector<wstring> >::const_iterator it;
+    for (it = m_header->getDisplayInputData().begin();
+         it != m_header->getDisplayInputData().end(); ++it)
+    {
+        // Save both the upper case and lower case versions
+        BOOST_FOREACH(wstring str, it->second)
+        {
+            // Make sure the string is in uppercase
+            std::transform(str.begin(), str.end(), str.begin(), towupper);
+            // Make a lowercase copy
+            wstring lower = str;
+            std::transform(lower.begin(), lower.end(), lower.begin(), 
towlower);
+            // Fill the cache
+            m_displayInputCache[towupper(it->first)].push_back(str);
+            m_displayInputCache[towlower(it->first)].push_back(lower);
+        }
+
+        // Update the m_hasDisplay flag
+        if (!m_hasDisplay && it->second[0] != wstring(1, it->first))
+            m_hasDisplay = true;
+    }
+
+
     m_dic = this;
 }
 
@@ -137,6 +163,58 @@
 }
 
 
+wdstring Dictionary::convertToDisplay(const wstring &iWord) const
+{
+    // Optimization for dictionaries without display nor input chars,
+    // which is the case in most languages.
+    if (!m_hasDisplay)
+        return iWord;
+
+    wdstring dispStr = iWord;
+    map<wchar_t, vector<wstring> >::const_iterator it;
+    for (it = m_displayInputCache.begin();
+         it != m_displayInputCache.end(); ++it)
+    {
+        const wstring &disp = it->second[0];
+        string::size_type pos = 0;
+        while (pos < dispStr.size() &&
+               (pos = dispStr.find(it->first, pos)) != string::npos)
+        {
+            dispStr.replace(pos, 1, disp);
+            pos += disp.size();
+        }
+    }
+    return dispStr;
+}
+
+
+wstring Dictionary::convertFromInput(const wistring &iWord) const
+{
+    // Optimization for dictionaries without display nor input chars,
+    // which is the case in most languages.
+    if (m_displayInputCache.empty())
+        return iWord;
+
+    wstring str = iWord;
+    map<wchar_t, vector<wstring> >::const_iterator it;
+    for (it = m_displayInputCache.begin();
+         it != m_displayInputCache.end(); ++it)
+    {
+        BOOST_FOREACH(const wstring &input, it->second)
+        {
+            string::size_type pos = 0;
+            while (pos < str.size() &&
+                   (pos = str.find(input, pos)) != string::npos)
+            {
+                str.replace(pos, input.size(), wstring(1, it->first));
+                pos += input.size();
+            }
+        }
+    }
+    return str;
+}
+
+
 dic_elt_t Dictionary::getNext(const dic_elt_t &e) const
 {
      if (!isLast(e))

Index: dic/dic.h
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/dic.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- dic/dic.h   27 Jun 2009 18:09:44 -0000      1.24
+++ dic/dic.h   3 Jul 2009 21:40:15 -0000       1.25
@@ -54,6 +54,7 @@
  * a bit more precisely the type of contents of the string.
  */
 typedef wstring wdstring;
+typedef wstring wistring;
 
 class Dictionary
 {
@@ -102,6 +103,21 @@
     bool validateInputChars(const wstring &iLetters,
                             const wstring &iAccepted = L"") const;
 
+    /**
+     * Convert the given string (made of internal characters)
+     * into a string suitable for display
+     */
+    wdstring convertToDisplay(const wstring &iWord) const;
+
+    /**
+     * Convert the given string (direct user input)
+     * into a string suitable for internal use in Eliot.
+     * For example, in Catalan, it will convert the L.L substring
+     * into the W character (because it is the internal character
+     * associated to the input string "L.L").
+     */
+    wstring convertFromInput(const wistring &iWord) const;
+
     /** Return a vector containing one of each possible tile */
     const vector<Tile>& getAllTiles() const { return m_tilesVect; }
 
@@ -265,6 +281,25 @@
     /// Vector of available tiles
     vector<Tile> m_tilesVect;
 
+    /**
+     * Associate to some internal chars (both the lower case and
+     * upper case versions) all the corresponding input strings.
+     * The first one is always the display string.
+     *
+     * Note: only the chars which have more than 1 input string,
+     * or which have a display string different from the internal char,
+     * are present in the map.
+     */
+    map<wchar_t, vector<wstring> > m_displayInputCache;
+
+    /**
+     * True if at least one display strings is different from the internal
+     * char, false otherwise. This flag is more precise than checking the size
+     * of m_displayInputCache, because a tile can have input strings even if
+     * its display string is equal to the internal char.
+     */
+    bool m_hasDisplay;
+
     static const Dictionary *m_dic;
 
     void convertDataToArch();

Index: dic/dic_search.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/dic_search.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- dic/dic_search.cpp  23 Jun 2009 21:39:07 -0000      1.16
+++ dic/dic_search.cpp  3 Jul 2009 21:40:15 -0000       1.17
@@ -23,6 +23,7 @@
 #include <cstring>
 #include <cwchar>
 #include <cwctype>
+#include <algorithm>
 
 #include "dic_internals.h"
 #include "dic_exception.h"
@@ -104,7 +105,7 @@
                         // Add the solution
                         vector<wdstring> &sols = 
(*params.results)[params.added_display];
                         if (sols.empty() || sols.back() != 
params.search_wordtst)
-                            
sols.push_back(getHeader().convertToDisplay(params.search_wordtst));
+                            
sols.push_back(convertToDisplay(params.search_wordtst));
                     }
                 }
                 else
@@ -127,7 +128,7 @@
                         // Add the solution
                         vector<wdstring> &sols = 
(*params.results)[params.added_display];
                         if (sols.empty() || sols.back() != 
params.search_wordtst)
-                            
sols.push_back(getHeader().convertToDisplay(params.search_wordtst));
+                            
sols.push_back(convertToDisplay(params.search_wordtst));
                     }
                 }
                 else
@@ -230,7 +231,10 @@
         oWordList.reserve(DEFAULT_VECT_ALLOC);
 
     // Transform the given word to make it suitable for display
-    const wdstring &displayWord = getHeader().convertToDisplay(iWord);
+    wdstring displayWord = convertToDisplay(iWord);
+    // Make it uppercase
+    std::transform(displayWord.begin(), displayWord.end(),
+                   displayWord.begin(), towupper);
 
     // Try to add a letter at the front
     const wstring &letters = getHeader().getLetters();
@@ -238,8 +242,7 @@
     {
         if (searchWord(letters[i] + iWord))
         {
-            const wdstring &chr =
-                
getHeader().getDisplayStr(getHeader().getCodeFromChar(letters[i]));
+            const wdstring &chr = 
getHeader().getDisplayStr(getHeader().getCodeFromChar(letters[i]));
             oWordList.push_back(chr + displayWord);
         }
         if (iMaxResults && oWordList.size() >= iMaxResults)
@@ -283,7 +286,10 @@
         oWordList.reserve(DEFAULT_VECT_ALLOC);
 
     // Transform the given word to make it suitable for display
-    const wdstring &displayWord = getHeader().convertToDisplay(iWord);
+    wdstring displayWord = convertToDisplay(iWord);
+    // Make it uppercase
+    std::transform(displayWord.begin(), displayWord.end(),
+                   displayWord.begin(), towupper);
 
     const DicEdge *edge0, *edge1, *edge2, *edgetst;
     edge0 = getEdgeAt(getRoot());

Index: dic/header.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/header.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- dic/header.cpp      28 Jun 2009 12:11:10 -0000      1.13
+++ dic/header.cpp      3 Jul 2009 21:40:15 -0000       1.14
@@ -250,26 +250,6 @@
         m_mapCodeFromChar[towupper(m_letters[i])] = i + 1;
     }
 
-    // Build the cache for the convertToDisplay() and convertFromInput()
-    // methods. Also ensure that the strings in m_displayAndInputData
-    // are all in uppercase.
-    map<wchar_t, vector<wstring> >::iterator it;
-    for (it = m_displayAndInputData.begin();
-         it != m_displayAndInputData.end(); ++it)
-    {
-        BOOST_FOREACH(wstring &str, it->second)
-        {
-            // Make sure the string is in uppercase
-            std::transform(str.begin(), str.end(), str.begin(), towupper);
-            // Make a lowercase copy
-            wstring lower = str;
-            std::transform(lower.begin(), lower.end(), lower.begin(), 
towlower);
-            // Fill the cache
-            m_displayInputCache[it->first].push_back(str);
-            m_displayInputCache[towlower(it->first)].push_back(lower);
-        }
-    }
-
     // Build the display strings cache
     m_displayCache.assign(m_letters.size() + 1, L"");
     for (unsigned int i = 0; i < m_letters.size(); ++i)
@@ -368,58 +348,6 @@
 }
 
 
-wdstring Header::convertToDisplay(const wstring &iWord) const
-{
-    // Optimization for dictionaries without display nor input chars,
-    // which is the case in most languages.
-    if (m_displayInputCache.empty())
-        return iWord;
-
-    wdstring dispStr = iWord;
-    map<wchar_t, vector<wstring> >::const_iterator it;
-    for (it = m_displayInputCache.begin();
-         it != m_displayInputCache.end(); ++it)
-    {
-        const wstring &disp = it->second[0];
-        string::size_type pos = 0;
-        while (pos < dispStr.size() &&
-               (pos = dispStr.find(it->first, pos)) != string::npos)
-        {
-            dispStr.replace(pos, 1, disp);
-            pos += disp.size();
-        }
-    }
-    return dispStr;
-}
-
-
-wstring Header::convertFromInput(const wistring &iWord) const
-{
-    // Optimization for dictionaries without display nor input chars,
-    // which is the case in most languages.
-    if (m_displayInputCache.empty())
-        return iWord;
-
-    wstring str = iWord;
-    map<wchar_t, vector<wstring> >::const_iterator it;
-    for (it = m_displayInputCache.begin();
-         it != m_displayInputCache.end(); ++it)
-    {
-        BOOST_FOREACH(const wstring &input, it->second)
-        {
-            string::size_type pos = 0;
-            while (pos < str.size() &&
-                   (pos = str.find(input, pos)) != string::npos)
-            {
-                str.replace(pos, input.size(), wstring(1, it->first));
-                pos += input.size();
-            }
-        }
-    }
-    return str;
-}
-
-
 void Header::read(istream &iStream)
 {
     Dict_header_old aHeader;

Index: dic/header.h
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/header.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- dic/header.h        28 Jun 2009 11:48:17 -0000      1.10
+++ dic/header.h        3 Jul 2009 21:40:15 -0000       1.11
@@ -117,6 +117,8 @@
     bool         isConsonant(unsigned int iCode) const { return 
m_consonants[iCode - 1]; }
     //@}
 
+    const map<wchar_t, vector<wstring> > & getDisplayInputData() const { 
return m_displayAndInputData; }
+
     /**
      * Return the letter corresponding to the given code
      */
@@ -138,21 +140,6 @@
     vector<wistring> getInputStr(unsigned int iCode) const;
 
     /**
-     * Convert the given string (made of internal characters)
-     * into a string suitable for display
-     */
-    wdstring convertToDisplay(const wstring &iWord) const;
-
-    /**
-     * Convert the given string (direct user input)
-     * into a string suitable for internal use in Eliot.
-     * For example, in Catalan, it will convert the L.L substring
-     * into the W character (because it is the internal character
-     * associated to the input string "L.L").
-     */
-    wstring convertFromInput(const wistring &iWord) const;
-
-    /**
      * Print a readable summary of the header on standard output
      */
     void print() const;
@@ -211,9 +198,6 @@
     /// Cache for the display string of each code
     vector<wdstring> m_displayCache;
 
-    /// Same as m_displayAndInputData, but also contains lowercase mappings
-    map<wchar_t, vector<wstring> > m_displayInputCache;
-
     /**
      * Load the header from a file
      * @param iStream: Input stream where to read the header

Index: dic/regexpmain.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/regexpmain.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- dic/regexpmain.cpp  22 Nov 2008 13:09:29 -0000      1.11
+++ dic/regexpmain.cpp  3 Jul 2009 21:40:15 -0000       1.12
@@ -37,7 +37,6 @@
 
 #include "dic.h"
 #include "dic_exception.h"
-#include "header.h"
 #include "encoding.h"
 
 

Index: game/duplicate.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/duplicate.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- game/duplicate.cpp  24 Jan 2009 17:44:56 -0000      1.31
+++ game/duplicate.cpp  3 Jul 2009 21:40:15 -0000       1.32
@@ -73,8 +73,10 @@
     }
     else
     {
+        // Convert the invalid word for display
+        const wdstring &dispWord = getDic().convertToDisplay(iWord);
         // Record the invalid move of the player
-        recordPlayerMove(Move(iWord, iCoord), currPlayer, true);
+        recordPlayerMove(Move(dispWord, iCoord), currPlayer, true);
     }
 
     // Little hack to handle duplicate games with only AI players.

Index: game/freegame.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/freegame.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- game/freegame.cpp   30 Nov 2008 21:10:26 -0000      1.31
+++ game/freegame.cpp   3 Jul 2009 21:40:15 -0000       1.32
@@ -71,7 +71,10 @@
     }
     else
     {
-        Move move(iWord, iCoord);
+        // Convert the invalid word for display
+        const wdstring &dispWord = getDic().convertToDisplay(iWord);
+
+        Move move(dispWord, iCoord);
 
         // Record the invalid move of the player
         recordPlayerMove(move, *m_players[m_currPlayer], true);

Index: game/move.h
===================================================================
RCS file: /cvsroot/eliot/eliot/game/move.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- game/move.h 23 Nov 2008 08:18:08 -0000      1.3
+++ game/move.h 3 Jul 2009 21:40:15 -0000       1.4
@@ -57,6 +57,7 @@
          * Constructor taking a word and its coordinates, corresponding
          * to an invalid move by the player (invalid word, invalid coordinates,
          * letters not corresponding to the rack, ...)
+         * Note: the invalid word must be given in the display form.
          */
         explicit Move(const wstring &iWord, const wstring &iCoord);
 

Index: game/turn.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/turn.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- game/turn.cpp       23 Nov 2008 08:18:10 -0000      1.14
+++ game/turn.cpp       3 Jul 2009 21:40:15 -0000       1.15
@@ -22,10 +22,10 @@
 #include "turn.h"
 
 
-// FIXME: move set to an invalid value. It would be better to get rid of this
+// FIXME: move set to an arbitrary one (pass). It would be better to get rid 
of this
 // constructor completely
 Turn::Turn()
-    : m_playerId(0), m_move(L"", L"")
+    : m_playerId(0), m_move(L"")
 {
 }
 

Index: qt/dic_tools_widget.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/dic_tools_widget.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- qt/dic_tools_widget.cpp     28 Jun 2009 12:11:10 -0000      1.11
+++ qt/dic_tools_widget.cpp     3 Jul 2009 21:40:15 -0000       1.12
@@ -158,11 +158,11 @@
             return;
         }
 
-        wstring input = m_dic->getHeader().convertFromInput(qtw(rack->text()));
+        wstring input = m_dic->convertFromInput(qtw(rack->text()));
         bool res = m_dic->searchWord(input);
         // Convert the input to uppercase
         std::transform(input.begin(), input.end(), input.begin(), towupper);
-        const wdstring &dispStr = m_dic->getHeader().convertToDisplay(input);
+        const wdstring &dispStr = m_dic->convertToDisplay(input);
         if (res)
         {
             labelCheck->setText(_q("The word '%1' exists").arg(qfw(dispStr)));
@@ -192,8 +192,8 @@
         return;
     }
 
-    const wstring &input = 
m_dic->getHeader().convertFromInput(qtw(rack->text().toUpper()));
-    const wdstring &disp = m_dic->getHeader().convertToDisplay(input);
+    const wstring &input = 
m_dic->convertFromInput(qtw(rack->text().toUpper()));
+    const wdstring &disp = m_dic->convertToDisplay(input);
     model->setHeaderData(0, Qt::Horizontal,
                          _q("Rack: %1").arg(qfw(disp)),
                          Qt::DisplayRole);
@@ -245,8 +245,8 @@
         return;
     }
 
-    const wstring &input = 
m_dic->getHeader().convertFromInput(qtw(rack->text().toUpper()));
-    const wdstring &disp = m_dic->getHeader().convertToDisplay(input);
+    const wstring &input = 
m_dic->convertFromInput(qtw(rack->text().toUpper()));
+    const wdstring &disp = m_dic->convertToDisplay(input);
     model->setHeaderData(0, Qt::Horizontal,
                          _q("Regular expression: %1").arg(qfw(disp)),
                          Qt::DisplayRole);
@@ -302,7 +302,7 @@
     {
         const Header &header = m_dic->getHeader();
         lineEditName->setText(qfw(header.getName()));
-        
lineEditLetters->setText(qfw(header.convertToDisplay(header.getLetters())));
+        
lineEditLetters->setText(qfw(m_dic->convertToDisplay(header.getLetters())));
         spinBoxWords->setValue(header.getNbWords());
 
         QStandardItemModel *model = m_dicInfoModel;
@@ -362,7 +362,7 @@
         return Invalid;
 
     // Convert the string to internal letters
-    const wstring &intInput = m_dic->getHeader().convertFromInput(winput);
+    const wstring &intInput = m_dic->convertFromInput(winput);
     // The string is invalid if it contains characters not present
     // in the dictionary
     if (!m_dic->validateLetters(intInput))
@@ -402,7 +402,7 @@
         return Invalid;
 
     // Convert the string to internal letters
-    const wstring &intInput = m_dic->getHeader().convertFromInput(winput);
+    const wstring &intInput = m_dic->convertFromInput(winput);
     // The string is invalid if it contains characters not present
     // in the dictionary
     if (!m_dic->validateLetters(intInput, authorizedChars))

Index: qt/play_word_mediator.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/play_word_mediator.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- qt/play_word_mediator.cpp   27 Jun 2009 18:09:44 -0000      1.2
+++ qt/play_word_mediator.cpp   3 Jul 2009 21:40:15 -0000       1.3
@@ -28,7 +28,6 @@
 #include "public_game.h"
 #include "coord.h"
 #include "dic.h"
-#include "header.h"
 #include "debug.h"
 
 
@@ -111,7 +110,7 @@
     // Convert the jokers to lowercase
     const wistring &inputWord = qtw(m_lineEditPlay.text().toUpper());
     // Convert to internal representation, then back to QString
-    QString word = 
qfw(m_game->getDic().getHeader().convertFromInput(inputWord));
+    QString word = qfw(m_game->getDic().convertFromInput(inputWord));
 
     int pos;
     while ((pos = word.indexOf('(')) != -1)
@@ -135,7 +134,7 @@
 
     // Convert the input string into an internal one
     const wstring intWord =
-        m_game->getDic().getHeader().convertFromInput(qtw(word));
+        m_game->getDic().convertFromInput(qtw(word));
 
     QString coords = m_lineEditCoord.text();
     int res = m_game->play(intWord, qtw(coords));
@@ -235,7 +234,7 @@
         return Invalid;
 
     // Convert the string to internal letters
-    const wstring &intInput = m_dic.getHeader().convertFromInput(winput);
+    const wstring &intInput = m_dic.convertFromInput(winput);
     // The string is invalid if it contains characters not present
     // in the dictionary (ignoring parentheses)
     if (!m_dic.validateLetters(intInput, L"()"))

Index: qt/player_widget.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/player_widget.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- qt/player_widget.cpp        27 Jun 2009 18:09:44 -0000      1.16
+++ qt/player_widget.cpp        3 Jul 2009 21:40:15 -0000       1.17
@@ -33,7 +33,6 @@
 #include "coord.h"
 #include "coord_model.h"
 #include "dic.h"
-#include "header.h"
 #include "debug.h"
 
 #include "encoding.h"
@@ -153,7 +152,7 @@
     QString inputLetters = lineEditChange->text();
     // Convert the input string into an internal one
     const wstring &letters =
-        m_game->getDic().getHeader().convertFromInput(qtw(inputLetters));
+        m_game->getDic().convertFromInput(qtw(inputLetters));
     // Pass the turn (and possibly change letters)
     int res = m_game->freeGamePass(letters);
     if (res == 0)
@@ -188,13 +187,13 @@
         return Invalid;
 
     // Convert the string to internal letters
-    const wstring &intInput = m_dic.getHeader().convertFromInput(winput);
+    const wstring &intInput = m_dic.convertFromInput(winput);
     // The string is invalid if it contains characters not present
     // in the dictionary
     if (!m_dic.validateLetters(intInput))
         return Intermediate;
 
-    const wstring &rack = 
m_dic.getHeader().convertFromInput(qtw(m_lineEdit.text()));
+    const wstring &rack = m_dic.convertFromInput(qtw(m_lineEdit.text()));
     if (intInput.size() > rack.size())
         return Intermediate;
     // The letters to change must be in the rack

Index: qt/training_widget.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/training_widget.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- qt/training_widget.cpp      27 Jun 2009 18:09:44 -0000      1.12
+++ qt/training_widget.cpp      3 Jul 2009 21:40:15 -0000       1.13
@@ -26,7 +26,6 @@
 #include "play_word_mediator.h"
 
 #include "dic.h"
-#include "header.h"
 #include "bag.h"
 #include "public_game.h"
 #include "game_exception.h"
@@ -210,8 +209,7 @@
     try
     {
         lineEditRack->setPalette(blackPalette);
-        const Header &header = m_game->getDic().getHeader();
-        const wstring &input = header.convertFromInput(qtw(iText));
+        const wstring &input = m_game->getDic().convertFromInput(qtw(iText));
         m_game->trainingSetRackManual(false, input);
         pushButtonSearch->setEnabled(m_model->rowCount() == 0 &&
                                      lineEditRack->text() != "");
@@ -319,7 +317,7 @@
         return Invalid;
 
     // Convert the string to internal letters
-    const wstring &intInput = dic.getHeader().convertFromInput(winput);
+    const wstring &intInput = dic.convertFromInput(winput);
     // The string is invalid if it contains characters not present
     // in the dictionary
     if (!dic.validateLetters(intInput))

Index: utils/eliottxt.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/utils/eliottxt.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -b -r1.37 -r1.38
--- utils/eliottxt.cpp  23 Jun 2009 21:39:07 -0000      1.37
+++ utils/eliottxt.cpp  3 Jul 2009 21:40:16 -0000       1.38
@@ -39,7 +39,6 @@
 
 #include "dic.h"
 #include "dic_exception.h"
-#include "header.h"
 #include "game_io.h"
 #include "game_factory.h"
 #include "public_game.h"
@@ -139,7 +138,7 @@
 {
     if (tokens.size() <= index)
         return L"";
-    return iDic.getHeader().convertFromInput(tokens[index]);
+    return iDic.convertFromInput(tokens[index]);
 }
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]