2020-05-04 17:33:15 +02:00
|
|
|
/* -*- compile-command: "cd ../linux && make MEMDEBUG=TRUE -j3"; -*- */
|
2003-11-01 06:35:29 +01:00
|
|
|
/*
|
2020-04-25 20:34:58 +02:00
|
|
|
* Copyright 1997 - 2020 by Eric House (xwords@eehouse.org). All rights
|
2009-04-05 21:02:21 +02:00
|
|
|
* reserved.
|
2003-11-01 06:35:29 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DICTNRY_H__
|
|
|
|
#define __DICTNRY_H__
|
|
|
|
|
2014-08-21 16:15:20 +02:00
|
|
|
/* #ifdef DEBUG */
|
|
|
|
/* # define DEBUG_REF 1 */
|
|
|
|
/* #endif */
|
2014-03-11 02:59:10 +01:00
|
|
|
|
2014-03-12 06:04:30 +01:00
|
|
|
#include <pthread.h>
|
|
|
|
|
2003-11-01 06:35:29 +01:00
|
|
|
#include "comtypes.h"
|
|
|
|
|
|
|
|
#include "dawg.h"
|
|
|
|
#include "model.h"
|
|
|
|
#include "mempool.h"
|
|
|
|
|
|
|
|
#ifdef CPLUS
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define LETTER_NONE '\0'
|
2009-04-05 21:02:21 +02:00
|
|
|
/* cast to unsigned in case XP_UCHAR is signed */
|
|
|
|
#define IS_SPECIAL(face) ((XP_U16)(face) < 0x0020)
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2010-12-06 04:33:10 +01:00
|
|
|
#define DICT_HEADER_MASK 0x08
|
2013-04-21 04:46:35 +02:00
|
|
|
#define DICT_SYNONYMS_MASK 0x10
|
2010-12-06 04:33:10 +01:00
|
|
|
|
2003-11-01 06:35:29 +01:00
|
|
|
typedef enum {
|
|
|
|
INTRADE_MW_TEXT = BONUS_LAST
|
|
|
|
} XWMiniTextType;
|
|
|
|
|
|
|
|
typedef struct SpecialBitmaps {
|
|
|
|
XP_Bitmap largeBM;
|
|
|
|
XP_Bitmap smallBM;
|
|
|
|
} SpecialBitmaps;
|
|
|
|
|
2009-01-13 13:57:56 +01:00
|
|
|
typedef struct _XP_Bitmaps {
|
|
|
|
XP_U16 nBitmaps;
|
|
|
|
XP_Bitmap bmps[2]; /* 2 is private, may change */
|
|
|
|
} XP_Bitmaps;
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2020-05-04 17:33:15 +02:00
|
|
|
#define HEADERFLAGS_DUPS_SUPPORTED_BIT 0x0001
|
|
|
|
|
2003-11-01 06:35:29 +01:00
|
|
|
struct DictionaryCtxt {
|
2020-04-25 20:34:58 +02:00
|
|
|
void (*destructor)( DictionaryCtxt* dict, XWEnv xwe );
|
2004-10-07 15:23:20 +02:00
|
|
|
|
2011-10-22 03:51:33 +02:00
|
|
|
array_edge* (*func_edge_for_index)( const DictionaryCtxt* dict,
|
|
|
|
XP_U32 index );
|
2006-09-02 07:30:51 +02:00
|
|
|
array_edge* (*func_dict_getTopEdge)( const DictionaryCtxt* dict );
|
2014-03-13 03:24:00 +01:00
|
|
|
XP_U32 (*func_dict_index_from)( const DictionaryCtxt* dict,
|
2011-10-22 03:51:33 +02:00
|
|
|
array_edge* p_edge );
|
|
|
|
array_edge* (*func_dict_follow)( const DictionaryCtxt* dict,
|
|
|
|
array_edge* in );
|
2011-10-29 05:27:16 +02:00
|
|
|
array_edge* (*func_dict_edge_with_tile)( const DictionaryCtxt* dict,
|
|
|
|
array_edge* from, Tile tile );
|
2006-09-24 17:28:15 +02:00
|
|
|
const XP_UCHAR* (*func_dict_getShortName)( const DictionaryCtxt* dict );
|
2004-10-07 15:23:20 +02:00
|
|
|
|
2014-03-12 06:01:11 +01:00
|
|
|
pthread_mutex_t mutex;
|
|
|
|
|
2003-11-01 06:35:29 +01:00
|
|
|
array_edge* topEdge;
|
2008-05-31 05:26:16 +02:00
|
|
|
array_edge* base; /* the physical beginning of the dictionary; not
|
|
|
|
necessarily the entry point for search!! */
|
2003-11-01 06:35:29 +01:00
|
|
|
XP_UCHAR* name;
|
2011-04-12 03:55:42 +02:00
|
|
|
XP_UCHAR* langName;
|
2022-05-28 18:00:20 +02:00
|
|
|
XP_UCHAR* isoCode;
|
2013-04-06 20:43:57 +02:00
|
|
|
XP_UCHAR* faces; /* storage for faces */
|
|
|
|
XP_UCHAR* facesEnd;
|
2012-08-27 05:58:28 +02:00
|
|
|
XP_UCHAR* desc;
|
2012-09-08 05:34:06 +02:00
|
|
|
XP_UCHAR* md5Sum;
|
2013-04-06 20:43:57 +02:00
|
|
|
const XP_UCHAR** facePtrs; /* elems point into faces, above */
|
2022-03-15 23:03:03 +01:00
|
|
|
XP_U8* counts[(MAX_COLS>>1) + 1];
|
|
|
|
XP_U8* values;
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2022-03-15 23:03:03 +01:00
|
|
|
XP_U8* otherCounts;
|
|
|
|
XP_U8* otherCountsEnd;
|
2022-03-14 18:28:08 +01:00
|
|
|
|
2003-11-01 06:35:29 +01:00
|
|
|
SpecialBitmaps* bitmaps;
|
|
|
|
XP_UCHAR** chars;
|
2013-04-09 16:43:04 +02:00
|
|
|
XP_UCHAR** charEnds;
|
2010-12-06 04:33:10 +01:00
|
|
|
XP_U32 nWords;
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2014-03-09 05:57:27 +01:00
|
|
|
XP_U16 refCount;
|
2020-05-04 17:33:15 +02:00
|
|
|
XP_U16 headerFlags;
|
2020-12-27 20:53:36 +01:00
|
|
|
XP_U16 maxChars;
|
2003-11-01 06:35:29 +01:00
|
|
|
XP_U8 nFaces;
|
|
|
|
XP_U8 nodeSize;
|
2003-12-14 17:21:01 +01:00
|
|
|
XP_Bool is_4_byte;
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2008-05-31 05:26:16 +02:00
|
|
|
XP_S8 blankTile; /* negative means there's no known blank */
|
2009-04-05 21:02:21 +02:00
|
|
|
XP_Bool isUTF8;
|
2003-11-01 06:35:29 +01:00
|
|
|
#ifdef DEBUG
|
|
|
|
XP_U32 numEdges;
|
|
|
|
#endif
|
|
|
|
MPSLOT
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This is the datastructure that allows access to a DAWG in a
|
|
|
|
* platform-independent way.
|
|
|
|
*/
|
|
|
|
/* typedef struct DictionaryVtable { */
|
|
|
|
/* XP_U16 (*m_getTileValue)( DictionaryCtxt* ctxt, CellTile tile ); */
|
|
|
|
/* unsigned char (*m_getTileChar)( DictionaryCtxt* ctxt, CellTile tile, */
|
2008-05-31 05:26:16 +02:00
|
|
|
/* XP_FontCode* fontCode ); */
|
2003-11-01 06:35:29 +01:00
|
|
|
/* XP_U16 (*m_numTiles)( DictionaryCtxt* ctxt, Tile tile ); */
|
|
|
|
/* XP_U16 (*m_numTileFaces)( DictionaryCtxt* ctxt ); */
|
|
|
|
/* } DictionaryVtable; */
|
|
|
|
|
|
|
|
|
|
|
|
/* struct DictionaryCtxt { */
|
|
|
|
/* DictionaryVtable* vtable; */
|
|
|
|
/* }; */
|
|
|
|
|
|
|
|
/* #define dict_getTileValue(dc,t) \ */
|
|
|
|
/* (dc)->vtable->m_getTileValue((dc),(t)) */
|
|
|
|
|
|
|
|
/* #define dict_getTileChar(dc,t,fc) \ */
|
|
|
|
/* (dc)->vtable->m_getTileChar((dc),(t),(fc)) */
|
|
|
|
|
|
|
|
/* #define dict_numTiles(dc,t) (dc)->vtable->m_numTiles((dc),(t)) */
|
|
|
|
|
|
|
|
/* #define dict_numTileFaces(dc) (dc)->vtable->m_numTileFaces(dc) */
|
|
|
|
|
2004-10-07 15:23:20 +02:00
|
|
|
#define dict_edge_for_index(d, i) (*((d)->func_edge_for_index))((d), (i))
|
|
|
|
#define dict_getTopEdge(d) (*((d)->func_dict_getTopEdge))(d)
|
2011-10-22 03:51:33 +02:00
|
|
|
#define dict_index_from(d,e) (*((d)->func_dict_index_from))(d,e)
|
|
|
|
#define dict_follow(d,e) (*((d)->func_dict_follow))(d,e)
|
2011-10-29 05:27:16 +02:00
|
|
|
#define dict_edge_with_tile(d,e,t) (*((d)->func_dict_edge_with_tile))(d,e,t)
|
2004-12-18 02:05:20 +01:00
|
|
|
#define dict_getShortName(d) (*((d)->func_dict_getShortName))(d)
|
2005-07-08 05:06:08 +02:00
|
|
|
|
2012-08-02 05:29:15 +02:00
|
|
|
#define ISACCEPTING(d,e) \
|
2011-10-22 03:51:33 +02:00
|
|
|
((ACCEPTINGMASK_NEW & ((array_edge_old*)(e))->bits) != 0)
|
2012-08-02 05:29:15 +02:00
|
|
|
#define IS_LAST_EDGE(d,e) \
|
2011-10-22 03:51:33 +02:00
|
|
|
((LASTEDGEMASK_NEW & ((array_edge_old*)(e))->bits) != 0)
|
add filtering to wordlist browser
Add a basic regular expression engine to the dictiter, and to the UI add
the ability to filter for "starts with", "contains" and "ends with",
which translate into ANDed RE_*, _*RE_* and _*RE, respectively (with
_ standing for blank/wildcard). The engine's tightly integrated with the
next/prevWord() functions for greatest possible speed, but unless
there's no pattern does slow things down a bit (especially when "ENDS
WITH" is used.) The full engine is not exposed (users can't provide raw
REs), and while the parser will accept nesting (e.g. ([AB]_*[CD]){2,5}
to mean words from 2-5 tiles long starting with A or B and ending with C
or D) the engine can't handle it. Which is why filtering for word length
is handled separately from REs (but also tightly integrated.)
Users can enter strings that don't map to tiles. They now get an
error. It made sense for the error alert to have a "Show tiles"
button, so there's now a dialog listing all the tiles in a wordlist,
something the browser has needed all along.
2020-08-05 18:25:33 +02:00
|
|
|
#define EDGETILE(dict,edge) \
|
2011-10-22 03:51:33 +02:00
|
|
|
((Tile)(((array_edge_old*)(edge))->bits & \
|
add filtering to wordlist browser
Add a basic regular expression engine to the dictiter, and to the UI add
the ability to filter for "starts with", "contains" and "ends with",
which translate into ANDed RE_*, _*RE_* and _*RE, respectively (with
_ standing for blank/wildcard). The engine's tightly integrated with the
next/prevWord() functions for greatest possible speed, but unless
there's no pattern does slow things down a bit (especially when "ENDS
WITH" is used.) The full engine is not exposed (users can't provide raw
REs), and while the parser will accept nesting (e.g. ([AB]_*[CD]){2,5}
to mean words from 2-5 tiles long starting with A or B and ending with C
or D) the engine can't handle it. Which is why filtering for word length
is handled separately from REs (but also tightly integrated.)
Users can enter strings that don't map to tiles. They now get an
error. It made sense for the error alert to have a "Show tiles"
button, so there's now a dialog listing all the tiles in a wordlist,
something the browser has needed all along.
2020-08-05 18:25:33 +02:00
|
|
|
((dict)->is_4_byte?LETTERMASK_NEW_4:LETTERMASK_NEW_3)))
|
2003-11-01 06:35:29 +01:00
|
|
|
|
add filtering to wordlist browser
Add a basic regular expression engine to the dictiter, and to the UI add
the ability to filter for "starts with", "contains" and "ends with",
which translate into ANDed RE_*, _*RE_* and _*RE, respectively (with
_ standing for blank/wildcard). The engine's tightly integrated with the
next/prevWord() functions for greatest possible speed, but unless
there's no pattern does slow things down a bit (especially when "ENDS
WITH" is used.) The full engine is not exposed (users can't provide raw
REs), and while the parser will accept nesting (e.g. ([AB]_*[CD]){2,5}
to mean words from 2-5 tiles long starting with A or B and ending with C
or D) the engine can't handle it. Which is why filtering for word length
is handled separately from REs (but also tightly integrated.)
Users can enter strings that don't map to tiles. They now get an
error. It made sense for the error alert to have a "Show tiles"
button, so there's now a dialog listing all the tiles in a wordlist,
something the browser has needed all along.
2020-08-05 18:25:33 +02:00
|
|
|
const DictionaryCtxt* p_dict_ref( const DictionaryCtxt* dict, XWEnv xwe
|
2014-03-11 02:59:10 +01:00
|
|
|
#ifdef DEBUG_REF
|
add filtering to wordlist browser
Add a basic regular expression engine to the dictiter, and to the UI add
the ability to filter for "starts with", "contains" and "ends with",
which translate into ANDed RE_*, _*RE_* and _*RE, respectively (with
_ standing for blank/wildcard). The engine's tightly integrated with the
next/prevWord() functions for greatest possible speed, but unless
there's no pattern does slow things down a bit (especially when "ENDS
WITH" is used.) The full engine is not exposed (users can't provide raw
REs), and while the parser will accept nesting (e.g. ([AB]_*[CD]){2,5}
to mean words from 2-5 tiles long starting with A or B and ending with C
or D) the engine can't handle it. Which is why filtering for word length
is handled separately from REs (but also tightly integrated.)
Users can enter strings that don't map to tiles. They now get an
error. It made sense for the error alert to have a "Show tiles"
button, so there's now a dialog listing all the tiles in a wordlist,
something the browser has needed all along.
2020-08-05 18:25:33 +02:00
|
|
|
,const char* func, const char* file, int line
|
2014-03-11 02:59:10 +01:00
|
|
|
#endif
|
|
|
|
);
|
add filtering to wordlist browser
Add a basic regular expression engine to the dictiter, and to the UI add
the ability to filter for "starts with", "contains" and "ends with",
which translate into ANDed RE_*, _*RE_* and _*RE, respectively (with
_ standing for blank/wildcard). The engine's tightly integrated with the
next/prevWord() functions for greatest possible speed, but unless
there's no pattern does slow things down a bit (especially when "ENDS
WITH" is used.) The full engine is not exposed (users can't provide raw
REs), and while the parser will accept nesting (e.g. ([AB]_*[CD]){2,5}
to mean words from 2-5 tiles long starting with A or B and ending with C
or D) the engine can't handle it. Which is why filtering for word length
is handled separately from REs (but also tightly integrated.)
Users can enter strings that don't map to tiles. They now get an
error. It made sense for the error alert to have a "Show tiles"
button, so there's now a dialog listing all the tiles in a wordlist,
something the browser has needed all along.
2020-08-05 18:25:33 +02:00
|
|
|
void p_dict_unref( const DictionaryCtxt* dict, XWEnv xwe
|
2014-03-11 02:59:10 +01:00
|
|
|
#ifdef DEBUG_REF
|
add filtering to wordlist browser
Add a basic regular expression engine to the dictiter, and to the UI add
the ability to filter for "starts with", "contains" and "ends with",
which translate into ANDed RE_*, _*RE_* and _*RE, respectively (with
_ standing for blank/wildcard). The engine's tightly integrated with the
next/prevWord() functions for greatest possible speed, but unless
there's no pattern does slow things down a bit (especially when "ENDS
WITH" is used.) The full engine is not exposed (users can't provide raw
REs), and while the parser will accept nesting (e.g. ([AB]_*[CD]){2,5}
to mean words from 2-5 tiles long starting with A or B and ending with C
or D) the engine can't handle it. Which is why filtering for word length
is handled separately from REs (but also tightly integrated.)
Users can enter strings that don't map to tiles. They now get an
error. It made sense for the error alert to have a "Show tiles"
button, so there's now a dialog listing all the tiles in a wordlist,
something the browser has needed all along.
2020-08-05 18:25:33 +02:00
|
|
|
,const char* func, const char* file, int line
|
2014-03-11 02:59:10 +01:00
|
|
|
#endif
|
|
|
|
);
|
2020-04-25 20:34:58 +02:00
|
|
|
void dict_unref_all( PlayerDicts* dicts, XWEnv xwe );
|
2014-03-09 05:57:27 +01:00
|
|
|
|
2014-03-11 02:59:10 +01:00
|
|
|
#ifdef DEBUG_REF
|
2020-04-25 20:34:58 +02:00
|
|
|
# define dict_ref(dict, xwe) p_dict_ref( dict, xwe, __func__, __FILE__, __LINE__ )
|
|
|
|
# define dict_unref(dict, xwe) p_dict_unref( (dict), (xwe), __func__, __FILE__, __LINE__ )
|
2014-03-11 02:59:10 +01:00
|
|
|
#else
|
2020-04-25 20:34:58 +02:00
|
|
|
# define dict_ref(dict, xwe) p_dict_ref( (dict), (xwe) )
|
|
|
|
# define dict_unref(dict, xwe) p_dict_unref( (dict), (xwe) )
|
2014-03-11 02:59:10 +01:00
|
|
|
#endif
|
|
|
|
|
2006-09-02 07:30:51 +02:00
|
|
|
XP_Bool dict_tilesAreSame( const DictionaryCtxt* dict1,
|
|
|
|
const DictionaryCtxt* dict2 );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2006-02-18 07:39:40 +01:00
|
|
|
XP_Bool dict_hasBlankTile( const DictionaryCtxt* dict );
|
|
|
|
Tile dict_getBlankTile( const DictionaryCtxt* dict );
|
|
|
|
XP_U16 dict_getTileValue( const DictionaryCtxt* ctxt, Tile tile );
|
2022-03-11 07:15:49 +01:00
|
|
|
XP_U16 dict_numTilesForSize( const DictionaryCtxt* ctxt, Tile tile, XP_U16 nCols );
|
2006-02-18 07:39:40 +01:00
|
|
|
XP_U16 dict_numTileFaces( const DictionaryCtxt* ctxt );
|
2020-12-27 20:53:36 +01:00
|
|
|
XP_U16 dict_getMaxTileChars( const DictionaryCtxt* ctxt );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2006-09-02 07:30:51 +02:00
|
|
|
XP_U16 dict_tilesToString( const DictionaryCtxt* ctxt, const Tile* tiles,
|
2020-05-04 17:33:15 +02:00
|
|
|
XP_U16 nTiles, XP_UCHAR* buf, XP_U16 bufSize,
|
|
|
|
const XP_UCHAR* delim );
|
2009-04-05 21:02:21 +02:00
|
|
|
const XP_UCHAR* dict_getTileString( const DictionaryCtxt* ctxt, Tile tile );
|
2013-04-06 20:43:57 +02:00
|
|
|
const XP_UCHAR* dict_getNextTileString( const DictionaryCtxt* ctxt, Tile tile,
|
|
|
|
const XP_UCHAR* cur );
|
2006-09-24 17:28:15 +02:00
|
|
|
const XP_UCHAR* dict_getName( const DictionaryCtxt* ctxt );
|
2011-04-12 03:55:42 +02:00
|
|
|
const XP_UCHAR* dict_getLangName(const DictionaryCtxt* ctxt );
|
|
|
|
|
2009-04-05 21:02:21 +02:00
|
|
|
XP_Bool dict_isUTF8( const DictionaryCtxt* ctxt );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2020-05-04 17:33:15 +02:00
|
|
|
typedef XP_Bool (*OnFoundTiles)(void* closure, const Tile* tiles, int len);
|
add filtering to wordlist browser
Add a basic regular expression engine to the dictiter, and to the UI add
the ability to filter for "starts with", "contains" and "ends with",
which translate into ANDed RE_*, _*RE_* and _*RE, respectively (with
_ standing for blank/wildcard). The engine's tightly integrated with the
next/prevWord() functions for greatest possible speed, but unless
there's no pattern does slow things down a bit (especially when "ENDS
WITH" is used.) The full engine is not exposed (users can't provide raw
REs), and while the parser will accept nesting (e.g. ([AB]_*[CD]){2,5}
to mean words from 2-5 tiles long starting with A or B and ending with C
or D) the engine can't handle it. Which is why filtering for word length
is handled separately from REs (but also tightly integrated.)
Users can enter strings that don't map to tiles. They now get an
error. It made sense for the error alert to have a "Show tiles"
button, so there's now a dialog listing all the tiles in a wordlist,
something the browser has needed all along.
2020-08-05 18:25:33 +02:00
|
|
|
void dict_tilesForString( const DictionaryCtxt* dict, const XP_UCHAR* str,
|
|
|
|
XP_U16 strLen, OnFoundTiles proc, void* closure );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2006-09-02 07:30:51 +02:00
|
|
|
XP_Bool dict_faceIsBitmap( const DictionaryCtxt* dict, Tile tile );
|
2009-01-13 13:57:56 +01:00
|
|
|
void dict_getFaceBitmaps( const DictionaryCtxt* dict, Tile tile,
|
|
|
|
XP_Bitmaps* bmps );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
add filtering to wordlist browser
Add a basic regular expression engine to the dictiter, and to the UI add
the ability to filter for "starts with", "contains" and "ends with",
which translate into ANDed RE_*, _*RE_* and _*RE, respectively (with
_ standing for blank/wildcard). The engine's tightly integrated with the
next/prevWord() functions for greatest possible speed, but unless
there's no pattern does slow things down a bit (especially when "ENDS
WITH" is used.) The full engine is not exposed (users can't provide raw
REs), and while the parser will accept nesting (e.g. ([AB]_*[CD]){2,5}
to mean words from 2-5 tiles long starting with A or B and ending with C
or D) the engine can't handle it. Which is why filtering for word length
is handled separately from REs (but also tightly integrated.)
Users can enter strings that don't map to tiles. They now get an
error. It made sense for the error alert to have a "Show tiles"
button, so there's now a dialog listing all the tiles in a wordlist,
something the browser has needed all along.
2020-08-05 18:25:33 +02:00
|
|
|
XP_U32 dict_getWordCount( const DictionaryCtxt* dict, XWEnv xwe );
|
2005-07-07 05:46:07 +02:00
|
|
|
|
2012-08-27 05:58:28 +02:00
|
|
|
const XP_UCHAR* dict_getDesc( const DictionaryCtxt* dict );
|
2022-06-04 23:02:28 +02:00
|
|
|
const XP_UCHAR* dict_getISOCode( const DictionaryCtxt* dict );
|
2012-09-08 19:09:31 +02:00
|
|
|
const XP_UCHAR* dict_getMd5Sum( const DictionaryCtxt* dict );
|
2020-05-04 17:33:15 +02:00
|
|
|
XP_Bool dict_hasDuplicates( const DictionaryCtxt* dict );
|
2012-08-27 05:58:28 +02:00
|
|
|
|
2022-03-11 07:15:49 +01:00
|
|
|
void dict_writeTilesInfo( const DictionaryCtxt* ctxt, XP_U16 boardSize,
|
|
|
|
XWStreamCtxt* stream );
|
add filtering to wordlist browser
Add a basic regular expression engine to the dictiter, and to the UI add
the ability to filter for "starts with", "contains" and "ends with",
which translate into ANDed RE_*, _*RE_* and _*RE, respectively (with
_ standing for blank/wildcard). The engine's tightly integrated with the
next/prevWord() functions for greatest possible speed, but unless
there's no pattern does slow things down a bit (especially when "ENDS
WITH" is used.) The full engine is not exposed (users can't provide raw
REs), and while the parser will accept nesting (e.g. ([AB]_*[CD]){2,5}
to mean words from 2-5 tiles long starting with A or B and ending with C
or D) the engine can't handle it. Which is why filtering for word length
is handled separately from REs (but also tightly integrated.)
Users can enter strings that don't map to tiles. They now get an
error. It made sense for the error alert to have a "Show tiles"
button, so there's now a dialog listing all the tiles in a wordlist,
something the browser has needed all along.
2020-08-05 18:25:33 +02:00
|
|
|
|
2008-09-05 14:11:37 +02:00
|
|
|
void dict_writeToStream( const DictionaryCtxt* ctxt, XWStreamCtxt* stream );
|
2020-04-25 20:34:58 +02:00
|
|
|
void dict_loadFromStream( DictionaryCtxt* dict, XWEnv xwe, XWStreamCtxt* stream );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2011-04-13 15:45:22 +02:00
|
|
|
#ifdef TEXT_MODEL
|
|
|
|
/* Return the strlen of the longest face, e.g. 1 for English and Italian;
|
|
|
|
2 for Spanish; 3 for Catalan */
|
|
|
|
XP_U16 dict_getMaxWidth( const DictionaryCtxt* dict );
|
|
|
|
#endif
|
|
|
|
|
2003-11-01 06:35:29 +01:00
|
|
|
|
|
|
|
/* These methods get "overridden" by subclasses. That is, they must be
|
|
|
|
implemented by each platform. */
|
|
|
|
|
|
|
|
#ifdef STUBBED_DICT
|
|
|
|
DictionaryCtxt* make_stubbed_dict( MPFORMAL_NOCOMMA );
|
|
|
|
#endif
|
2020-05-01 18:18:27 +02:00
|
|
|
XP_U16 countSpecials( DictionaryCtxt* ctxt );
|
|
|
|
XP_Bool parseCommon( DictionaryCtxt* dict, XWEnv xwe, const XP_U8** ptrp,
|
|
|
|
const XP_U8* end );
|
|
|
|
XP_Bool checkSanity( DictionaryCtxt* dict, XP_U32 numEdges );
|
2003-11-01 06:35:29 +01:00
|
|
|
|
2004-10-07 15:23:20 +02:00
|
|
|
/* To be called only by subclasses!!! */
|
2021-02-02 05:13:25 +01:00
|
|
|
void dict_super_init( MPFORMAL DictionaryCtxt* ctxt );
|
2022-03-15 23:03:03 +01:00
|
|
|
void dict_super_destroy( DictionaryCtxt* ctxt );
|
|
|
|
|
2020-05-01 18:18:27 +02:00
|
|
|
/* Must be implemented by subclasses */
|
2020-04-25 20:34:58 +02:00
|
|
|
void dict_splitFaces( DictionaryCtxt* dict, XWEnv xwe, const XP_U8* bytes,
|
|
|
|
XP_U16 nBytes, XP_U16 nFaceos );
|
2020-05-01 18:18:27 +02:00
|
|
|
void computeChecksum( DictionaryCtxt* dctxt, XWEnv xwe, const XP_U8* ptr,
|
|
|
|
XP_U32 len, XP_UCHAR* out );
|
|
|
|
|
|
|
|
/* Utility used only by dict-parsing code for now */
|
|
|
|
#define CHECK_PTR(p,c,e,lab) \
|
|
|
|
if ( ((p)+(c)) > (e) ) { \
|
|
|
|
XP_LOGF( "%s (line %d); out of bytes", __func__, __LINE__ ); \
|
|
|
|
goto lab; \
|
|
|
|
}
|
2011-11-09 15:51:12 +01:00
|
|
|
|
2003-11-01 06:35:29 +01:00
|
|
|
#ifdef CPLUS
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|