libDtSearch: Remove optional code for NO_DBN which is not used on CDE
[oweals/cde.git] / cde / programs / nsgmls / TrieBuilder.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: TrieBuilder.h /main/1 1996/07/29 17:06:48 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
26
27 #ifndef TrieBuilder_INCLUDED
28 #define TrieBuilder_INCLUDED 1
29 #ifdef __GNUG__
30 #pragma interface
31 #endif
32
33 #include "types.h"
34 #include "StringOf.h"
35 #include "Owner.h"
36 #include "Trie.h"
37 #include "Vector.h"
38
39 #ifdef SP_NAMESPACE
40 namespace SP_NAMESPACE {
41 #endif
42
43 class TrieBuilder {
44 public:
45   typedef Vector<Token> TokenVector;
46   TrieBuilder(int nCodes);
47   void recognize(const String<EquivCode> &chars,
48                  Token t,
49                  Priority::Type pri,
50                  TokenVector &ambiguities);
51   void recognize(const String<EquivCode> &chars,
52                  const String<EquivCode> &set,
53                  Token t,
54                  Priority::Type pri,
55                  TokenVector &ambiguities);
56   // recognize a delimiter with a blank sequence
57   void recognizeB(const String<EquivCode> &chars,
58                   int bSequenceLength, // >= 1
59                   size_t maxBlankSequenceLength,
60                   const String<EquivCode> &blankCodes,
61                   const String<EquivCode> &chars2,
62                   Token t,
63                   TokenVector &ambiguities);
64   void recognizeEE(EquivCode code, Token t);
65   Trie *extractTrie() { return root_.extract(); }
66 private:
67   TrieBuilder(const TrieBuilder &); // undefined
68   void operator=(const TrieBuilder &); // undefined
69   void doB(Trie *trie,
70            int tokenLength,
71            int minBLength,
72            size_t maxLength,
73            const String<EquivCode> &blankCodes,
74            const String<EquivCode> &chars2,
75            Token token,
76            Priority::Type pri,
77            TokenVector &ambiguities);
78   Trie *extendTrie(Trie *, const String<EquivCode> &);
79   void setToken(Trie *trie, int tokenLength, Token token, Priority::Type pri,
80                 TokenVector &ambiguities);
81
82   Trie *forceNext(Trie *trie, EquivCode);
83   void copyInto(Trie *, const Trie *, int);
84
85   int nCodes_;
86   Owner<Trie> root_;
87 };
88
89 #ifdef SP_NAMESPACE
90 }
91 #endif
92
93 #endif /* not TrieBuilder_INCLUDED */