xref: /trunk/main/autodoc/source/parser_i/inc/tokens/tkpstam2.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef ADC_TKPSTAM2_HXX
29 #define ADC_TKPSTAM2_HXX
30 
31 // USED SERVICES
32     // BASE CLASSES
33 #include <tokens/tkpcont2.hxx>
34     // COMPONENTS
35 #include <tokens/stmstar2.hxx>
36 #include <tokens/stmstfi2.hxx>
37 
38 /** @descr
39     This state-machine models state transitions from one state to another
40     per indices of branches. If the indices represent ascii-char-values,
41     the state-machine can be used for recognising tokens of text.
42 
43     The state-machine can be a status itself.
44 
45     StateMachin2 needs the array-size of all stati as a guess, how many stati
46     the state machine will contain, when at work.
47 
48 
49 **/
50 class StateMachin2
51 {
52     public:
53         // Types
54         typedef StmStatu2::Branch   Branch;
55         typedef StmStatu2 * *       StatusList;
56 
57     //# Interface self
58         // LIFECYCLE
59                         StateMachin2(
60                             intt            in_nStatusSize,
61                             intt            in_nInitial_StatusListSize );   /// The user of the constructor should guess
62                                                                             ///   the approximate number of stati here to
63                                                                             ///   avoid multiple reallocations.
64         /// @#AddStatus
65         intt            AddStatus(      /// @return the new #Status' ID
66                             DYN StmStatu2 * let_dpStatus);
67         /// @#AddToken
68         void            AddToken(
69                             const char *        in_sToken,
70                             UINT16              in_nTokenId,
71                             const INT16 *       in_aBranches,
72                             INT16               in_nBoundsStatus );
73                         ~StateMachin2();
74 
75         // OPERATIONS
76         StmBoundsStatu2 &
77                         GetCharChain(
78                             UINT16 &            o_nTokenId,
79                             CharacterSource &   io_rText );
80     private:
81         // SERVICE FUNCTIONS
82         StmStatu2 &     Status(
83                             intt            in_nStatusNr) const;
84         StmArrayStatu2 &
85                         CurrentStatus() const;
86         StmBoundsStatu2 *
87                         BoundsStatus() const;
88 
89         /// Sets the PeekedStatus.
90         void            Peek(
91                             intt            in_nBranch);
92 
93         void            ResizeStati();      // Adds space for 32 stati.
94 
95         // DATA
96         StatusList      pStati;             /// List of Status, implemented as simple C-array of length #nStatiSpace
97                                             /// with nStatiLength valid members (beginning from zero).
98         intt            nCurrentStatus;
99         intt            nPeekedStatus;
100 
101         intt            nStatusSize;        /// Size of the branch array of a single status.
102 
103         intt            nNrofStati;         /// Nr of Stati so far.
104         intt            nStatiSpace;        /// Size of allocated array for #pStati (size in items).
105 };
106 
107 
108 
109 /** @#AddToken
110     @descr
111     Adds a token, which will be recogniszeds by the
112     statemachine.
113 
114 
115 **/
116 
117 
118 
119 #endif
120 
121 
122