Update ooo320-m1
[ooovba.git] / autodoc / source / parser_i / inc / tokens / tkpstam2.hxx
blobd913e2ce4ffa6cf43218c316aa9b6b088bf769b1
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: tkpstam2.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_TKPSTAM2_HXX
32 #define ADC_TKPSTAM2_HXX
34 // USED SERVICES
35 // BASE CLASSES
36 #include <tokens/tkpcont2.hxx>
37 // COMPONENTS
38 #include <tokens/stmstar2.hxx>
39 #include <tokens/stmstfi2.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 StateMachin2 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 StateMachin2
55 public:
56 // Types
57 typedef StmStatu2::Branch Branch;
58 typedef StmStatu2 * * StatusList;
60 //# Interface self
61 // LIFECYCLE
62 StateMachin2(
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 StmStatu2 * let_dpStatus);
70 /// @#AddToken
71 void AddToken(
72 const char * in_sToken,
73 UINT16 in_nTokenId,
74 const INT16 * in_aBranches,
75 INT16 in_nBoundsStatus );
76 ~StateMachin2();
78 // OPERATIONS
79 StmBoundsStatu2 &
80 GetCharChain(
81 UINT16 & o_nTokenId,
82 CharacterSource & io_rText );
83 private:
84 // SERVICE FUNCTIONS
85 StmStatu2 & Status(
86 intt in_nStatusNr) const;
87 StmArrayStatu2 &
88 CurrentStatus() const;
89 StmBoundsStatu2 *
90 BoundsStatus() const;
92 /// Sets the PeekedStatus.
93 void Peek(
94 intt in_nBranch);
96 void ResizeStati(); // Adds space for 32 stati.
98 // DATA
99 StatusList pStati; /// List of Status, implemented as simple C-array of length #nStatiSpace
100 /// with nStatiLength valid members (beginning from zero).
101 intt nCurrentStatus;
102 intt nPeekedStatus;
104 intt nStatusSize; /// Size of the branch array of a single status.
106 intt nNrofStati; /// Nr of Stati so far.
107 intt nStatiSpace; /// Size of allocated array for #pStati (size in items).
112 /** @#AddToken
113 @descr
114 Adds a token, which will be recogniszeds by the
115 statemachine.
122 #endif