[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] eliot dic/dic.h dic/dic_search.cpp dic/header.c...
From: |
Olivier Teulière |
Subject: |
[Eliot-dev] eliot dic/dic.h dic/dic_search.cpp dic/header.c... |
Date: |
Tue, 23 Jun 2009 21:39:08 +0000 |
CVSROOT: /cvsroot/eliot
Module name: eliot
Changes by: Olivier Teulière <ipkiss> 09/06/23 21:39:07
Modified files:
dic : dic.h dic_search.cpp header.cpp header.h
utils : eliottxt.cpp
Log message:
First step in accepting various input strings for the same tile: input
coming from the text interface is now passed through a conversion method (...
which does nothing yet!)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/dic.h?cvsroot=eliot&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/dic_search.cpp?cvsroot=eliot&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/header.cpp?cvsroot=eliot&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/header.h?cvsroot=eliot&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/eliot/utils/eliottxt.cpp?cvsroot=eliot&r1=1.36&r2=1.37
Patches:
Index: dic/dic.h
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/dic.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- dic/dic.h 23 Jun 2009 12:41:53 -0000 1.22
+++ dic/dic.h 23 Jun 2009 21:39:07 -0000 1.23
@@ -1,6 +1,6 @@
/*****************************************************************************
* Eliot
- * Copyright (C) 2002-2007 Antoine Fraboulet & Olivier Teulière
+ * Copyright (C) 2002-2009 Antoine Fraboulet & Olivier Teulière
* Authors: Antoine Fraboulet <antoine.fraboulet @@ free.fr>
* Olivier Teulière <ipkiss @@ gmail.com>
*
@@ -45,7 +45,7 @@
class DicEdge;
/**
- * A wdstring is a display string, i.e. it can contains more chars thani
+ * A wdstring is a display string, i.e. it can contain more chars than
* the represented string. The difference arises in languages such as Catalan,
* where for example "QU" is made of 2 real characters, but corresponds to a
* single tile.
Index: dic/dic_search.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/dic_search.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- dic/dic_search.cpp 23 Jun 2009 15:36:28 -0000 1.15
+++ dic/dic_search.cpp 23 Jun 2009 21:39:07 -0000 1.16
@@ -1,6 +1,6 @@
/*****************************************************************************
* Eliot
- * Copyright (C) 2002-2008 Antoine Fraboulet & Olivier Teulière
+ * Copyright (C) 2002-2009 Antoine Fraboulet & Olivier Teulière
* Authors: Antoine Fraboulet <antoine.fraboulet @@ free.fr>
* Olivier Teulière <ipkiss @@ gmail.com>
*
Index: dic/header.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/header.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- dic/header.cpp 23 Jun 2009 15:36:28 -0000 1.8
+++ dic/header.cpp 23 Jun 2009 21:39:07 -0000 1.9
@@ -1,6 +1,6 @@
/*****************************************************************************
* Eliot
- * Copyright (C) 2007 Olivier Teulière
+ * Copyright (C) 2007-2009 Olivier Teulière
* Authors: Olivier Teulière <ipkiss @@ gmail.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -259,7 +259,7 @@
}
-wstring Header::getDisplayStr(unsigned int iCode) const
+wdstring Header::getDisplayStr(unsigned int iCode) const
{
// Safety check
if (iCode == 0 || iCode > m_letters.size())
@@ -290,6 +290,13 @@
}
+wstring Header::convertFromInput(const wistring &iWord) const
+{
+ // TODO: do something useful
+ return iWord;
+}
+
+
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.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- dic/header.h 23 Jun 2009 15:36:28 -0000 1.6
+++ dic/header.h 23 Jun 2009 21:39:07 -0000 1.7
@@ -1,6 +1,6 @@
/*****************************************************************************
* Eliot
- * Copyright (C) 2007 Olivier Teulière
+ * Copyright (C) 2007-2009 Olivier Teulière
* Authors: Olivier Teulière <ipkiss @@ gmail.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -30,6 +30,7 @@
// XXX: duplicated typedef (also present in dic.h)
typedef wstring wdstring;
+typedef wstring wistring;
/**
@@ -127,7 +128,7 @@
/**
* Return the display string corresponding to the given code
*/
- wstring getDisplayStr(unsigned int iCode) const;
+ wdstring getDisplayStr(unsigned int iCode) const;
/**
* Convert the given string (made of internal characters)
@@ -136,6 +137,15 @@
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;
Index: utils/eliottxt.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/utils/eliottxt.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- utils/eliottxt.cpp 23 Jun 2009 12:41:54 -0000 1.36
+++ utils/eliottxt.cpp 23 Jun 2009 21:39:07 -0000 1.37
@@ -39,6 +39,7 @@
#include "dic.h"
#include "dic_exception.h"
+#include "header.h"
#include "game_io.h"
#include "game_factory.h"
#include "public_game.h"
@@ -133,28 +134,23 @@
}
-wstring checkAlphaNumToken(const vector<wstring> &tokens, uint8_t index)
+wstring checkLettersToken(const vector<wstring> &tokens, uint8_t index,
+ const Dictionary &iDic)
{
if (tokens.size() <= index)
return L"";
- const wstring &wstr = tokens[index];
- BOOST_FOREACH(wchar_t wch, wstr)
- {
- if (!iswalnum(wch))
- return L"";
- }
- return wstr;
+ return iDic.getHeader().convertFromInput(tokens[index]);
}
-wstring checkAlphaPlusJokerToken(const vector<wstring> &tokens, uint8_t index)
+wstring checkAlphaNumToken(const vector<wstring> &tokens, uint8_t index)
{
if (tokens.size() <= index)
return L"";
const wstring &wstr = tokens[index];
BOOST_FOREACH(wchar_t wch, wstr)
{
- if (!iswalpha(wch) && wch != L'+' && wch != L'?')
+ if (!iswalnum(wch))
return L"";
}
return wstr;
@@ -375,7 +371,7 @@
displayData(iGame, tokens);
else if (tokens[0][0] == L'd')
{
- const wstring &word = checkAlphaToken(tokens, 1);
+ const wstring &word = checkLettersToken(tokens, 1, iGame.getDic());
if (word == L"")
helpDuplicate();
else
@@ -413,7 +409,7 @@
}
else if (tokens[0][0] == L'j')
{
- const wstring &word = checkAlphaToken(tokens, 1);
+ const wstring &word = checkLettersToken(tokens, 1, iGame.getDic());
if (word == L"")
helpDuplicate();
else
@@ -512,7 +508,7 @@
return;
}
const wstring &type = checkAlphaToken(tokens, 1);
- if (type == L"" || type.size() != 1 ||
+ if (type.size() != 1 ||
(type[0] != L'b' && type[0] != L'i'))
{
printf("Invalid type\n");
@@ -589,7 +585,7 @@
helpTraining();
else
{
- const wstring &word = checkAlphaToken(tokens, 2);
+ const wstring &word = checkLettersToken(tokens, 2,
iGame.getDic());
if (word == L"")
helpTraining();
else
@@ -652,7 +648,8 @@
break;
case L't':
{
- const wstring &letters =
checkAlphaPlusJokerToken(tokens, 1);
+ const wstring &letters =
+ checkLettersToken(tokens, 1, iGame.getDic());
if (letters == L"")
helpTraining();
else
@@ -728,7 +725,7 @@
/* You can pass your turn without changing any letter
*/
if (tokens.size() > 1)
{
- letters = checkAlphaToken(tokens, 1);
+ letters = checkLettersToken(tokens, 1,
iGame.getDic());
if (letters == L"")
fprintf(stderr, "Invalid letters\n");
}