1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tkpstama.hxx,v $
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
36 #include <tokens/tkpcontx.hxx>
38 #include <tokens/stmstarr.hxx>
39 #include <tokens/stmstfin.hxx>
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.
57 typedef StmStatus::Branch Branch
;
58 typedef StmStatus
* * StatusList
;
64 intt in_nInitial_StatusListSize
); /// The user of the constructor should guess
65 /// the approximate number of stati here to
66 /// avoid multiple reallocations.
68 intt
AddStatus( /// @return the new #Status' ID
69 DYN StmStatus
* let_dpStatus
);
72 const char * in_sToken
,
73 TextToken::F_CRTOK in_fTokenCreateFunction
,
74 const INT16
* in_aBranches
,
75 INT16 in_nBoundsStatus
);
83 o_nTokenCreateFunction
,
84 CharacterSource
& io_rText
);
88 intt in_nStatusNr
) const;
90 CurrentStatus() const;
94 /// Sets the PeekedStatus.
98 void ResizeStati(); // Adds space for 32 stati.
101 StatusList pStati
; /// List of Status, implemented as simple C-array of length #nStatiSpace
102 /// with nStatiLength valid members (beginning from zero).
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).
116 Adds a token, which will be recogniszeds by the