xref: /trunk/main/autodoc/source/parser/inc/tokens/parseinc.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_PARSEINC_HXX
29 #define ADC_PARSEINC_HXX
30 
31 
32 #include <tools/tkpchars.hxx>
33 
34 inline char
35 jumpOver( CharacterSource & io_rText,
36           char in_c )
37 {
38     char cNext;
39     for ( cNext = io_rText.CurChar();
40           cNext == in_c;
41           cNext = io_rText.MoveOn() )
42     { }
43 
44     return cNext;
45 }
46 
47 inline char
48 jumpTo( CharacterSource & io_rText,
49         char              in_c )
50 {
51     char cNext;
52     for ( cNext = io_rText.CurChar();
53           cNext != in_c AND cNext != 0;
54           cNext = io_rText.MoveOn() )
55     { }
56 
57     return cNext;
58 }
59 
60 inline char
61 jumpTo( CharacterSource & io_rText,
62         char              in_c1,
63         char              in_c2 )
64 {
65     char cNext;
66     for ( cNext = io_rText.CurChar();
67           cNext != in_c1 AND cNext != in_c2 AND cNext != 0;
68           cNext = io_rText.MoveOn() )
69     { }
70 
71     return cNext;
72 }
73 
74 inline char
75 jumpTo( CharacterSource & io_rText,
76         char              in_c1,
77         char              in_c2,
78         char              in_c3 )
79 {
80     char cNext;
81     for ( cNext = io_rText.CurChar();
82           cNext != in_c1 AND cNext != in_c2 AND cNext != in_c3 AND cNext != 0;
83           cNext = io_rText.MoveOn() )
84     { }
85 
86     return cNext;
87 }
88 
89 inline char
90 jumpTo( CharacterSource & io_rText,
91         char              in_c1,
92         char              in_c2,
93         char              in_c3,
94         char              in_c4 )
95 {
96     char cNext;
97     for ( cNext = io_rText.CurChar();
98           cNext != in_c1 AND cNext != in_c2 AND cNext != in_c3
99                          AND cNext != in_c4 AND cNext != 0;
100           cNext = io_rText.MoveOn() )
101     { }
102 
103     return cNext;
104 }
105 
106 inline char
107 jumpOverWhite(CharacterSource & io_rText)
108 {
109     char cNext;
110     for ( cNext = io_rText.CurChar();
111           static_cast<UINT8>(cNext) < 33
112             AND cNext != 0 AND cNext != 13 AND cNext != 10;
113           cNext = io_rText.MoveOn() )
114     { }
115 
116     return cNext;
117 }
118 
119 inline char
120 jumpToWhite(CharacterSource & io_rText)
121 {
122     char cNext;
123     for ( cNext = io_rText.CurChar();
124           static_cast<UINT8>(cNext) > 32;
125           cNext = io_rText.MoveOn() )
126     { }
127 
128     return cNext;
129 }
130 
131 inline char
132 jumpToEol(CharacterSource & io_rText, int & o_rCount_BackslashedLineBreaks )
133 {
134     o_rCount_BackslashedLineBreaks = 0;
135     char cNext;
136     for ( cNext = io_rText.CurChar();
137           cNext != 13 AND cNext != 10 AND cNext != NULCH;
138           cNext = io_rText.MoveOn() )
139     {
140         if ( cNext == '\\')
141         {
142             cNext = io_rText.MoveOn();
143             if ( cNext == 13 )
144                 io_rText.MoveOn();
145             if ( cNext == 10 )
146                 ++o_rCount_BackslashedLineBreaks;
147         }
148     }
149     return cNext;
150 }
151 
152 inline char
153 jumpToEol(CharacterSource & io_rText)
154 {
155     char cNext;
156     for ( cNext = io_rText.CurChar();
157           cNext != 13 AND cNext != 10 AND cNext != NULCH;
158           cNext = io_rText.MoveOn() )
159     {
160         if ( cNext == '\\')
161             io_rText.MoveOn();
162     }
163     return cNext;
164 }
165 
166 inline char
167 jumpOverEol(CharacterSource & io_rText)
168 {
169     char cNext = io_rText.CurChar();
170 
171     if (cNext == 13)
172         io_rText.MoveOn();
173     if (cNext == 10)
174         io_rText.MoveOn();
175     return cNext;
176 }
177 
178 
179 inline char // Finds a matching closing bracket after the opening one is passed
180 jumpToMatchingBracket( CharacterSource & io_rText,
181                        char              in_cBegin,
182                        char              in_cEnd )
183 {
184     intt nCounter = 1;
185     char cNext;
186     for ( cNext = io_rText.CurChar();
187           nCounter - (cNext == in_cEnd ? 1 : 0) > 0 AND cNext != NULCH;
188           cNext = io_rText.MoveOn() )
189     {
190         if (cNext == in_cEnd)
191            nCounter++;
192         else if (cNext == in_cBegin)
193            nCounter--;
194     }
195 
196     return cNext;
197 }
198 
199 
200 
201 
202 #endif
203 
204