xref: /trunk/main/autodoc/source/parser/inc/tokens/tkpstama.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_TKPSTAMA_HXX
29 #define ADC_TKPSTAMA_HXX
30 
31 // USED SERVICES
32     // BASE CLASSES
33 #include <tokens/tkpcontx.hxx>
34     // COMPONENTS
35 #include <tokens/stmstarr.hxx>
36 #include <tokens/stmstfin.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     StateMachine 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 StateMachine
51 {
52     public:
53         // Types
54         typedef StmStatus::Branch   Branch;
55         typedef StmStatus * *       StatusList;
56 
57     //# Interface self
58         // LIFECYCLE
59                         StateMachine(
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 StmStatus * let_dpStatus);
67         /// @#AddToken
68         void            AddToken(
69                             const char *        in_sToken,
70                             TextToken::F_CRTOK  in_fTokenCreateFunction,
71                             const INT16 *       in_aBranches,
72                             INT16               in_nBoundsStatus );
73                         ~StateMachine();
74 
75 
76         // OPERATIONS
77         StmBoundsStatus &
78                         GetCharChain(
79                             TextToken::F_CRTOK &
80                                                 o_nTokenCreateFunction,
81                             CharacterSource &   io_rText );
82     private:
83         // SERVICE FUNCTIONS
84         StmStatus &     Status(
85                             intt            in_nStatusNr) const;
86         StmArrayStatus &
87                         CurrentStatus() const;
88         StmBoundsStatus *
89                         BoundsStatus() const;
90 
91         /// Sets the PeekedStatus.
92         void            Peek(
93                             intt            in_nBranch);
94 
95         void            ResizeStati();      // Adds space for 32 stati.
96 
97         // DATA
98         StatusList      pStati;             /// List of Status, implemented as simple C-array of length #nStatiSpace
99                                             /// with nStatiLength valid members (beginning from zero).
100         intt            nCurrentStatus;
101         intt            nPeekedStatus;
102 
103         intt            nStatusSize;        /// Size of the branch array of a single status.
104 
105         intt            nNrofStati;         /// Nr of Stati so far.
106         intt            nStatiSpace;        /// Size of allocated array for #pStati (size in items).
107 };
108 
109 
110 
111 /** @#AddToken
112     @descr
113     Adds a token, which will be recogniszeds by the
114     statemachine.
115 
116 
117 **/
118 
119 
120 
121 #endif
122 
123 
124