/src/logging-log4cxx/src/main/cpp/patternparser.cpp
Line | Count | Source |
1 | | /* |
2 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
3 | | * contributor license agreements. See the NOTICE file distributed with |
4 | | * this work for additional information regarding copyright ownership. |
5 | | * The ASF licenses this file to You under the Apache License, Version 2.0 |
6 | | * (the "License"); you may not use this file except in compliance with |
7 | | * the License. You may obtain a copy of the License at |
8 | | * |
9 | | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | | * |
11 | | * Unless required by applicable law or agreed to in writing, software |
12 | | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | * See the License for the specific language governing permissions and |
15 | | * limitations under the License. |
16 | | */ |
17 | | |
18 | | #include <log4cxx/logstring.h> |
19 | | #include <log4cxx/pattern/patternparser.h> |
20 | | #include <log4cxx/pattern/literalpatternconverter.h> |
21 | | #include <log4cxx/helpers/loglog.h> |
22 | | |
23 | | using namespace LOG4CXX_NS; |
24 | | using namespace LOG4CXX_NS::pattern; |
25 | | using namespace LOG4CXX_NS::helpers; |
26 | | |
27 | | const logchar PatternParser::ESCAPE_CHAR = 0x25; // '%' |
28 | | |
29 | | |
30 | | /** |
31 | | * Private constructor. |
32 | | */ |
33 | | PatternParser::PatternParser() |
34 | 0 | { |
35 | 0 | } |
36 | | |
37 | | bool PatternParser::isUnicodeIdentifierStart(logchar ch) |
38 | 1.17M | { |
39 | | // |
40 | | // greatly simplified version checks if |
41 | | // character is USACII alpha or number |
42 | | // |
43 | 1.17M | return (ch >= 0x41 /* 'A' */ && ch <= 0x5A /* 'Z' */) || |
44 | 975k | (ch >= 0x61 /* 'a' */ && ch <= 0x7A /* 'z' */) || |
45 | 311k | (ch >= 0x30 /* '0' */ && ch <= 0x39 /* '9' */); |
46 | 1.17M | } log4cxx::pattern::PatternParser::isUnicodeIdentifierStart(char) Line | Count | Source | 38 | 635k | { | 39 | | // | 40 | | // greatly simplified version checks if | 41 | | // character is USACII alpha or number | 42 | | // | 43 | 635k | return (ch >= 0x41 /* 'A' */ && ch <= 0x5A /* 'Z' */) || | 44 | 570k | (ch >= 0x61 /* 'a' */ && ch <= 0x7A /* 'z' */) || | 45 | 167k | (ch >= 0x30 /* '0' */ && ch <= 0x39 /* '9' */); | 46 | 635k | } |
log4cxx::pattern::PatternParser::isUnicodeIdentifierStart(wchar_t) Line | Count | Source | 38 | 541k | { | 39 | | // | 40 | | // greatly simplified version checks if | 41 | | // character is USACII alpha or number | 42 | | // | 43 | 541k | return (ch >= 0x41 /* 'A' */ && ch <= 0x5A /* 'Z' */) || | 44 | 404k | (ch >= 0x61 /* 'a' */ && ch <= 0x7A /* 'z' */) || | 45 | 144k | (ch >= 0x30 /* '0' */ && ch <= 0x39 /* '9' */); | 46 | 541k | } |
|
47 | | |
48 | | bool PatternParser::isUnicodeIdentifierPart(logchar ch) |
49 | 957k | { |
50 | | // |
51 | | // greatly simplified version checks if |
52 | | // character is USACII alpha or number |
53 | | // |
54 | 957k | return isUnicodeIdentifierStart(ch) |
55 | 205k | || (ch == 0x5F /* '_' */); |
56 | 957k | } log4cxx::pattern::PatternParser::isUnicodeIdentifierPart(char) Line | Count | Source | 49 | 531k | { | 50 | | // | 51 | | // greatly simplified version checks if | 52 | | // character is USACII alpha or number | 53 | | // | 54 | 531k | return isUnicodeIdentifierStart(ch) | 55 | 96.6k | || (ch == 0x5F /* '_' */); | 56 | 531k | } |
log4cxx::pattern::PatternParser::isUnicodeIdentifierPart(wchar_t) Line | Count | Source | 49 | 425k | { | 50 | | // | 51 | | // greatly simplified version checks if | 52 | | // character is USACII alpha or number | 53 | | // | 54 | 425k | return isUnicodeIdentifierStart(ch) | 55 | 109k | || (ch == 0x5F /* '_' */); | 56 | 425k | } |
|
57 | | |
58 | | size_t PatternParser::extractConverter( |
59 | | logchar lastChar, const LogString& pattern, |
60 | | LogString::size_type i, LogString& convBuf, |
61 | | LogString& currentLiteral) |
62 | 219k | { |
63 | 219k | if (!convBuf.empty()) |
64 | 0 | { |
65 | 0 | convBuf.erase(convBuf.begin(), convBuf.end()); |
66 | 0 | } |
67 | | |
68 | | // When this method is called, lastChar points to the first character of the |
69 | | // conversion word. For example: |
70 | | // For "%hello" lastChar = 'h' |
71 | | // For "%-5hello" lastChar = 'h' |
72 | | //System.out.println("lastchar is "+lastChar); |
73 | 219k | if (!isUnicodeIdentifierStart(lastChar)) |
74 | 12.5k | { |
75 | 12.5k | return i; |
76 | 12.5k | } |
77 | | |
78 | 206k | convBuf.append(1, lastChar); |
79 | | |
80 | 206k | while ( |
81 | 959k | (i < pattern.length()) |
82 | 957k | && isUnicodeIdentifierPart(pattern[i])) |
83 | 752k | { |
84 | 752k | convBuf.append(1, pattern[i]); |
85 | 752k | currentLiteral.append(1, pattern[i]); |
86 | | |
87 | | //System.out.println("conv buffer is now ["+convBuf+"]."); |
88 | 752k | i++; |
89 | 752k | } |
90 | | |
91 | 206k | return i; |
92 | 219k | } log4cxx::pattern::PatternParser::extractConverter(char, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) Line | Count | Source | 62 | 103k | { | 63 | 103k | if (!convBuf.empty()) | 64 | 0 | { | 65 | 0 | convBuf.erase(convBuf.begin(), convBuf.end()); | 66 | 0 | } | 67 | | | 68 | | // When this method is called, lastChar points to the first character of the | 69 | | // conversion word. For example: | 70 | | // For "%hello" lastChar = 'h' | 71 | | // For "%-5hello" lastChar = 'h' | 72 | | //System.out.println("lastchar is "+lastChar); | 73 | 103k | if (!isUnicodeIdentifierStart(lastChar)) | 74 | 6.60k | { | 75 | 6.60k | return i; | 76 | 6.60k | } | 77 | | | 78 | 97.3k | convBuf.append(1, lastChar); | 79 | | | 80 | 97.3k | while ( | 81 | 532k | (i < pattern.length()) | 82 | 531k | && isUnicodeIdentifierPart(pattern[i])) | 83 | 435k | { | 84 | 435k | convBuf.append(1, pattern[i]); | 85 | 435k | currentLiteral.append(1, pattern[i]); | 86 | | | 87 | | //System.out.println("conv buffer is now ["+convBuf+"]."); | 88 | 435k | i++; | 89 | 435k | } | 90 | | | 91 | 97.3k | return i; | 92 | 103k | } |
log4cxx::pattern::PatternParser::extractConverter(wchar_t, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&, unsigned long, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&) Line | Count | Source | 62 | 115k | { | 63 | 115k | if (!convBuf.empty()) | 64 | 0 | { | 65 | 0 | convBuf.erase(convBuf.begin(), convBuf.end()); | 66 | 0 | } | 67 | | | 68 | | // When this method is called, lastChar points to the first character of the | 69 | | // conversion word. For example: | 70 | | // For "%hello" lastChar = 'h' | 71 | | // For "%-5hello" lastChar = 'h' | 72 | | //System.out.println("lastchar is "+lastChar); | 73 | 115k | if (!isUnicodeIdentifierStart(lastChar)) | 74 | 5.98k | { | 75 | 5.98k | return i; | 76 | 5.98k | } | 77 | | | 78 | 109k | convBuf.append(1, lastChar); | 79 | | | 80 | 109k | while ( | 81 | 426k | (i < pattern.length()) | 82 | 425k | && isUnicodeIdentifierPart(pattern[i])) | 83 | 316k | { | 84 | 316k | convBuf.append(1, pattern[i]); | 85 | 316k | currentLiteral.append(1, pattern[i]); | 86 | | | 87 | | //System.out.println("conv buffer is now ["+convBuf+"]."); | 88 | 316k | i++; | 89 | 316k | } | 90 | | | 91 | 109k | return i; | 92 | 115k | } |
|
93 | | |
94 | | |
95 | | size_t PatternParser::extractOptions(const LogString& pattern, LogString::size_type i, |
96 | | std::vector<LogString>& options) |
97 | 206k | { |
98 | 340k | while ((i < pattern.length()) && (pattern[i] == 0x7B /* '{' */)) |
99 | 134k | { |
100 | 134k | size_t end = pattern.find(0x7D /* '}' */, i); |
101 | | |
102 | 134k | if (end == pattern.npos) |
103 | 978 | { |
104 | 978 | break; |
105 | 978 | } |
106 | | |
107 | 133k | LogString r(pattern.substr(i + 1, end - i - 1)); |
108 | 133k | options.push_back(r); |
109 | 133k | i = end + 1; |
110 | 133k | } |
111 | | |
112 | 206k | return i; |
113 | 206k | } log4cxx::pattern::PatternParser::extractOptions(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&) Line | Count | Source | 97 | 97.3k | { | 98 | 163k | while ((i < pattern.length()) && (pattern[i] == 0x7B /* '{' */)) | 99 | 66.3k | { | 100 | 66.3k | size_t end = pattern.find(0x7D /* '}' */, i); | 101 | | | 102 | 66.3k | if (end == pattern.npos) | 103 | 509 | { | 104 | 509 | break; | 105 | 509 | } | 106 | | | 107 | 65.8k | LogString r(pattern.substr(i + 1, end - i - 1)); | 108 | 65.8k | options.push_back(r); | 109 | 65.8k | i = end + 1; | 110 | 65.8k | } | 111 | | | 112 | 97.3k | return i; | 113 | 97.3k | } |
log4cxx::pattern::PatternParser::extractOptions(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&, unsigned long, std::__1::vector<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::allocator<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > > >&) Line | Count | Source | 97 | 109k | { | 98 | 177k | while ((i < pattern.length()) && (pattern[i] == 0x7B /* '{' */)) | 99 | 68.1k | { | 100 | 68.1k | size_t end = pattern.find(0x7D /* '}' */, i); | 101 | | | 102 | 68.1k | if (end == pattern.npos) | 103 | 469 | { | 104 | 469 | break; | 105 | 469 | } | 106 | | | 107 | 67.6k | LogString r(pattern.substr(i + 1, end - i - 1)); | 108 | 67.6k | options.push_back(r); | 109 | 67.6k | i = end + 1; | 110 | 67.6k | } | 111 | | | 112 | 109k | return i; | 113 | 109k | } |
|
114 | | |
115 | | void PatternParser::parse( |
116 | | const LogString& pattern, |
117 | | std::vector<PatternConverterPtr>& patternConverters, |
118 | | std::vector<FormattingInfoPtr>& formattingInfos, |
119 | | const PatternMap& rules) |
120 | 9.51k | { |
121 | | |
122 | 9.51k | LogString currentLiteral; |
123 | | |
124 | 9.51k | size_t patternLength = pattern.length(); |
125 | 9.51k | int state = LITERAL_STATE; |
126 | 9.51k | logchar c; |
127 | 9.51k | size_t i = 0; |
128 | 9.51k | int minDigitCount{ 0 }, maxDigitCount{ 0 }; |
129 | 9.51k | FormattingInfoPtr formattingInfo(FormattingInfo::getDefault()); |
130 | | |
131 | 1.34M | while (i < patternLength) |
132 | 1.33M | { |
133 | 1.33M | c = pattern[i++]; |
134 | | |
135 | 1.33M | switch (state) |
136 | 1.33M | { |
137 | 1.02M | case LITERAL_STATE: |
138 | | |
139 | | // In literal state, the last char is always a literal. |
140 | 1.02M | if (i == patternLength) |
141 | 2.79k | { |
142 | 2.79k | currentLiteral.append(1, c); |
143 | | |
144 | 2.79k | continue; |
145 | 2.79k | } |
146 | | |
147 | 1.02M | if (c == ESCAPE_CHAR) |
148 | 225k | { |
149 | | // peek at the next char. |
150 | 225k | if (pattern[i] == ESCAPE_CHAR) |
151 | 3.37k | { |
152 | 3.37k | currentLiteral.append(1, c); |
153 | 3.37k | i++; // move pointer |
154 | 3.37k | } |
155 | 222k | else |
156 | 222k | { |
157 | 222k | if (!currentLiteral.empty()) |
158 | 66.1k | { |
159 | 66.1k | patternConverters.push_back( |
160 | 66.1k | LiteralPatternConverter::newInstance(currentLiteral)); |
161 | 66.1k | formattingInfos.push_back(FormattingInfo::getDefault()); |
162 | 66.1k | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); |
163 | 66.1k | } |
164 | | |
165 | 222k | currentLiteral.append(1, c); // append % |
166 | 222k | state = CONVERTER_STATE; |
167 | 222k | formattingInfo = FormattingInfo::getDefault(); |
168 | 222k | } |
169 | 225k | } |
170 | 794k | else |
171 | 794k | { |
172 | 794k | currentLiteral.append(1, c); |
173 | 794k | } |
174 | | |
175 | 1.02M | break; |
176 | | |
177 | 290k | case CONVERTER_STATE: |
178 | 290k | currentLiteral.append(1, c); |
179 | | |
180 | 290k | switch (c) |
181 | 290k | { |
182 | 68.2k | case 0x2D: // '-' |
183 | 68.2k | formattingInfo = std::make_shared<FormattingInfo>( |
184 | 68.2k | true, formattingInfo->getMinLength(), |
185 | 68.2k | formattingInfo->getMaxLength()); |
186 | | |
187 | 68.2k | break; |
188 | | |
189 | 4.58k | case 0x2E: // '.' |
190 | 4.58k | state = DOT_STATE; |
191 | | |
192 | 4.58k | break; |
193 | | |
194 | 217k | default: |
195 | | |
196 | 217k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */)) |
197 | 9.06k | { |
198 | 9.06k | formattingInfo = std::make_shared<FormattingInfo>( |
199 | 9.06k | formattingInfo->isLeftAligned(), c - 0x30 /* '0' */, |
200 | 9.06k | formattingInfo->getMaxLength()); |
201 | 9.06k | state = MIN_STATE; |
202 | 9.06k | minDigitCount = 1; |
203 | 9.06k | } |
204 | 208k | else |
205 | 208k | { |
206 | 208k | i = finalizeConverter( |
207 | 208k | c, pattern, i, currentLiteral, formattingInfo, |
208 | 208k | rules, patternConverters, formattingInfos); |
209 | | |
210 | | // Next pattern is assumed to be a literal. |
211 | 208k | state = LITERAL_STATE; |
212 | 208k | formattingInfo = FormattingInfo::getDefault(); |
213 | | |
214 | 208k | if (!currentLiteral.empty()) |
215 | 0 | { |
216 | 0 | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); |
217 | 0 | } |
218 | 208k | } |
219 | 290k | } // switch |
220 | | |
221 | 290k | break; |
222 | | |
223 | 290k | case MIN_STATE: |
224 | 11.7k | currentLiteral.append(1, c); |
225 | | |
226 | 11.7k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */) && minDigitCount < 3) |
227 | 2.77k | { |
228 | 2.77k | formattingInfo = std::make_shared<FormattingInfo>( |
229 | 2.77k | formattingInfo->isLeftAligned(), |
230 | 2.77k | (formattingInfo->getMinLength() * 10) + (c - 0x30 /* '0' */), |
231 | 2.77k | formattingInfo->getMaxLength()); |
232 | 2.77k | ++minDigitCount; |
233 | 2.77k | } |
234 | 8.97k | else if (c == 0x2E /* '.' */) |
235 | 1.67k | { |
236 | 1.67k | state = DOT_STATE; |
237 | 1.67k | } |
238 | 7.29k | else |
239 | 7.29k | { |
240 | 7.29k | i = finalizeConverter( |
241 | 7.29k | c, pattern, i, currentLiteral, formattingInfo, |
242 | 7.29k | rules, patternConverters, formattingInfos); |
243 | 7.29k | state = LITERAL_STATE; |
244 | 7.29k | formattingInfo = FormattingInfo::getDefault(); |
245 | | |
246 | 7.29k | if (!currentLiteral.empty()) |
247 | 0 | { |
248 | 0 | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); |
249 | 0 | } |
250 | 7.29k | } |
251 | | |
252 | 11.7k | break; |
253 | | |
254 | 6.23k | case DOT_STATE: |
255 | 6.23k | currentLiteral.append(1, c); |
256 | | |
257 | 6.23k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */)) |
258 | 3.91k | { |
259 | 3.91k | formattingInfo = std::make_shared<FormattingInfo>( |
260 | 3.91k | formattingInfo->isLeftAligned(), formattingInfo->getMinLength(), |
261 | 3.91k | c - 0x30 /* '0' */); |
262 | 3.91k | state = MAX_STATE; |
263 | 3.91k | maxDigitCount = 1; |
264 | 3.91k | } |
265 | 2.31k | else |
266 | 2.31k | { |
267 | 2.31k | LogLog::error(LOG4CXX_STR("Error in pattern, was expecting digit.")); |
268 | | |
269 | 2.31k | state = LITERAL_STATE; |
270 | 2.31k | } |
271 | | |
272 | 6.23k | break; |
273 | | |
274 | 6.04k | case MAX_STATE: |
275 | 6.04k | currentLiteral.append(1, c); |
276 | | |
277 | 6.04k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */) && maxDigitCount < 3) |
278 | 2.22k | { |
279 | 2.22k | formattingInfo = std::make_shared<FormattingInfo>( |
280 | 2.22k | formattingInfo->isLeftAligned(), formattingInfo->getMinLength(), |
281 | 2.22k | (formattingInfo->getMaxLength() * 10) + (c - 0x30 /* '0' */)); |
282 | 2.22k | ++maxDigitCount; |
283 | 2.22k | } |
284 | 3.82k | else |
285 | 3.82k | { |
286 | 3.82k | i = finalizeConverter( |
287 | 3.82k | c, pattern, i, currentLiteral, formattingInfo, |
288 | 3.82k | rules, patternConverters, formattingInfos); |
289 | 3.82k | state = LITERAL_STATE; |
290 | 3.82k | formattingInfo = FormattingInfo::getDefault(); |
291 | | |
292 | 3.82k | if (!currentLiteral.empty()) |
293 | 0 | { |
294 | 0 | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); |
295 | 0 | } |
296 | 3.82k | } |
297 | | |
298 | 6.04k | break; |
299 | 1.33M | } // switch |
300 | 1.33M | } |
301 | | |
302 | | // while |
303 | 9.51k | if (currentLiteral.length() != 0) |
304 | 3.21k | { |
305 | 3.21k | patternConverters.push_back( |
306 | 3.21k | LiteralPatternConverter::newInstance(currentLiteral)); |
307 | 3.21k | formattingInfos.push_back(FormattingInfo::getDefault()); |
308 | 3.21k | } |
309 | 9.51k | } log4cxx::pattern::PatternParser::parse(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::vector<std::__1::shared_ptr<log4cxx::pattern::PatternConverter>, std::__1::allocator<std::__1::shared_ptr<log4cxx::pattern::PatternConverter> > >&, std::__1::vector<std::__1::shared_ptr<log4cxx::pattern::FormattingInfo>, std::__1::allocator<std::__1::shared_ptr<log4cxx::pattern::FormattingInfo> > >&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::function<std::__1::shared_ptr<log4cxx::pattern::PatternConverter> (std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&)>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::function<std::__1::shared_ptr<log4cxx::pattern::PatternConverter> (std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&)> > > > const&) Line | Count | Source | 120 | 5.66k | { | 121 | | | 122 | 5.66k | LogString currentLiteral; | 123 | | | 124 | 5.66k | size_t patternLength = pattern.length(); | 125 | 5.66k | int state = LITERAL_STATE; | 126 | 5.66k | logchar c; | 127 | 5.66k | size_t i = 0; | 128 | 5.66k | int minDigitCount{ 0 }, maxDigitCount{ 0 }; | 129 | 5.66k | FormattingInfoPtr formattingInfo(FormattingInfo::getDefault()); | 130 | | | 131 | 588k | while (i < patternLength) | 132 | 582k | { | 133 | 582k | c = pattern[i++]; | 134 | | | 135 | 582k | switch (state) | 136 | 582k | { | 137 | 454k | case LITERAL_STATE: | 138 | | | 139 | | // In literal state, the last char is always a literal. | 140 | 454k | if (i == patternLength) | 141 | 2.27k | { | 142 | 2.27k | currentLiteral.append(1, c); | 143 | | | 144 | 2.27k | continue; | 145 | 2.27k | } | 146 | | | 147 | 452k | if (c == ESCAPE_CHAR) | 148 | 107k | { | 149 | | // peek at the next char. | 150 | 107k | if (pattern[i] == ESCAPE_CHAR) | 151 | 2.24k | { | 152 | 2.24k | currentLiteral.append(1, c); | 153 | 2.24k | i++; // move pointer | 154 | 2.24k | } | 155 | 105k | else | 156 | 105k | { | 157 | 105k | if (!currentLiteral.empty()) | 158 | 31.3k | { | 159 | 31.3k | patternConverters.push_back( | 160 | 31.3k | LiteralPatternConverter::newInstance(currentLiteral)); | 161 | 31.3k | formattingInfos.push_back(FormattingInfo::getDefault()); | 162 | 31.3k | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 163 | 31.3k | } | 164 | | | 165 | 105k | currentLiteral.append(1, c); // append % | 166 | 105k | state = CONVERTER_STATE; | 167 | 105k | formattingInfo = FormattingInfo::getDefault(); | 168 | 105k | } | 169 | 107k | } | 170 | 344k | else | 171 | 344k | { | 172 | 344k | currentLiteral.append(1, c); | 173 | 344k | } | 174 | | | 175 | 452k | break; | 176 | | | 177 | 115k | case CONVERTER_STATE: | 178 | 115k | currentLiteral.append(1, c); | 179 | | | 180 | 115k | switch (c) | 181 | 115k | { | 182 | 9.93k | case 0x2D: // '-' | 183 | 9.93k | formattingInfo = std::make_shared<FormattingInfo>( | 184 | 9.93k | true, formattingInfo->getMinLength(), | 185 | 9.93k | formattingInfo->getMaxLength()); | 186 | | | 187 | 9.93k | break; | 188 | | | 189 | 2.40k | case 0x2E: // '.' | 190 | 2.40k | state = DOT_STATE; | 191 | | | 192 | 2.40k | break; | 193 | | | 194 | 102k | default: | 195 | | | 196 | 102k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */)) | 197 | 5.72k | { | 198 | 5.72k | formattingInfo = std::make_shared<FormattingInfo>( | 199 | 5.72k | formattingInfo->isLeftAligned(), c - 0x30 /* '0' */, | 200 | 5.72k | formattingInfo->getMaxLength()); | 201 | 5.72k | state = MIN_STATE; | 202 | 5.72k | minDigitCount = 1; | 203 | 5.72k | } | 204 | 96.9k | else | 205 | 96.9k | { | 206 | 96.9k | i = finalizeConverter( | 207 | 96.9k | c, pattern, i, currentLiteral, formattingInfo, | 208 | 96.9k | rules, patternConverters, formattingInfos); | 209 | | | 210 | | // Next pattern is assumed to be a literal. | 211 | 96.9k | state = LITERAL_STATE; | 212 | 96.9k | formattingInfo = FormattingInfo::getDefault(); | 213 | | | 214 | 96.9k | if (!currentLiteral.empty()) | 215 | 0 | { | 216 | 0 | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 217 | 0 | } | 218 | 96.9k | } | 219 | 115k | } // switch | 220 | | | 221 | 115k | break; | 222 | | | 223 | 115k | case MIN_STATE: | 224 | 7.01k | currentLiteral.append(1, c); | 225 | | | 226 | 7.01k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */) && minDigitCount < 3) | 227 | 1.33k | { | 228 | 1.33k | formattingInfo = std::make_shared<FormattingInfo>( | 229 | 1.33k | formattingInfo->isLeftAligned(), | 230 | 1.33k | (formattingInfo->getMinLength() * 10) + (c - 0x30 /* '0' */), | 231 | 1.33k | formattingInfo->getMaxLength()); | 232 | 1.33k | ++minDigitCount; | 233 | 1.33k | } | 234 | 5.68k | else if (c == 0x2E /* '.' */) | 235 | 678 | { | 236 | 678 | state = DOT_STATE; | 237 | 678 | } | 238 | 5.00k | else | 239 | 5.00k | { | 240 | 5.00k | i = finalizeConverter( | 241 | 5.00k | c, pattern, i, currentLiteral, formattingInfo, | 242 | 5.00k | rules, patternConverters, formattingInfos); | 243 | 5.00k | state = LITERAL_STATE; | 244 | 5.00k | formattingInfo = FormattingInfo::getDefault(); | 245 | | | 246 | 5.00k | if (!currentLiteral.empty()) | 247 | 0 | { | 248 | 0 | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 249 | 0 | } | 250 | 5.00k | } | 251 | | | 252 | 7.01k | break; | 253 | | | 254 | 3.07k | case DOT_STATE: | 255 | 3.07k | currentLiteral.append(1, c); | 256 | | | 257 | 3.07k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */)) | 258 | 2.00k | { | 259 | 2.00k | formattingInfo = std::make_shared<FormattingInfo>( | 260 | 2.00k | formattingInfo->isLeftAligned(), formattingInfo->getMinLength(), | 261 | 2.00k | c - 0x30 /* '0' */); | 262 | 2.00k | state = MAX_STATE; | 263 | 2.00k | maxDigitCount = 1; | 264 | 2.00k | } | 265 | 1.06k | else | 266 | 1.06k | { | 267 | 1.06k | LogLog::error(LOG4CXX_STR("Error in pattern, was expecting digit.")); | 268 | | | 269 | 1.06k | state = LITERAL_STATE; | 270 | 1.06k | } | 271 | | | 272 | 3.07k | break; | 273 | | | 274 | 2.95k | case MAX_STATE: | 275 | 2.95k | currentLiteral.append(1, c); | 276 | | | 277 | 2.95k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */) && maxDigitCount < 3) | 278 | 995 | { | 279 | 995 | formattingInfo = std::make_shared<FormattingInfo>( | 280 | 995 | formattingInfo->isLeftAligned(), formattingInfo->getMinLength(), | 281 | 995 | (formattingInfo->getMaxLength() * 10) + (c - 0x30 /* '0' */)); | 282 | 995 | ++maxDigitCount; | 283 | 995 | } | 284 | 1.96k | else | 285 | 1.96k | { | 286 | 1.96k | i = finalizeConverter( | 287 | 1.96k | c, pattern, i, currentLiteral, formattingInfo, | 288 | 1.96k | rules, patternConverters, formattingInfos); | 289 | 1.96k | state = LITERAL_STATE; | 290 | 1.96k | formattingInfo = FormattingInfo::getDefault(); | 291 | | | 292 | 1.96k | if (!currentLiteral.empty()) | 293 | 0 | { | 294 | 0 | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 295 | 0 | } | 296 | 1.96k | } | 297 | | | 298 | 2.95k | break; | 299 | 582k | } // switch | 300 | 582k | } | 301 | | | 302 | | // while | 303 | 5.66k | if (currentLiteral.length() != 0) | 304 | 2.41k | { | 305 | 2.41k | patternConverters.push_back( | 306 | 2.41k | LiteralPatternConverter::newInstance(currentLiteral)); | 307 | 2.41k | formattingInfos.push_back(FormattingInfo::getDefault()); | 308 | 2.41k | } | 309 | 5.66k | } |
log4cxx::pattern::PatternParser::parse(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&, std::__1::vector<std::__1::shared_ptr<log4cxx::pattern::PatternConverter>, std::__1::allocator<std::__1::shared_ptr<log4cxx::pattern::PatternConverter> > >&, std::__1::vector<std::__1::shared_ptr<log4cxx::pattern::FormattingInfo>, std::__1::allocator<std::__1::shared_ptr<log4cxx::pattern::FormattingInfo> > >&, std::__1::map<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::function<std::__1::shared_ptr<log4cxx::pattern::PatternConverter> (std::__1::vector<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::allocator<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > > > const&)>, std::__1::less<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const, std::__1::function<std::__1::shared_ptr<log4cxx::pattern::PatternConverter> (std::__1::vector<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::allocator<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > > > const&)> > > > const&) Line | Count | Source | 120 | 3.84k | { | 121 | | | 122 | 3.84k | LogString currentLiteral; | 123 | | | 124 | 3.84k | size_t patternLength = pattern.length(); | 125 | 3.84k | int state = LITERAL_STATE; | 126 | 3.84k | logchar c; | 127 | 3.84k | size_t i = 0; | 128 | 3.84k | int minDigitCount{ 0 }, maxDigitCount{ 0 }; | 129 | 3.84k | FormattingInfoPtr formattingInfo(FormattingInfo::getDefault()); | 130 | | | 131 | 758k | while (i < patternLength) | 132 | 754k | { | 133 | 754k | c = pattern[i++]; | 134 | | | 135 | 754k | switch (state) | 136 | 754k | { | 137 | 568k | case LITERAL_STATE: | 138 | | | 139 | | // In literal state, the last char is always a literal. | 140 | 568k | if (i == patternLength) | 141 | 522 | { | 142 | 522 | currentLiteral.append(1, c); | 143 | | | 144 | 522 | continue; | 145 | 522 | } | 146 | | | 147 | 568k | if (c == ESCAPE_CHAR) | 148 | 118k | { | 149 | | // peek at the next char. | 150 | 118k | if (pattern[i] == ESCAPE_CHAR) | 151 | 1.13k | { | 152 | 1.13k | currentLiteral.append(1, c); | 153 | 1.13k | i++; // move pointer | 154 | 1.13k | } | 155 | 117k | else | 156 | 117k | { | 157 | 117k | if (!currentLiteral.empty()) | 158 | 34.7k | { | 159 | 34.7k | patternConverters.push_back( | 160 | 34.7k | LiteralPatternConverter::newInstance(currentLiteral)); | 161 | 34.7k | formattingInfos.push_back(FormattingInfo::getDefault()); | 162 | 34.7k | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 163 | 34.7k | } | 164 | | | 165 | 117k | currentLiteral.append(1, c); // append % | 166 | 117k | state = CONVERTER_STATE; | 167 | 117k | formattingInfo = FormattingInfo::getDefault(); | 168 | 117k | } | 169 | 118k | } | 170 | 449k | else | 171 | 449k | { | 172 | 449k | currentLiteral.append(1, c); | 173 | 449k | } | 174 | | | 175 | 568k | break; | 176 | | | 177 | 175k | case CONVERTER_STATE: | 178 | 175k | currentLiteral.append(1, c); | 179 | | | 180 | 175k | switch (c) | 181 | 175k | { | 182 | 58.3k | case 0x2D: // '-' | 183 | 58.3k | formattingInfo = std::make_shared<FormattingInfo>( | 184 | 58.3k | true, formattingInfo->getMinLength(), | 185 | 58.3k | formattingInfo->getMaxLength()); | 186 | | | 187 | 58.3k | break; | 188 | | | 189 | 2.17k | case 0x2E: // '.' | 190 | 2.17k | state = DOT_STATE; | 191 | | | 192 | 2.17k | break; | 193 | | | 194 | 114k | default: | 195 | | | 196 | 114k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */)) | 197 | 3.34k | { | 198 | 3.34k | formattingInfo = std::make_shared<FormattingInfo>( | 199 | 3.34k | formattingInfo->isLeftAligned(), c - 0x30 /* '0' */, | 200 | 3.34k | formattingInfo->getMaxLength()); | 201 | 3.34k | state = MIN_STATE; | 202 | 3.34k | minDigitCount = 1; | 203 | 3.34k | } | 204 | 111k | else | 205 | 111k | { | 206 | 111k | i = finalizeConverter( | 207 | 111k | c, pattern, i, currentLiteral, formattingInfo, | 208 | 111k | rules, patternConverters, formattingInfos); | 209 | | | 210 | | // Next pattern is assumed to be a literal. | 211 | 111k | state = LITERAL_STATE; | 212 | 111k | formattingInfo = FormattingInfo::getDefault(); | 213 | | | 214 | 111k | if (!currentLiteral.empty()) | 215 | 0 | { | 216 | 0 | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 217 | 0 | } | 218 | 111k | } | 219 | 175k | } // switch | 220 | | | 221 | 175k | break; | 222 | | | 223 | 175k | case MIN_STATE: | 224 | 4.73k | currentLiteral.append(1, c); | 225 | | | 226 | 4.73k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */) && minDigitCount < 3) | 227 | 1.44k | { | 228 | 1.44k | formattingInfo = std::make_shared<FormattingInfo>( | 229 | 1.44k | formattingInfo->isLeftAligned(), | 230 | 1.44k | (formattingInfo->getMinLength() * 10) + (c - 0x30 /* '0' */), | 231 | 1.44k | formattingInfo->getMaxLength()); | 232 | 1.44k | ++minDigitCount; | 233 | 1.44k | } | 234 | 3.28k | else if (c == 0x2E /* '.' */) | 235 | 1.00k | { | 236 | 1.00k | state = DOT_STATE; | 237 | 1.00k | } | 238 | 2.28k | else | 239 | 2.28k | { | 240 | 2.28k | i = finalizeConverter( | 241 | 2.28k | c, pattern, i, currentLiteral, formattingInfo, | 242 | 2.28k | rules, patternConverters, formattingInfos); | 243 | 2.28k | state = LITERAL_STATE; | 244 | 2.28k | formattingInfo = FormattingInfo::getDefault(); | 245 | | | 246 | 2.28k | if (!currentLiteral.empty()) | 247 | 0 | { | 248 | 0 | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 249 | 0 | } | 250 | 2.28k | } | 251 | | | 252 | 4.73k | break; | 253 | | | 254 | 3.15k | case DOT_STATE: | 255 | 3.15k | currentLiteral.append(1, c); | 256 | | | 257 | 3.15k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */)) | 258 | 1.90k | { | 259 | 1.90k | formattingInfo = std::make_shared<FormattingInfo>( | 260 | 1.90k | formattingInfo->isLeftAligned(), formattingInfo->getMinLength(), | 261 | 1.90k | c - 0x30 /* '0' */); | 262 | 1.90k | state = MAX_STATE; | 263 | 1.90k | maxDigitCount = 1; | 264 | 1.90k | } | 265 | 1.25k | else | 266 | 1.25k | { | 267 | 1.25k | LogLog::error(LOG4CXX_STR("Error in pattern, was expecting digit.")); | 268 | | | 269 | 1.25k | state = LITERAL_STATE; | 270 | 1.25k | } | 271 | | | 272 | 3.15k | break; | 273 | | | 274 | 3.08k | case MAX_STATE: | 275 | 3.08k | currentLiteral.append(1, c); | 276 | | | 277 | 3.08k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */) && maxDigitCount < 3) | 278 | 1.22k | { | 279 | 1.22k | formattingInfo = std::make_shared<FormattingInfo>( | 280 | 1.22k | formattingInfo->isLeftAligned(), formattingInfo->getMinLength(), | 281 | 1.22k | (formattingInfo->getMaxLength() * 10) + (c - 0x30 /* '0' */)); | 282 | 1.22k | ++maxDigitCount; | 283 | 1.22k | } | 284 | 1.85k | else | 285 | 1.85k | { | 286 | 1.85k | i = finalizeConverter( | 287 | 1.85k | c, pattern, i, currentLiteral, formattingInfo, | 288 | 1.85k | rules, patternConverters, formattingInfos); | 289 | 1.85k | state = LITERAL_STATE; | 290 | 1.85k | formattingInfo = FormattingInfo::getDefault(); | 291 | | | 292 | 1.85k | if (!currentLiteral.empty()) | 293 | 0 | { | 294 | 0 | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 295 | 0 | } | 296 | 1.85k | } | 297 | | | 298 | 3.08k | break; | 299 | 754k | } // switch | 300 | 754k | } | 301 | | | 302 | | // while | 303 | 3.84k | if (currentLiteral.length() != 0) | 304 | 807 | { | 305 | 807 | patternConverters.push_back( | 306 | 807 | LiteralPatternConverter::newInstance(currentLiteral)); | 307 | 807 | formattingInfos.push_back(FormattingInfo::getDefault()); | 308 | 807 | } | 309 | 3.84k | } |
|
310 | | |
311 | | |
312 | | PatternConverterPtr PatternParser::createConverter( |
313 | | const LogString& converterId, |
314 | | LogString& currentLiteral, |
315 | | const PatternMap& rules, |
316 | | std::vector<LogString>& options) |
317 | 206k | { |
318 | | |
319 | 206k | LogString converterName(converterId); |
320 | | |
321 | 960k | for (size_t i = converterId.length(); i > 0; i--) |
322 | 947k | { |
323 | 947k | converterName = converterName.substr(0, i); |
324 | 947k | PatternMap::const_iterator iter = rules.find(converterName); |
325 | | |
326 | 947k | if (iter != rules.end()) |
327 | 194k | { |
328 | 194k | currentLiteral.erase(currentLiteral.begin(), |
329 | 194k | currentLiteral.end() - (converterId.length() - i)); |
330 | 194k | return (iter->second)(options); |
331 | 194k | } |
332 | 947k | } |
333 | | |
334 | 12.5k | LogLog::error(LogString(LOG4CXX_STR("Unrecognized format specifier ")) + converterId); |
335 | | |
336 | 12.5k | return PatternConverterPtr(); |
337 | 206k | } log4cxx::pattern::PatternParser::createConverter(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::function<std::__1::shared_ptr<log4cxx::pattern::PatternConverter> (std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&)>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::function<std::__1::shared_ptr<log4cxx::pattern::PatternConverter> (std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&)> > > > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&) Line | Count | Source | 317 | 97.3k | { | 318 | | | 319 | 97.3k | LogString converterName(converterId); | 320 | | | 321 | 530k | for (size_t i = converterId.length(); i > 0; i--) | 322 | 521k | { | 323 | 521k | converterName = converterName.substr(0, i); | 324 | 521k | PatternMap::const_iterator iter = rules.find(converterName); | 325 | | | 326 | 521k | if (iter != rules.end()) | 327 | 88.3k | { | 328 | 88.3k | currentLiteral.erase(currentLiteral.begin(), | 329 | 88.3k | currentLiteral.end() - (converterId.length() - i)); | 330 | 88.3k | return (iter->second)(options); | 331 | 88.3k | } | 332 | 521k | } | 333 | | | 334 | 8.92k | LogLog::error(LogString(LOG4CXX_STR("Unrecognized format specifier ")) + converterId); | 335 | | | 336 | 8.92k | return PatternConverterPtr(); | 337 | 97.3k | } |
log4cxx::pattern::PatternParser::createConverter(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&, std::__1::map<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::function<std::__1::shared_ptr<log4cxx::pattern::PatternConverter> (std::__1::vector<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::allocator<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > > > const&)>, std::__1::less<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const, std::__1::function<std::__1::shared_ptr<log4cxx::pattern::PatternConverter> (std::__1::vector<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::allocator<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > > > const&)> > > > const&, std::__1::vector<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::allocator<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > > >&) Line | Count | Source | 317 | 109k | { | 318 | | | 319 | 109k | LogString converterName(converterId); | 320 | | | 321 | 429k | for (size_t i = converterId.length(); i > 0; i--) | 322 | 425k | { | 323 | 425k | converterName = converterName.substr(0, i); | 324 | 425k | PatternMap::const_iterator iter = rules.find(converterName); | 325 | | | 326 | 425k | if (iter != rules.end()) | 327 | 105k | { | 328 | 105k | currentLiteral.erase(currentLiteral.begin(), | 329 | 105k | currentLiteral.end() - (converterId.length() - i)); | 330 | 105k | return (iter->second)(options); | 331 | 105k | } | 332 | 425k | } | 333 | | | 334 | 3.65k | LogLog::error(LogString(LOG4CXX_STR("Unrecognized format specifier ")) + converterId); | 335 | | | 336 | 3.65k | return PatternConverterPtr(); | 337 | 109k | } |
|
338 | | |
339 | | size_t PatternParser::finalizeConverter( |
340 | | logchar c, const LogString& pattern, size_t i, |
341 | | LogString& currentLiteral, const FormattingInfoPtr& formattingInfo, |
342 | | const PatternMap& rules, |
343 | | std::vector<PatternConverterPtr>& patternConverters, |
344 | | std::vector<FormattingInfoPtr>& formattingInfos) |
345 | 219k | { |
346 | 219k | LogString convBuf; |
347 | 219k | i = extractConverter(c, pattern, i, convBuf, currentLiteral); |
348 | | |
349 | 219k | if (convBuf.empty()) |
350 | 12.5k | { |
351 | 12.5k | LogLog::error(LOG4CXX_STR("Empty conversion specifier")); |
352 | 12.5k | patternConverters.push_back( |
353 | 12.5k | LiteralPatternConverter::newInstance(currentLiteral)); |
354 | 12.5k | formattingInfos.push_back(FormattingInfo::getDefault()); |
355 | 12.5k | } |
356 | 206k | else |
357 | 206k | { |
358 | 206k | LogString converterId(convBuf); |
359 | | |
360 | 206k | std::vector<LogString> options; |
361 | 206k | i = extractOptions(pattern, i, options); |
362 | | |
363 | 206k | PatternConverterPtr pc( |
364 | 206k | createConverter( |
365 | 206k | converterId, currentLiteral, rules, options)); |
366 | | |
367 | 206k | if (pc == NULL) |
368 | 12.5k | { |
369 | 12.5k | LogString msg(LOG4CXX_STR("Unrecognized conversion specifier [")); |
370 | 12.5k | msg.append(converterId); |
371 | 12.5k | msg.append(LOG4CXX_STR("] in conversion pattern.")); |
372 | 12.5k | LogLog::error(msg); |
373 | 12.5k | patternConverters.push_back( |
374 | 12.5k | LiteralPatternConverter::newInstance(currentLiteral)); |
375 | 12.5k | formattingInfos.push_back(FormattingInfo::getDefault()); |
376 | 12.5k | } |
377 | 194k | else |
378 | 194k | { |
379 | 194k | patternConverters.push_back(pc); |
380 | 194k | formattingInfos.push_back(formattingInfo); |
381 | | |
382 | 194k | if (currentLiteral.length() > 0) |
383 | 53.2k | { |
384 | 53.2k | patternConverters.push_back( |
385 | 53.2k | LiteralPatternConverter::newInstance(currentLiteral)); |
386 | 53.2k | formattingInfos.push_back(FormattingInfo::getDefault()); |
387 | 53.2k | } |
388 | 194k | } |
389 | 206k | } |
390 | | |
391 | 219k | if (!currentLiteral.empty()) |
392 | 78.4k | { |
393 | 78.4k | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); |
394 | 78.4k | } |
395 | | |
396 | 219k | return i; |
397 | 219k | } log4cxx::pattern::PatternParser::finalizeConverter(char, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::shared_ptr<log4cxx::pattern::FormattingInfo> const&, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::function<std::__1::shared_ptr<log4cxx::pattern::PatternConverter> (std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&)>, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::function<std::__1::shared_ptr<log4cxx::pattern::PatternConverter> (std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&)> > > > const&, std::__1::vector<std::__1::shared_ptr<log4cxx::pattern::PatternConverter>, std::__1::allocator<std::__1::shared_ptr<log4cxx::pattern::PatternConverter> > >&, std::__1::vector<std::__1::shared_ptr<log4cxx::pattern::FormattingInfo>, std::__1::allocator<std::__1::shared_ptr<log4cxx::pattern::FormattingInfo> > >&) Line | Count | Source | 345 | 103k | { | 346 | 103k | LogString convBuf; | 347 | 103k | i = extractConverter(c, pattern, i, convBuf, currentLiteral); | 348 | | | 349 | 103k | if (convBuf.empty()) | 350 | 6.60k | { | 351 | 6.60k | LogLog::error(LOG4CXX_STR("Empty conversion specifier")); | 352 | 6.60k | patternConverters.push_back( | 353 | 6.60k | LiteralPatternConverter::newInstance(currentLiteral)); | 354 | 6.60k | formattingInfos.push_back(FormattingInfo::getDefault()); | 355 | 6.60k | } | 356 | 97.3k | else | 357 | 97.3k | { | 358 | 97.3k | LogString converterId(convBuf); | 359 | | | 360 | 97.3k | std::vector<LogString> options; | 361 | 97.3k | i = extractOptions(pattern, i, options); | 362 | | | 363 | 97.3k | PatternConverterPtr pc( | 364 | 97.3k | createConverter( | 365 | 97.3k | converterId, currentLiteral, rules, options)); | 366 | | | 367 | 97.3k | if (pc == NULL) | 368 | 8.92k | { | 369 | 8.92k | LogString msg(LOG4CXX_STR("Unrecognized conversion specifier [")); | 370 | 8.92k | msg.append(converterId); | 371 | 8.92k | msg.append(LOG4CXX_STR("] in conversion pattern.")); | 372 | 8.92k | LogLog::error(msg); | 373 | 8.92k | patternConverters.push_back( | 374 | 8.92k | LiteralPatternConverter::newInstance(currentLiteral)); | 375 | 8.92k | formattingInfos.push_back(FormattingInfo::getDefault()); | 376 | 8.92k | } | 377 | 88.3k | else | 378 | 88.3k | { | 379 | 88.3k | patternConverters.push_back(pc); | 380 | 88.3k | formattingInfos.push_back(formattingInfo); | 381 | | | 382 | 88.3k | if (currentLiteral.length() > 0) | 383 | 25.1k | { | 384 | 25.1k | patternConverters.push_back( | 385 | 25.1k | LiteralPatternConverter::newInstance(currentLiteral)); | 386 | 25.1k | formattingInfos.push_back(FormattingInfo::getDefault()); | 387 | 25.1k | } | 388 | 88.3k | } | 389 | 97.3k | } | 390 | | | 391 | 103k | if (!currentLiteral.empty()) | 392 | 40.6k | { | 393 | 40.6k | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 394 | 40.6k | } | 395 | | | 396 | 103k | return i; | 397 | 103k | } |
log4cxx::pattern::PatternParser::finalizeConverter(wchar_t, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&, unsigned long, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&, std::__1::shared_ptr<log4cxx::pattern::FormattingInfo> const&, std::__1::map<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::function<std::__1::shared_ptr<log4cxx::pattern::PatternConverter> (std::__1::vector<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::allocator<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > > > const&)>, std::__1::less<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const, std::__1::function<std::__1::shared_ptr<log4cxx::pattern::PatternConverter> (std::__1::vector<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >, std::__1::allocator<std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > > > const&)> > > > const&, std::__1::vector<std::__1::shared_ptr<log4cxx::pattern::PatternConverter>, std::__1::allocator<std::__1::shared_ptr<log4cxx::pattern::PatternConverter> > >&, std::__1::vector<std::__1::shared_ptr<log4cxx::pattern::FormattingInfo>, std::__1::allocator<std::__1::shared_ptr<log4cxx::pattern::FormattingInfo> > >&) Line | Count | Source | 345 | 115k | { | 346 | 115k | LogString convBuf; | 347 | 115k | i = extractConverter(c, pattern, i, convBuf, currentLiteral); | 348 | | | 349 | 115k | if (convBuf.empty()) | 350 | 5.98k | { | 351 | 5.98k | LogLog::error(LOG4CXX_STR("Empty conversion specifier")); | 352 | 5.98k | patternConverters.push_back( | 353 | 5.98k | LiteralPatternConverter::newInstance(currentLiteral)); | 354 | 5.98k | formattingInfos.push_back(FormattingInfo::getDefault()); | 355 | 5.98k | } | 356 | 109k | else | 357 | 109k | { | 358 | 109k | LogString converterId(convBuf); | 359 | | | 360 | 109k | std::vector<LogString> options; | 361 | 109k | i = extractOptions(pattern, i, options); | 362 | | | 363 | 109k | PatternConverterPtr pc( | 364 | 109k | createConverter( | 365 | 109k | converterId, currentLiteral, rules, options)); | 366 | | | 367 | 109k | if (pc == NULL) | 368 | 3.65k | { | 369 | 3.65k | LogString msg(LOG4CXX_STR("Unrecognized conversion specifier [")); | 370 | 3.65k | msg.append(converterId); | 371 | 3.65k | msg.append(LOG4CXX_STR("] in conversion pattern.")); | 372 | 3.65k | LogLog::error(msg); | 373 | 3.65k | patternConverters.push_back( | 374 | 3.65k | LiteralPatternConverter::newInstance(currentLiteral)); | 375 | 3.65k | formattingInfos.push_back(FormattingInfo::getDefault()); | 376 | 3.65k | } | 377 | 105k | else | 378 | 105k | { | 379 | 105k | patternConverters.push_back(pc); | 380 | 105k | formattingInfos.push_back(formattingInfo); | 381 | | | 382 | 105k | if (currentLiteral.length() > 0) | 383 | 28.1k | { | 384 | 28.1k | patternConverters.push_back( | 385 | 28.1k | LiteralPatternConverter::newInstance(currentLiteral)); | 386 | 28.1k | formattingInfos.push_back(FormattingInfo::getDefault()); | 387 | 28.1k | } | 388 | 105k | } | 389 | 109k | } | 390 | | | 391 | 115k | if (!currentLiteral.empty()) | 392 | 37.7k | { | 393 | 37.7k | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 394 | 37.7k | } | 395 | | | 396 | 115k | return i; | 397 | 115k | } |
|