Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef ADC_PARSEINC_HXX
21 : #define ADC_PARSEINC_HXX
22 :
23 :
24 : #include <tools/tkpchars.hxx>
25 :
26 : inline char
27 103250 : jumpOver( CharacterSource & io_rText,
28 : char in_c )
29 : {
30 : char cNext;
31 103250 : for ( cNext = io_rText.CurChar();
32 : cNext == in_c;
33 : cNext = io_rText.MoveOn() )
34 : { }
35 :
36 103250 : return cNext;
37 : }
38 :
39 : inline char
40 27471 : jumpTo( CharacterSource & io_rText,
41 : char in_c )
42 : {
43 : char cNext;
44 27471 : for ( cNext = io_rText.CurChar();
45 : cNext != in_c AND cNext != 0;
46 : cNext = io_rText.MoveOn() )
47 : { }
48 :
49 27471 : return cNext;
50 : }
51 :
52 : inline char
53 163249 : jumpTo( CharacterSource & io_rText,
54 : char in_c1,
55 : char in_c2 )
56 : {
57 : char cNext;
58 163249 : for ( cNext = io_rText.CurChar();
59 : cNext != in_c1 AND cNext != in_c2 AND cNext != 0;
60 : cNext = io_rText.MoveOn() )
61 : { }
62 :
63 163249 : return cNext;
64 : }
65 :
66 : inline char
67 15165 : jumpTo( CharacterSource & io_rText,
68 : char in_c1,
69 : char in_c2,
70 : char in_c3 )
71 : {
72 : char cNext;
73 15165 : for ( cNext = io_rText.CurChar();
74 : cNext != in_c1 AND cNext != in_c2 AND cNext != in_c3 AND cNext != 0;
75 : cNext = io_rText.MoveOn() )
76 : { }
77 :
78 15165 : return cNext;
79 : }
80 :
81 : inline char
82 3348 : jumpTo( CharacterSource & io_rText,
83 : char in_c1,
84 : char in_c2,
85 : char in_c3,
86 : char in_c4 )
87 : {
88 : char cNext;
89 3348 : for ( cNext = io_rText.CurChar();
90 : cNext != in_c1 AND cNext != in_c2 AND cNext != in_c3
91 : AND cNext != in_c4 AND cNext != 0;
92 : cNext = io_rText.MoveOn() )
93 : { }
94 :
95 3348 : return cNext;
96 : }
97 :
98 : inline char
99 : jumpOverWhite(CharacterSource & io_rText)
100 : {
101 : char cNext;
102 : for ( cNext = io_rText.CurChar();
103 : static_cast<UINT8>(cNext) < 33
104 : AND cNext != 0 AND cNext != 13 AND cNext != 10;
105 : cNext = io_rText.MoveOn() )
106 : { }
107 :
108 : return cNext;
109 : }
110 :
111 : inline char
112 1 : jumpToWhite(CharacterSource & io_rText)
113 : {
114 : char cNext;
115 1 : for ( cNext = io_rText.CurChar();
116 : static_cast<UINT8>(cNext) > 32;
117 : cNext = io_rText.MoveOn() )
118 : { }
119 :
120 1 : return cNext;
121 : }
122 :
123 : inline char
124 : jumpToEol(CharacterSource & io_rText, int & o_rCount_BackslashedLineBreaks )
125 : {
126 : o_rCount_BackslashedLineBreaks = 0;
127 : char cNext;
128 : for ( cNext = io_rText.CurChar();
129 : cNext != 13 AND cNext != 10 AND cNext != NULCH;
130 : cNext = io_rText.MoveOn() )
131 : {
132 : if ( cNext == '\\')
133 : {
134 : cNext = io_rText.MoveOn();
135 : if ( cNext == 13 )
136 : io_rText.MoveOn();
137 : if ( cNext == 10 )
138 : ++o_rCount_BackslashedLineBreaks;
139 : }
140 : }
141 : return cNext;
142 : }
143 :
144 : inline char
145 23515 : jumpToEol(CharacterSource & io_rText)
146 : {
147 : char cNext;
148 1017052 : for ( cNext = io_rText.CurChar();
149 : cNext != 13 AND cNext != 10 AND cNext != NULCH;
150 : cNext = io_rText.MoveOn() )
151 : {
152 993537 : if ( cNext == '\\')
153 0 : io_rText.MoveOn();
154 : }
155 23515 : return cNext;
156 : }
157 :
158 : inline char
159 23515 : jumpOverEol(CharacterSource & io_rText)
160 : {
161 23515 : char cNext = io_rText.CurChar();
162 :
163 23515 : if (cNext == 13)
164 0 : io_rText.MoveOn();
165 23515 : if (cNext == 10)
166 23515 : io_rText.MoveOn();
167 23515 : return cNext;
168 : }
169 :
170 :
171 : inline char // Finds a matching closing bracket after the opening one is passed
172 : jumpToMatchingBracket( CharacterSource & io_rText,
173 : char in_cBegin,
174 : char in_cEnd )
175 : {
176 : intt nCounter = 1;
177 : char cNext;
178 : for ( cNext = io_rText.CurChar();
179 : nCounter - (cNext == in_cEnd ? 1 : 0) > 0 AND cNext != NULCH;
180 : cNext = io_rText.MoveOn() )
181 : {
182 : if (cNext == in_cEnd)
183 : nCounter++;
184 : else if (cNext == in_cBegin)
185 : nCounter--;
186 : }
187 :
188 : return cNext;
189 : }
190 :
191 :
192 :
193 :
194 : #endif
195 :
196 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|