Update ooo320-m1
[ooovba.git] / autodoc / source / parser / inc / tokens / tkpstama.hxx
blobfed4e837d4c6c613bd3917d7587b219979e38937
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tkpstama.hxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef ADC_TKPSTAMA_HXX
32 #define ADC_TKPSTAMA_HXX
34 // USED SERVICES
35 // BASE CLASSES
36 #include <tokens/tkpcontx.hxx>
37 // COMPONENTS
38 #include <tokens/stmstarr.hxx>
39 #include <tokens/stmstfin.hxx>
41 /** @descr
42 This state-machine models state transitions from one state to another
43 per indices of branches. If the indices represent ascii-char-values,
44 the state-machine can be used for recognising tokens of text.
46 The state-machine can be a status itself.
48 StateMachine needs the array-size of all stati as a guess, how many stati
49 the state machine will contain, when at work.
52 **/
53 class StateMachine
55 public:
56 // Types
57 typedef StmStatus::Branch Branch;
58 typedef StmStatus * * StatusList;
60 //# Interface self
61 // LIFECYCLE
62 StateMachine(
63 intt in_nStatusSize,
64 intt in_nInitial_StatusListSize ); /// The user of the constructor should guess
65 /// the approximate number of stati here to
66 /// avoid multiple reallocations.
67 /// @#AddStatus
68 intt AddStatus( /// @return the new #Status' ID
69 DYN StmStatus * let_dpStatus);
70 /// @#AddToken
71 void AddToken(
72 const char * in_sToken,
73 TextToken::F_CRTOK in_fTokenCreateFunction,
74 const INT16 * in_aBranches,
75 INT16 in_nBoundsStatus );
76 ~StateMachine();
79 // OPERATIONS
80 StmBoundsStatus &
81 GetCharChain(
82 TextToken::F_CRTOK &
83 o_nTokenCreateFunction,
84 CharacterSource & io_rText );
85 private:
86 // SERVICE FUNCTIONS
87 StmStatus & Status(
88 intt in_nStatusNr) const;
89 StmArrayStatus &
90 CurrentStatus() const;
91 StmBoundsStatus *
92 BoundsStatus() const;
94 /// Sets the PeekedStatus.
95 void Peek(
96 intt in_nBranch);
98 void ResizeStati(); // Adds space for 32 stati.
100 // DATA
101 StatusList pStati; /// List of Status, implemented as simple C-array of length #nStatiSpace
102 /// with nStatiLength valid members (beginning from zero).
103 intt nCurrentStatus;
104 intt nPeekedStatus;
106 intt nStatusSize; /// Size of the branch array of a single status.
108 intt nNrofStati; /// Nr of Stati so far.
109 intt nStatiSpace; /// Size of allocated array for #pStati (size in items).
114 /** @#AddToken
115 @descr
116 Adds a token, which will be recogniszeds by the
117 statemachine.
124 #endif