xref: /trunk/main/autodoc/source/parser/inc/tokens/tkpcontx.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_TKPCONTX_HXX
29 #define ADC_TKPCONTX_HXX
30 
31 // USED SERVICES
32     // BASE CLASSES
33     // COMPONENTS
34     // PARAMETERS
35 #include <tokens/token.hxx>
36 class CharacterSource;
37 class TkpNullContext;
38 
39 /** @task
40     Specifies a context within which tokens are interpreted in a special
41     way. For example in parsing C++ there could be a context for code,
42     one for comments and a third one for preprocessor statements, because
43     each of these would give the same token different meanings.
44 
45     The three functions
46             ReadCharChain()
47             PassNewToken()
48             FollowUpContext()
49     have to be called in this sequence.
50 
51 **/
52 class TkpContext
53 {
54   public:
55     // LIFECYCLE
56     virtual                 ~TkpContext() {}
57 
58     // OPERATIONS
59     /** @descr
60         The functions starts to parse with the CurChar() of io_rText.
61         It leaves io_rText.CurChar() at the first char of the following Token or
62         the following Context.
63 
64         This function returns, when a context has parsed some characterss
65         and completed a token OR left the context.
66         If the token is to be ignored, it is cut from io_rText.
67 
68         If the token is to be parsed further in a different context,
69         it is NOT cut from io_rText.
70 
71         After this function PassNewToken() has to be called.
72 
73         If the function has found a valid and complete token, PassNewToken()
74         passes the parsed token to the internally known receiver and
75         returns true. The token is cut from io_rText.
76     **/
77     virtual void        ReadCharChain(
78                             CharacterSource &   io_rText ) = 0;
79     /** Has to pass the parsed token to a known receiver.
80         If the token is to be parsed further in a different context,
81         PassNewToken() returns false, but the token is NOT cut from io_rText.
82 
83         @return true, if a token was passed.
84                 false, if the token was not parsed completely by this context
85                        or if the token is to be ignored.
86     */
87     virtual bool        PassNewToken() = 0;
88     virtual TkpContext &
89                         FollowUpContext() = 0;
90 
91     static TkpNullContext &
92                         Null_();
93 };
94 
95 class StateMachineContext
96 {
97   public:
98     typedef TextToken::F_CRTOK F_CRTOK;
99 
100     virtual ~StateMachineContext() {}
101 
102     /// Is used by StmBoundsStatus only.
103     virtual void        PerformStatusFunction(
104                             uintt               i_nStatusSignal,
105                             F_CRTOK             i_fTokenCreateFunction,
106                             CharacterSource &   io_rText ) = 0;
107 };
108 
109 class TkpNullContext : public TkpContext
110 {
111   public:
112                         ~TkpNullContext();
113 
114     virtual void        ReadCharChain(
115                             CharacterSource &   io_rText );
116     virtual bool        PassNewToken();
117     virtual TkpContext &
118                         FollowUpContext();
119 };
120 
121 namespace autodoc
122 {
123 
124 class TkpDocuContext : public TkpContext
125 {
126   public:
127     virtual void        SetParentContext(
128                             TkpContext &        io_rParentContext,
129                             const char *        i_sMultiLineEndToken ) = 0;
130     virtual void        AssignDealer(
131                             TokenDealer &       o_rDealer ) = 0;
132     virtual void        SetMode_IsMultiLine(
133                             bool                i_bTrue ) = 0;
134 };
135 
136 } // namespace autodoc
137 
138 #endif
139 
140 
141