xref: /AOO41X/main/autodoc/source/parser_i/inc/tokens/tkpstam2.hxx (revision 1c78a5d6c0093dece4c096ba53051800fbad6e33)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef ADC_TKPSTAM2_HXX
25 #define ADC_TKPSTAM2_HXX
26 
27 // USED SERVICES
28     // BASE CLASSES
29 #include <tokens/tkpcont2.hxx>
30     // COMPONENTS
31 #include <tokens/stmstar2.hxx>
32 #include <tokens/stmstfi2.hxx>
33 
34 /** @descr
35     This state-machine models state transitions from one state to another
36     per indices of branches. If the indices represent ascii-char-values,
37     the state-machine can be used for recognising tokens of text.
38 
39     The state-machine can be a status itself.
40 
41     StateMachin2 needs the array-size of all stati as a guess, how many stati
42     the state machine will contain, when at work.
43 
44 
45 **/
46 class StateMachin2
47 {
48     public:
49         // Types
50         typedef StmStatu2::Branch   Branch;
51         typedef StmStatu2 * *       StatusList;
52 
53     //# Interface self
54         // LIFECYCLE
55                         StateMachin2(
56                             intt            in_nStatusSize,
57                             intt            in_nInitial_StatusListSize );   /// The user of the constructor should guess
58                                                                             ///   the approximate number of stati here to
59                                                                             ///   avoid multiple reallocations.
60         /// @#AddStatus
61         intt            AddStatus(      /// @return the new #Status' ID
62                             DYN StmStatu2 * let_dpStatus);
63         /// @#AddToken
64         void            AddToken(
65                             const char *        in_sToken,
66                             UINT16              in_nTokenId,
67                             const INT16 *       in_aBranches,
68                             INT16               in_nBoundsStatus );
69                         ~StateMachin2();
70 
71         // OPERATIONS
72         StmBoundsStatu2 &
73                         GetCharChain(
74                             UINT16 &            o_nTokenId,
75                             CharacterSource &   io_rText );
76     private:
77         // SERVICE FUNCTIONS
78         StmStatu2 &     Status(
79                             intt            in_nStatusNr) const;
80         StmArrayStatu2 &
81                         CurrentStatus() const;
82         StmBoundsStatu2 *
83                         BoundsStatus() const;
84 
85         /// Sets the PeekedStatus.
86         void            Peek(
87                             intt            in_nBranch);
88 
89         void            ResizeStati();      // Adds space for 32 stati.
90 
91         // DATA
92         StatusList      pStati;             /// List of Status, implemented as simple C-array of length #nStatiSpace
93                                             /// with nStatiLength valid members (beginning from zero).
94         intt            nCurrentStatus;
95         intt            nPeekedStatus;
96 
97         intt            nStatusSize;        /// Size of the branch array of a single status.
98 
99         intt            nNrofStati;         /// Nr of Stati so far.
100         intt            nStatiSpace;        /// Size of allocated array for #pStati (size in items).
101 };
102 
103 
104 
105 /** @#AddToken
106     @descr
107     Adds a token, which will be recogniszeds by the
108     statemachine.
109 
110 
111 **/
112 
113 
114 
115 #endif
116 
117 
118