1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #ifndef ADC_PARSEINC_HXX
25 #define ADC_PARSEINC_HXX
26
27
28 #include <tools/tkpchars.hxx>
29
30 inline char
jumpOver(CharacterSource & io_rText,char in_c)31 jumpOver( CharacterSource & io_rText,
32 char in_c )
33 {
34 char cNext;
35 for ( cNext = io_rText.CurChar();
36 cNext == in_c;
37 cNext = io_rText.MoveOn() )
38 { }
39
40 return cNext;
41 }
42
43 inline char
jumpTo(CharacterSource & io_rText,char in_c)44 jumpTo( CharacterSource & io_rText,
45 char in_c )
46 {
47 char cNext;
48 for ( cNext = io_rText.CurChar();
49 cNext != in_c AND cNext != 0;
50 cNext = io_rText.MoveOn() )
51 { }
52
53 return cNext;
54 }
55
56 inline char
jumpTo(CharacterSource & io_rText,char in_c1,char in_c2)57 jumpTo( CharacterSource & io_rText,
58 char in_c1,
59 char in_c2 )
60 {
61 char cNext;
62 for ( cNext = io_rText.CurChar();
63 cNext != in_c1 AND cNext != in_c2 AND cNext != 0;
64 cNext = io_rText.MoveOn() )
65 { }
66
67 return cNext;
68 }
69
70 inline char
jumpTo(CharacterSource & io_rText,char in_c1,char in_c2,char in_c3)71 jumpTo( CharacterSource & io_rText,
72 char in_c1,
73 char in_c2,
74 char in_c3 )
75 {
76 char cNext;
77 for ( cNext = io_rText.CurChar();
78 cNext != in_c1 AND cNext != in_c2 AND cNext != in_c3 AND cNext != 0;
79 cNext = io_rText.MoveOn() )
80 { }
81
82 return cNext;
83 }
84
85 inline char
jumpTo(CharacterSource & io_rText,char in_c1,char in_c2,char in_c3,char in_c4)86 jumpTo( CharacterSource & io_rText,
87 char in_c1,
88 char in_c2,
89 char in_c3,
90 char in_c4 )
91 {
92 char cNext;
93 for ( cNext = io_rText.CurChar();
94 cNext != in_c1 AND cNext != in_c2 AND cNext != in_c3
95 AND cNext != in_c4 AND cNext != 0;
96 cNext = io_rText.MoveOn() )
97 { }
98
99 return cNext;
100 }
101
102 inline char
jumpOverWhite(CharacterSource & io_rText)103 jumpOverWhite(CharacterSource & io_rText)
104 {
105 char cNext;
106 for ( cNext = io_rText.CurChar();
107 static_cast<UINT8>(cNext) < 33
108 AND cNext != 0 AND cNext != 13 AND cNext != 10;
109 cNext = io_rText.MoveOn() )
110 { }
111
112 return cNext;
113 }
114
115 inline char
jumpToWhite(CharacterSource & io_rText)116 jumpToWhite(CharacterSource & io_rText)
117 {
118 char cNext;
119 for ( cNext = io_rText.CurChar();
120 static_cast<UINT8>(cNext) > 32;
121 cNext = io_rText.MoveOn() )
122 { }
123
124 return cNext;
125 }
126
127 inline char
jumpToEol(CharacterSource & io_rText,int & o_rCount_BackslashedLineBreaks)128 jumpToEol(CharacterSource & io_rText, int & o_rCount_BackslashedLineBreaks )
129 {
130 o_rCount_BackslashedLineBreaks = 0;
131 char cNext;
132 for ( cNext = io_rText.CurChar();
133 cNext != 13 AND cNext != 10 AND cNext != NULCH;
134 cNext = io_rText.MoveOn() )
135 {
136 if ( cNext == '\\')
137 {
138 cNext = io_rText.MoveOn();
139 if ( cNext == 13 )
140 io_rText.MoveOn();
141 if ( cNext == 10 )
142 ++o_rCount_BackslashedLineBreaks;
143 }
144 }
145 return cNext;
146 }
147
148 inline char
jumpToEol(CharacterSource & io_rText)149 jumpToEol(CharacterSource & io_rText)
150 {
151 char cNext;
152 for ( cNext = io_rText.CurChar();
153 cNext != 13 AND cNext != 10 AND cNext != NULCH;
154 cNext = io_rText.MoveOn() )
155 {
156 if ( cNext == '\\')
157 io_rText.MoveOn();
158 }
159 return cNext;
160 }
161
162 inline char
jumpOverEol(CharacterSource & io_rText)163 jumpOverEol(CharacterSource & io_rText)
164 {
165 char cNext = io_rText.CurChar();
166
167 if (cNext == 13)
168 io_rText.MoveOn();
169 if (cNext == 10)
170 io_rText.MoveOn();
171 return cNext;
172 }
173
174
175 inline char // Finds a matching closing bracket after the opening one is passed
jumpToMatchingBracket(CharacterSource & io_rText,char in_cBegin,char in_cEnd)176 jumpToMatchingBracket( CharacterSource & io_rText,
177 char in_cBegin,
178 char in_cEnd )
179 {
180 intt nCounter = 1;
181 char cNext;
182 for ( cNext = io_rText.CurChar();
183 nCounter - (cNext == in_cEnd ? 1 : 0) > 0 AND cNext != NULCH;
184 cNext = io_rText.MoveOn() )
185 {
186 if (cNext == in_cEnd)
187 nCounter++;
188 else if (cNext == in_cBegin)
189 nCounter--;
190 }
191
192 return cNext;
193 }
194
195
196
197
198 #endif
199
200