/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.21M | { |
39 | | // |
40 | | // greatly simplified version checks if |
41 | | // character is USACII alpha or number |
42 | | // |
43 | 1.21M | return (ch >= 0x41 /* 'A' */ && ch <= 0x5A /* 'Z' */) || |
44 | 985k | (ch >= 0x61 /* 'a' */ && ch <= 0x7A /* 'z' */) || |
45 | 321k | (ch >= 0x30 /* '0' */ && ch <= 0x39 /* '9' */); |
46 | 1.21M | } log4cxx::pattern::PatternParser::isUnicodeIdentifierStart(char) Line | Count | Source | 38 | 689k | { | 39 | | // | 40 | | // greatly simplified version checks if | 41 | | // character is USACII alpha or number | 42 | | // | 43 | 689k | return (ch >= 0x41 /* 'A' */ && ch <= 0x5A /* 'Z' */) || | 44 | 583k | (ch >= 0x61 /* 'a' */ && ch <= 0x7A /* 'z' */) || | 45 | 169k | (ch >= 0x30 /* '0' */ && ch <= 0x39 /* '9' */); | 46 | 689k | } |
log4cxx::pattern::PatternParser::isUnicodeIdentifierStart(wchar_t) Line | Count | Source | 38 | 529k | { | 39 | | // | 40 | | // greatly simplified version checks if | 41 | | // character is USACII alpha or number | 42 | | // | 43 | 529k | return (ch >= 0x41 /* 'A' */ && ch <= 0x5A /* 'Z' */) || | 44 | 401k | (ch >= 0x61 /* 'a' */ && ch <= 0x7A /* 'z' */) || | 45 | 152k | (ch >= 0x30 /* '0' */ && ch <= 0x39 /* '9' */); | 46 | 529k | } |
|
47 | | |
48 | | bool PatternParser::isUnicodeIdentifierPart(logchar ch) |
49 | 960k | { |
50 | | // |
51 | | // greatly simplified version checks if |
52 | | // character is USACII alpha or number |
53 | | // |
54 | 960k | return isUnicodeIdentifierStart(ch) |
55 | 246k | || (ch == 0x5F /* '_' */); |
56 | 960k | } log4cxx::pattern::PatternParser::isUnicodeIdentifierPart(char) Line | Count | Source | 49 | 556k | { | 50 | | // | 51 | | // greatly simplified version checks if | 52 | | // character is USACII alpha or number | 53 | | // | 54 | 556k | return isUnicodeIdentifierStart(ch) | 55 | 126k | || (ch == 0x5F /* '_' */); | 56 | 556k | } |
log4cxx::pattern::PatternParser::isUnicodeIdentifierPart(wchar_t) Line | Count | Source | 49 | 404k | { | 50 | | // | 51 | | // greatly simplified version checks if | 52 | | // character is USACII alpha or number | 53 | | // | 54 | 404k | return isUnicodeIdentifierStart(ch) | 55 | 119k | || (ch == 0x5F /* '_' */); | 56 | 404k | } |
|
57 | | |
58 | | size_t PatternParser::extractConverter( |
59 | | logchar lastChar, const LogString& pattern, |
60 | | LogString::size_type i, LogString& convBuf, |
61 | | LogString& currentLiteral) |
62 | 258k | { |
63 | 258k | 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 | 258k | if (!isUnicodeIdentifierStart(lastChar)) |
74 | 10.6k | { |
75 | 10.6k | return i; |
76 | 10.6k | } |
77 | | |
78 | 247k | convBuf.append(1, lastChar); |
79 | | |
80 | 247k | while ( |
81 | 962k | (i < pattern.length()) |
82 | 960k | && isUnicodeIdentifierPart(pattern[i])) |
83 | 714k | { |
84 | 714k | convBuf.append(1, pattern[i]); |
85 | 714k | currentLiteral.append(1, pattern[i]); |
86 | | |
87 | | //System.out.println("conv buffer is now ["+convBuf+"]."); |
88 | 714k | i++; |
89 | 714k | } |
90 | | |
91 | 247k | return i; |
92 | 258k | } 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 | 133k | { | 63 | 133k | 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 | 133k | if (!isUnicodeIdentifierStart(lastChar)) | 74 | 6.10k | { | 75 | 6.10k | return i; | 76 | 6.10k | } | 77 | | | 78 | 127k | convBuf.append(1, lastChar); | 79 | | | 80 | 127k | while ( | 81 | 557k | (i < pattern.length()) | 82 | 556k | && isUnicodeIdentifierPart(pattern[i])) | 83 | 429k | { | 84 | 429k | convBuf.append(1, pattern[i]); | 85 | 429k | currentLiteral.append(1, pattern[i]); | 86 | | | 87 | | //System.out.println("conv buffer is now ["+convBuf+"]."); | 88 | 429k | i++; | 89 | 429k | } | 90 | | | 91 | 127k | return i; | 92 | 133k | } |
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 | 124k | { | 63 | 124k | 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 | 124k | if (!isUnicodeIdentifierStart(lastChar)) | 74 | 4.53k | { | 75 | 4.53k | return i; | 76 | 4.53k | } | 77 | | | 78 | 120k | convBuf.append(1, lastChar); | 79 | | | 80 | 120k | while ( | 81 | 404k | (i < pattern.length()) | 82 | 404k | && isUnicodeIdentifierPart(pattern[i])) | 83 | 284k | { | 84 | 284k | convBuf.append(1, pattern[i]); | 85 | 284k | currentLiteral.append(1, pattern[i]); | 86 | | | 87 | | //System.out.println("conv buffer is now ["+convBuf+"]."); | 88 | 284k | i++; | 89 | 284k | } | 90 | | | 91 | 120k | return i; | 92 | 124k | } |
|
93 | | |
94 | | |
95 | | size_t PatternParser::extractOptions(const LogString& pattern, LogString::size_type i, |
96 | | std::vector<LogString>& options) |
97 | 247k | { |
98 | 366k | while ((i < pattern.length()) && (pattern[i] == 0x7B /* '{' */)) |
99 | 120k | { |
100 | 120k | size_t end = pattern.find(0x7D /* '}' */, i); |
101 | | |
102 | 120k | if (end == pattern.npos) |
103 | 923 | { |
104 | 923 | break; |
105 | 923 | } |
106 | | |
107 | 119k | LogString r(pattern.substr(i + 1, end - i - 1)); |
108 | 119k | options.push_back(r); |
109 | 119k | i = end + 1; |
110 | 119k | } |
111 | | |
112 | 247k | return i; |
113 | 247k | } 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 | 127k | { | 98 | 189k | while ((i < pattern.length()) && (pattern[i] == 0x7B /* '{' */)) | 99 | 62.8k | { | 100 | 62.8k | size_t end = pattern.find(0x7D /* '}' */, i); | 101 | | | 102 | 62.8k | if (end == pattern.npos) | 103 | 496 | { | 104 | 496 | break; | 105 | 496 | } | 106 | | | 107 | 62.3k | LogString r(pattern.substr(i + 1, end - i - 1)); | 108 | 62.3k | options.push_back(r); | 109 | 62.3k | i = end + 1; | 110 | 62.3k | } | 111 | | | 112 | 127k | return i; | 113 | 127k | } |
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 | 120k | { | 98 | 177k | while ((i < pattern.length()) && (pattern[i] == 0x7B /* '{' */)) | 99 | 57.2k | { | 100 | 57.2k | size_t end = pattern.find(0x7D /* '}' */, i); | 101 | | | 102 | 57.2k | if (end == pattern.npos) | 103 | 427 | { | 104 | 427 | break; | 105 | 427 | } | 106 | | | 107 | 56.8k | LogString r(pattern.substr(i + 1, end - i - 1)); | 108 | 56.8k | options.push_back(r); | 109 | 56.8k | i = end + 1; | 110 | 56.8k | } | 111 | | | 112 | 120k | return i; | 113 | 120k | } |
|
114 | | |
115 | | #if LOG4CXX_ABI_VERSION <= 15 |
116 | | void PatternParser::parse( |
117 | | const LogString& pattern, |
118 | | std::vector<PatternConverterPtr>& patternConverters, |
119 | | std::vector<FormattingInfoPtr>& formattingInfos, |
120 | | const PatternMap& rules) |
121 | 0 | { |
122 | 0 | patternConverters = parse(pattern, rules); |
123 | 0 | } Unexecuted instantiation: 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&) Unexecuted instantiation: 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&) |
124 | | #endif |
125 | | |
126 | | PatternConverterList PatternParser::parse |
127 | | ( const LogString& pattern |
128 | | , const PatternMap& rules |
129 | | ) |
130 | 9.76k | { |
131 | 9.76k | PatternConverterList patternConverters; |
132 | 9.76k | LogString currentLiteral; |
133 | | |
134 | 9.76k | size_t patternLength = pattern.length(); |
135 | 9.76k | int state = LITERAL_STATE; |
136 | 9.76k | logchar c; |
137 | 9.76k | size_t i = 0; |
138 | 9.76k | int minDigitCount{ 0 }, maxDigitCount{ 0 }; |
139 | 9.76k | auto formattingInfo = FormattingInfo::getDefault(); |
140 | | |
141 | 1.45M | while (i < patternLength) |
142 | 1.44M | { |
143 | 1.44M | c = pattern[i++]; |
144 | | |
145 | 1.44M | switch (state) |
146 | 1.44M | { |
147 | 1.07M | case LITERAL_STATE: |
148 | | |
149 | | // In literal state, the last char is always a literal. |
150 | 1.07M | if (i == patternLength) |
151 | 2.97k | { |
152 | 2.97k | currentLiteral.append(1, c); |
153 | | |
154 | 2.97k | continue; |
155 | 2.97k | } |
156 | | |
157 | 1.07M | if (c == ESCAPE_CHAR) |
158 | 264k | { |
159 | | // peek at the next char. |
160 | 264k | if (pattern[i] == ESCAPE_CHAR) |
161 | 2.93k | { |
162 | 2.93k | currentLiteral.append(1, c); |
163 | 2.93k | i++; // move pointer |
164 | 2.93k | } |
165 | 261k | else |
166 | 261k | { |
167 | 261k | if (!currentLiteral.empty()) |
168 | 79.1k | { |
169 | 79.1k | patternConverters.push_back( |
170 | 79.1k | LiteralPatternConverter::newInstance(currentLiteral)); |
171 | 79.1k | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); |
172 | 79.1k | } |
173 | | |
174 | 261k | currentLiteral.append(1, c); // append % |
175 | 261k | state = CONVERTER_STATE; |
176 | 261k | formattingInfo = FormattingInfo::getDefault(); |
177 | 261k | } |
178 | 264k | } |
179 | 810k | else |
180 | 810k | { |
181 | 810k | currentLiteral.append(1, c); |
182 | 810k | } |
183 | | |
184 | 1.07M | break; |
185 | | |
186 | 338k | case CONVERTER_STATE: |
187 | 338k | currentLiteral.append(1, c); |
188 | | |
189 | 338k | switch (c) |
190 | 338k | { |
191 | 76.9k | case 0x2D: // '-' |
192 | 76.9k | formattingInfo = std::make_shared<FormattingInfo>( |
193 | 76.9k | true, formattingInfo->getMinLength(), |
194 | 76.9k | formattingInfo->getMaxLength()); |
195 | | |
196 | 76.9k | break; |
197 | | |
198 | 8.02k | case 0x2E: // '.' |
199 | 8.02k | state = DOT_STATE; |
200 | | |
201 | 8.02k | break; |
202 | | |
203 | 253k | default: |
204 | | |
205 | 253k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */)) |
206 | 8.25k | { |
207 | 8.25k | formattingInfo = std::make_shared<FormattingInfo>( |
208 | 8.25k | formattingInfo->isLeftAligned(), c - 0x30 /* '0' */, |
209 | 8.25k | formattingInfo->getMaxLength()); |
210 | 8.25k | state = MIN_STATE; |
211 | 8.25k | minDigitCount = 1; |
212 | 8.25k | } |
213 | 245k | else |
214 | 245k | { |
215 | 245k | i = finalizeConverter( |
216 | 245k | c, pattern, i, currentLiteral, formattingInfo, |
217 | 245k | rules, patternConverters); |
218 | | |
219 | | // Next pattern is assumed to be a literal. |
220 | 245k | state = LITERAL_STATE; |
221 | 245k | formattingInfo = FormattingInfo::getDefault(); |
222 | | |
223 | 245k | if (!currentLiteral.empty()) |
224 | 0 | { |
225 | 0 | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); |
226 | 0 | } |
227 | 245k | } |
228 | 338k | } // switch |
229 | | |
230 | 338k | break; |
231 | | |
232 | 338k | case MIN_STATE: |
233 | 10.6k | currentLiteral.append(1, c); |
234 | | |
235 | 10.6k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */) && minDigitCount < 3) |
236 | 2.51k | { |
237 | 2.51k | formattingInfo = std::make_shared<FormattingInfo>( |
238 | 2.51k | formattingInfo->isLeftAligned(), |
239 | 2.51k | (formattingInfo->getMinLength() * 10) + (c - 0x30 /* '0' */), |
240 | 2.51k | formattingInfo->getMaxLength()); |
241 | 2.51k | ++minDigitCount; |
242 | 2.51k | } |
243 | 8.15k | else if (c == 0x2E /* '.' */) |
244 | 1.41k | { |
245 | 1.41k | state = DOT_STATE; |
246 | 1.41k | } |
247 | 6.74k | else |
248 | 6.74k | { |
249 | 6.74k | i = finalizeConverter( |
250 | 6.74k | c, pattern, i, currentLiteral, formattingInfo, |
251 | 6.74k | rules, patternConverters); |
252 | 6.74k | state = LITERAL_STATE; |
253 | 6.74k | formattingInfo = FormattingInfo::getDefault(); |
254 | | |
255 | 6.74k | if (!currentLiteral.empty()) |
256 | 0 | { |
257 | 0 | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); |
258 | 0 | } |
259 | 6.74k | } |
260 | | |
261 | 10.6k | break; |
262 | | |
263 | 9.41k | case DOT_STATE: |
264 | 9.41k | currentLiteral.append(1, c); |
265 | | |
266 | 9.41k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */)) |
267 | 6.39k | { |
268 | 6.39k | formattingInfo = std::make_shared<FormattingInfo>( |
269 | 6.39k | formattingInfo->isLeftAligned(), formattingInfo->getMinLength(), |
270 | 6.39k | c - 0x30 /* '0' */); |
271 | 6.39k | state = MAX_STATE; |
272 | 6.39k | maxDigitCount = 1; |
273 | 6.39k | } |
274 | 3.02k | else |
275 | 3.02k | { |
276 | 3.02k | LogLog::error(LOG4CXX_STR("Error in pattern, was expecting digit.")); |
277 | | |
278 | 3.02k | state = LITERAL_STATE; |
279 | 3.02k | } |
280 | | |
281 | 9.41k | break; |
282 | | |
283 | 12.9k | case MAX_STATE: |
284 | 12.9k | currentLiteral.append(1, c); |
285 | | |
286 | 12.9k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */) && maxDigitCount < 3) |
287 | 6.60k | { |
288 | 6.60k | formattingInfo = std::make_shared<FormattingInfo>( |
289 | 6.60k | formattingInfo->isLeftAligned(), formattingInfo->getMinLength(), |
290 | 6.60k | (formattingInfo->getMaxLength() * 10) + (c - 0x30 /* '0' */)); |
291 | 6.60k | ++maxDigitCount; |
292 | 6.60k | } |
293 | 6.31k | else |
294 | 6.31k | { |
295 | 6.31k | i = finalizeConverter( |
296 | 6.31k | c, pattern, i, currentLiteral, formattingInfo, |
297 | 6.31k | rules, patternConverters); |
298 | 6.31k | state = LITERAL_STATE; |
299 | 6.31k | formattingInfo = FormattingInfo::getDefault(); |
300 | | |
301 | 6.31k | if (!currentLiteral.empty()) |
302 | 0 | { |
303 | 0 | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); |
304 | 0 | } |
305 | 6.31k | } |
306 | | |
307 | 12.9k | break; |
308 | 1.44M | } // switch |
309 | 1.44M | } |
310 | | |
311 | | // while |
312 | 9.76k | if (currentLiteral.length() != 0) |
313 | 3.38k | { |
314 | 3.38k | patternConverters.push_back( |
315 | 3.38k | LiteralPatternConverter::newInstance(currentLiteral)); |
316 | 3.38k | } |
317 | 9.76k | return patternConverters; |
318 | 9.76k | } log4cxx::pattern::PatternParser::parse(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > 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&) Line | Count | Source | 130 | 5.94k | { | 131 | 5.94k | PatternConverterList patternConverters; | 132 | 5.94k | LogString currentLiteral; | 133 | | | 134 | 5.94k | size_t patternLength = pattern.length(); | 135 | 5.94k | int state = LITERAL_STATE; | 136 | 5.94k | logchar c; | 137 | 5.94k | size_t i = 0; | 138 | 5.94k | int minDigitCount{ 0 }, maxDigitCount{ 0 }; | 139 | 5.94k | auto formattingInfo = FormattingInfo::getDefault(); | 140 | | | 141 | 667k | while (i < patternLength) | 142 | 661k | { | 143 | 661k | c = pattern[i++]; | 144 | | | 145 | 661k | switch (state) | 146 | 661k | { | 147 | 500k | case LITERAL_STATE: | 148 | | | 149 | | // In literal state, the last char is always a literal. | 150 | 500k | if (i == patternLength) | 151 | 2.47k | { | 152 | 2.47k | currentLiteral.append(1, c); | 153 | | | 154 | 2.47k | continue; | 155 | 2.47k | } | 156 | | | 157 | 497k | if (c == ESCAPE_CHAR) | 158 | 136k | { | 159 | | // peek at the next char. | 160 | 136k | if (pattern[i] == ESCAPE_CHAR) | 161 | 1.74k | { | 162 | 1.74k | currentLiteral.append(1, c); | 163 | 1.74k | i++; // move pointer | 164 | 1.74k | } | 165 | 134k | else | 166 | 134k | { | 167 | 134k | if (!currentLiteral.empty()) | 168 | 43.6k | { | 169 | 43.6k | patternConverters.push_back( | 170 | 43.6k | LiteralPatternConverter::newInstance(currentLiteral)); | 171 | 43.6k | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 172 | 43.6k | } | 173 | | | 174 | 134k | currentLiteral.append(1, c); // append % | 175 | 134k | state = CONVERTER_STATE; | 176 | 134k | formattingInfo = FormattingInfo::getDefault(); | 177 | 134k | } | 178 | 136k | } | 179 | 361k | else | 180 | 361k | { | 181 | 361k | currentLiteral.append(1, c); | 182 | 361k | } | 183 | | | 184 | 497k | break; | 185 | | | 186 | 145k | case CONVERTER_STATE: | 187 | 145k | currentLiteral.append(1, c); | 188 | | | 189 | 145k | switch (c) | 190 | 145k | { | 191 | 10.6k | case 0x2D: // '-' | 192 | 10.6k | formattingInfo = std::make_shared<FormattingInfo>( | 193 | 10.6k | true, formattingInfo->getMinLength(), | 194 | 10.6k | formattingInfo->getMaxLength()); | 195 | | | 196 | 10.6k | break; | 197 | | | 198 | 3.77k | case 0x2E: // '.' | 199 | 3.77k | state = DOT_STATE; | 200 | | | 201 | 3.77k | break; | 202 | | | 203 | 131k | default: | 204 | | | 205 | 131k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */)) | 206 | 4.90k | { | 207 | 4.90k | formattingInfo = std::make_shared<FormattingInfo>( | 208 | 4.90k | formattingInfo->isLeftAligned(), c - 0x30 /* '0' */, | 209 | 4.90k | formattingInfo->getMaxLength()); | 210 | 4.90k | state = MIN_STATE; | 211 | 4.90k | minDigitCount = 1; | 212 | 4.90k | } | 213 | 126k | else | 214 | 126k | { | 215 | 126k | i = finalizeConverter( | 216 | 126k | c, pattern, i, currentLiteral, formattingInfo, | 217 | 126k | rules, patternConverters); | 218 | | | 219 | | // Next pattern is assumed to be a literal. | 220 | 126k | state = LITERAL_STATE; | 221 | 126k | formattingInfo = FormattingInfo::getDefault(); | 222 | | | 223 | 126k | if (!currentLiteral.empty()) | 224 | 0 | { | 225 | 0 | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 226 | 0 | } | 227 | 126k | } | 228 | 145k | } // switch | 229 | | | 230 | 145k | break; | 231 | | | 232 | 145k | case MIN_STATE: | 233 | 5.99k | currentLiteral.append(1, c); | 234 | | | 235 | 5.99k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */) && minDigitCount < 3) | 236 | 1.13k | { | 237 | 1.13k | formattingInfo = std::make_shared<FormattingInfo>( | 238 | 1.13k | formattingInfo->isLeftAligned(), | 239 | 1.13k | (formattingInfo->getMinLength() * 10) + (c - 0x30 /* '0' */), | 240 | 1.13k | formattingInfo->getMaxLength()); | 241 | 1.13k | ++minDigitCount; | 242 | 1.13k | } | 243 | 4.86k | else if (c == 0x2E /* '.' */) | 244 | 730 | { | 245 | 730 | state = DOT_STATE; | 246 | 730 | } | 247 | 4.13k | else | 248 | 4.13k | { | 249 | 4.13k | i = finalizeConverter( | 250 | 4.13k | c, pattern, i, currentLiteral, formattingInfo, | 251 | 4.13k | rules, patternConverters); | 252 | 4.13k | state = LITERAL_STATE; | 253 | 4.13k | formattingInfo = FormattingInfo::getDefault(); | 254 | | | 255 | 4.13k | if (!currentLiteral.empty()) | 256 | 0 | { | 257 | 0 | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 258 | 0 | } | 259 | 4.13k | } | 260 | | | 261 | 5.99k | break; | 262 | | | 263 | 4.49k | case DOT_STATE: | 264 | 4.49k | currentLiteral.append(1, c); | 265 | | | 266 | 4.49k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */)) | 267 | 3.26k | { | 268 | 3.26k | formattingInfo = std::make_shared<FormattingInfo>( | 269 | 3.26k | formattingInfo->isLeftAligned(), formattingInfo->getMinLength(), | 270 | 3.26k | c - 0x30 /* '0' */); | 271 | 3.26k | state = MAX_STATE; | 272 | 3.26k | maxDigitCount = 1; | 273 | 3.26k | } | 274 | 1.23k | else | 275 | 1.23k | { | 276 | 1.23k | LogLog::error(LOG4CXX_STR("Error in pattern, was expecting digit.")); | 277 | | | 278 | 1.23k | state = LITERAL_STATE; | 279 | 1.23k | } | 280 | | | 281 | 4.49k | break; | 282 | | | 283 | 5.87k | case MAX_STATE: | 284 | 5.87k | currentLiteral.append(1, c); | 285 | | | 286 | 5.87k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */) && maxDigitCount < 3) | 287 | 2.65k | { | 288 | 2.65k | formattingInfo = std::make_shared<FormattingInfo>( | 289 | 2.65k | formattingInfo->isLeftAligned(), formattingInfo->getMinLength(), | 290 | 2.65k | (formattingInfo->getMaxLength() * 10) + (c - 0x30 /* '0' */)); | 291 | 2.65k | ++maxDigitCount; | 292 | 2.65k | } | 293 | 3.22k | else | 294 | 3.22k | { | 295 | 3.22k | i = finalizeConverter( | 296 | 3.22k | c, pattern, i, currentLiteral, formattingInfo, | 297 | 3.22k | rules, patternConverters); | 298 | 3.22k | state = LITERAL_STATE; | 299 | 3.22k | formattingInfo = FormattingInfo::getDefault(); | 300 | | | 301 | 3.22k | if (!currentLiteral.empty()) | 302 | 0 | { | 303 | 0 | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 304 | 0 | } | 305 | 3.22k | } | 306 | | | 307 | 5.87k | break; | 308 | 661k | } // switch | 309 | 661k | } | 310 | | | 311 | | // while | 312 | 5.94k | if (currentLiteral.length() != 0) | 313 | 2.63k | { | 314 | 2.63k | patternConverters.push_back( | 315 | 2.63k | LiteralPatternConverter::newInstance(currentLiteral)); | 316 | 2.63k | } | 317 | 5.94k | return patternConverters; | 318 | 5.94k | } |
log4cxx::pattern::PatternParser::parse(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > 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&) Line | Count | Source | 130 | 3.82k | { | 131 | 3.82k | PatternConverterList patternConverters; | 132 | 3.82k | LogString currentLiteral; | 133 | | | 134 | 3.82k | size_t patternLength = pattern.length(); | 135 | 3.82k | int state = LITERAL_STATE; | 136 | 3.82k | logchar c; | 137 | 3.82k | size_t i = 0; | 138 | 3.82k | int minDigitCount{ 0 }, maxDigitCount{ 0 }; | 139 | 3.82k | auto formattingInfo = FormattingInfo::getDefault(); | 140 | | | 141 | 791k | while (i < patternLength) | 142 | 787k | { | 143 | 787k | c = pattern[i++]; | 144 | | | 145 | 787k | switch (state) | 146 | 787k | { | 147 | 578k | case LITERAL_STATE: | 148 | | | 149 | | // In literal state, the last char is always a literal. | 150 | 578k | if (i == patternLength) | 151 | 494 | { | 152 | 494 | currentLiteral.append(1, c); | 153 | | | 154 | 494 | continue; | 155 | 494 | } | 156 | | | 157 | 577k | if (c == ESCAPE_CHAR) | 158 | 128k | { | 159 | | // peek at the next char. | 160 | 128k | if (pattern[i] == ESCAPE_CHAR) | 161 | 1.19k | { | 162 | 1.19k | currentLiteral.append(1, c); | 163 | 1.19k | i++; // move pointer | 164 | 1.19k | } | 165 | 126k | else | 166 | 126k | { | 167 | 126k | if (!currentLiteral.empty()) | 168 | 35.5k | { | 169 | 35.5k | patternConverters.push_back( | 170 | 35.5k | LiteralPatternConverter::newInstance(currentLiteral)); | 171 | 35.5k | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 172 | 35.5k | } | 173 | | | 174 | 126k | currentLiteral.append(1, c); // append % | 175 | 126k | state = CONVERTER_STATE; | 176 | 126k | formattingInfo = FormattingInfo::getDefault(); | 177 | 126k | } | 178 | 128k | } | 179 | 449k | else | 180 | 449k | { | 181 | 449k | currentLiteral.append(1, c); | 182 | 449k | } | 183 | | | 184 | 577k | break; | 185 | | | 186 | 193k | case CONVERTER_STATE: | 187 | 193k | currentLiteral.append(1, c); | 188 | | | 189 | 193k | switch (c) | 190 | 193k | { | 191 | 66.3k | case 0x2D: // '-' | 192 | 66.3k | formattingInfo = std::make_shared<FormattingInfo>( | 193 | 66.3k | true, formattingInfo->getMinLength(), | 194 | 66.3k | formattingInfo->getMaxLength()); | 195 | | | 196 | 66.3k | break; | 197 | | | 198 | 4.24k | case 0x2E: // '.' | 199 | 4.24k | state = DOT_STATE; | 200 | | | 201 | 4.24k | break; | 202 | | | 203 | 122k | default: | 204 | | | 205 | 122k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */)) | 206 | 3.34k | { | 207 | 3.34k | formattingInfo = std::make_shared<FormattingInfo>( | 208 | 3.34k | formattingInfo->isLeftAligned(), c - 0x30 /* '0' */, | 209 | 3.34k | formattingInfo->getMaxLength()); | 210 | 3.34k | state = MIN_STATE; | 211 | 3.34k | minDigitCount = 1; | 212 | 3.34k | } | 213 | 119k | else | 214 | 119k | { | 215 | 119k | i = finalizeConverter( | 216 | 119k | c, pattern, i, currentLiteral, formattingInfo, | 217 | 119k | rules, patternConverters); | 218 | | | 219 | | // Next pattern is assumed to be a literal. | 220 | 119k | state = LITERAL_STATE; | 221 | 119k | formattingInfo = FormattingInfo::getDefault(); | 222 | | | 223 | 119k | if (!currentLiteral.empty()) | 224 | 0 | { | 225 | 0 | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 226 | 0 | } | 227 | 119k | } | 228 | 193k | } // switch | 229 | | | 230 | 193k | break; | 231 | | | 232 | 193k | case MIN_STATE: | 233 | 4.67k | currentLiteral.append(1, c); | 234 | | | 235 | 4.67k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */) && minDigitCount < 3) | 236 | 1.38k | { | 237 | 1.38k | formattingInfo = std::make_shared<FormattingInfo>( | 238 | 1.38k | formattingInfo->isLeftAligned(), | 239 | 1.38k | (formattingInfo->getMinLength() * 10) + (c - 0x30 /* '0' */), | 240 | 1.38k | formattingInfo->getMaxLength()); | 241 | 1.38k | ++minDigitCount; | 242 | 1.38k | } | 243 | 3.29k | else if (c == 0x2E /* '.' */) | 244 | 688 | { | 245 | 688 | state = DOT_STATE; | 246 | 688 | } | 247 | 2.60k | else | 248 | 2.60k | { | 249 | 2.60k | i = finalizeConverter( | 250 | 2.60k | c, pattern, i, currentLiteral, formattingInfo, | 251 | 2.60k | rules, patternConverters); | 252 | 2.60k | state = LITERAL_STATE; | 253 | 2.60k | formattingInfo = FormattingInfo::getDefault(); | 254 | | | 255 | 2.60k | if (!currentLiteral.empty()) | 256 | 0 | { | 257 | 0 | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 258 | 0 | } | 259 | 2.60k | } | 260 | | | 261 | 4.67k | break; | 262 | | | 263 | 4.92k | case DOT_STATE: | 264 | 4.92k | currentLiteral.append(1, c); | 265 | | | 266 | 4.92k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */)) | 267 | 3.13k | { | 268 | 3.13k | formattingInfo = std::make_shared<FormattingInfo>( | 269 | 3.13k | formattingInfo->isLeftAligned(), formattingInfo->getMinLength(), | 270 | 3.13k | c - 0x30 /* '0' */); | 271 | 3.13k | state = MAX_STATE; | 272 | 3.13k | maxDigitCount = 1; | 273 | 3.13k | } | 274 | 1.78k | else | 275 | 1.78k | { | 276 | 1.78k | LogLog::error(LOG4CXX_STR("Error in pattern, was expecting digit.")); | 277 | | | 278 | 1.78k | state = LITERAL_STATE; | 279 | 1.78k | } | 280 | | | 281 | 4.92k | break; | 282 | | | 283 | 7.04k | case MAX_STATE: | 284 | 7.04k | currentLiteral.append(1, c); | 285 | | | 286 | 7.04k | if ((c >= 0x30 /* '0' */) && (c <= 0x39 /* '9' */) && maxDigitCount < 3) | 287 | 3.95k | { | 288 | 3.95k | formattingInfo = std::make_shared<FormattingInfo>( | 289 | 3.95k | formattingInfo->isLeftAligned(), formattingInfo->getMinLength(), | 290 | 3.95k | (formattingInfo->getMaxLength() * 10) + (c - 0x30 /* '0' */)); | 291 | 3.95k | ++maxDigitCount; | 292 | 3.95k | } | 293 | 3.09k | else | 294 | 3.09k | { | 295 | 3.09k | i = finalizeConverter( | 296 | 3.09k | c, pattern, i, currentLiteral, formattingInfo, | 297 | 3.09k | rules, patternConverters); | 298 | 3.09k | state = LITERAL_STATE; | 299 | 3.09k | formattingInfo = FormattingInfo::getDefault(); | 300 | | | 301 | 3.09k | if (!currentLiteral.empty()) | 302 | 0 | { | 303 | 0 | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 304 | 0 | } | 305 | 3.09k | } | 306 | | | 307 | 7.04k | break; | 308 | 787k | } // switch | 309 | 787k | } | 310 | | | 311 | | // while | 312 | 3.82k | if (currentLiteral.length() != 0) | 313 | 758 | { | 314 | 758 | patternConverters.push_back( | 315 | 758 | LiteralPatternConverter::newInstance(currentLiteral)); | 316 | 758 | } | 317 | 3.82k | return patternConverters; | 318 | 3.82k | } |
|
319 | | |
320 | | |
321 | | PatternConverterPtr PatternParser::createConverter( |
322 | | const LogString& converterId, |
323 | | LogString& currentLiteral, |
324 | | const PatternMap& rules, |
325 | | std::vector<LogString>& options) |
326 | 247k | { |
327 | | |
328 | 247k | LogString converterName(converterId); |
329 | | |
330 | 958k | for (size_t i = converterId.length(); i > 0; i--) |
331 | 945k | { |
332 | 945k | converterName = converterName.substr(0, i); |
333 | 945k | PatternMap::const_iterator iter = rules.find(converterName); |
334 | | |
335 | 945k | if (iter != rules.end()) |
336 | 235k | { |
337 | 235k | currentLiteral.erase(currentLiteral.begin(), |
338 | 235k | currentLiteral.end() - (converterId.length() - i)); |
339 | 235k | return (iter->second)(options); |
340 | 235k | } |
341 | 945k | } |
342 | | |
343 | 12.6k | LogLog::error(LogString(LOG4CXX_STR("Unrecognized format specifier ")) + converterId); |
344 | | |
345 | 12.6k | return PatternConverterPtr(); |
346 | 247k | } 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 | 326 | 127k | { | 327 | | | 328 | 127k | LogString converterName(converterId); | 329 | | | 330 | 549k | for (size_t i = converterId.length(); i > 0; i--) | 331 | 541k | { | 332 | 541k | converterName = converterName.substr(0, i); | 333 | 541k | PatternMap::const_iterator iter = rules.find(converterName); | 334 | | | 335 | 541k | if (iter != rules.end()) | 336 | 119k | { | 337 | 119k | currentLiteral.erase(currentLiteral.begin(), | 338 | 119k | currentLiteral.end() - (converterId.length() - i)); | 339 | 119k | return (iter->second)(options); | 340 | 119k | } | 341 | 541k | } | 342 | | | 343 | 7.63k | LogLog::error(LogString(LOG4CXX_STR("Unrecognized format specifier ")) + converterId); | 344 | | | 345 | 7.63k | return PatternConverterPtr(); | 346 | 127k | } |
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 | 326 | 120k | { | 327 | | | 328 | 120k | LogString converterName(converterId); | 329 | | | 330 | 409k | for (size_t i = converterId.length(); i > 0; i--) | 331 | 404k | { | 332 | 404k | converterName = converterName.substr(0, i); | 333 | 404k | PatternMap::const_iterator iter = rules.find(converterName); | 334 | | | 335 | 404k | if (iter != rules.end()) | 336 | 115k | { | 337 | 115k | currentLiteral.erase(currentLiteral.begin(), | 338 | 115k | currentLiteral.end() - (converterId.length() - i)); | 339 | 115k | return (iter->second)(options); | 340 | 115k | } | 341 | 404k | } | 342 | | | 343 | 5.04k | LogLog::error(LogString(LOG4CXX_STR("Unrecognized format specifier ")) + converterId); | 344 | | | 345 | 5.04k | return PatternConverterPtr(); | 346 | 120k | } |
|
347 | | |
348 | | size_t PatternParser::finalizeConverter( |
349 | | logchar c, const LogString& pattern, size_t i, |
350 | | LogString& currentLiteral, const FormattingInfoPtr& formattingInfo, |
351 | | const PatternMap& rules, |
352 | | PatternConverterList& patternConverters) |
353 | 258k | { |
354 | 258k | LogString convBuf; |
355 | 258k | i = extractConverter(c, pattern, i, convBuf, currentLiteral); |
356 | | |
357 | 258k | if (convBuf.empty()) |
358 | 10.6k | { |
359 | 10.6k | LogLog::error(LOG4CXX_STR("Empty conversion specifier")); |
360 | 10.6k | patternConverters.push_back( |
361 | 10.6k | LiteralPatternConverter::newInstance(currentLiteral)); |
362 | 10.6k | } |
363 | 247k | else |
364 | 247k | { |
365 | 247k | LogString converterId(convBuf); |
366 | | |
367 | 247k | std::vector<LogString> options; |
368 | 247k | i = extractOptions(pattern, i, options); |
369 | | |
370 | 247k | PatternConverterPtr pc( |
371 | 247k | createConverter( |
372 | 247k | converterId, currentLiteral, rules, options)); |
373 | | |
374 | 247k | if (pc == NULL) |
375 | 12.6k | { |
376 | 12.6k | LogString msg(LOG4CXX_STR("Unrecognized conversion specifier [")); |
377 | 12.6k | msg.append(converterId); |
378 | 12.6k | msg.append(LOG4CXX_STR("] in conversion pattern.")); |
379 | 12.6k | LogLog::error(msg); |
380 | 12.6k | patternConverters.push_back( |
381 | 12.6k | LiteralPatternConverter::newInstance(currentLiteral)); |
382 | 12.6k | } |
383 | 235k | else |
384 | 235k | { |
385 | 235k | patternConverters.push_back(pc); |
386 | 235k | pc->setFormattingInfo(formattingInfo); |
387 | | |
388 | 235k | if (currentLiteral.length() > 0) |
389 | 64.8k | { |
390 | 64.8k | patternConverters.push_back( |
391 | 64.8k | LiteralPatternConverter::newInstance(currentLiteral)); |
392 | 64.8k | } |
393 | 235k | } |
394 | 247k | } |
395 | | |
396 | 258k | if (!currentLiteral.empty()) |
397 | 88.2k | { |
398 | 88.2k | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); |
399 | 88.2k | } |
400 | | |
401 | 258k | return i; |
402 | 258k | } 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> > >&) Line | Count | Source | 353 | 133k | { | 354 | 133k | LogString convBuf; | 355 | 133k | i = extractConverter(c, pattern, i, convBuf, currentLiteral); | 356 | | | 357 | 133k | if (convBuf.empty()) | 358 | 6.10k | { | 359 | 6.10k | LogLog::error(LOG4CXX_STR("Empty conversion specifier")); | 360 | 6.10k | patternConverters.push_back( | 361 | 6.10k | LiteralPatternConverter::newInstance(currentLiteral)); | 362 | 6.10k | } | 363 | 127k | else | 364 | 127k | { | 365 | 127k | LogString converterId(convBuf); | 366 | | | 367 | 127k | std::vector<LogString> options; | 368 | 127k | i = extractOptions(pattern, i, options); | 369 | | | 370 | 127k | PatternConverterPtr pc( | 371 | 127k | createConverter( | 372 | 127k | converterId, currentLiteral, rules, options)); | 373 | | | 374 | 127k | if (pc == NULL) | 375 | 7.63k | { | 376 | 7.63k | LogString msg(LOG4CXX_STR("Unrecognized conversion specifier [")); | 377 | 7.63k | msg.append(converterId); | 378 | 7.63k | msg.append(LOG4CXX_STR("] in conversion pattern.")); | 379 | 7.63k | LogLog::error(msg); | 380 | 7.63k | patternConverters.push_back( | 381 | 7.63k | LiteralPatternConverter::newInstance(currentLiteral)); | 382 | 7.63k | } | 383 | 119k | else | 384 | 119k | { | 385 | 119k | patternConverters.push_back(pc); | 386 | 119k | pc->setFormattingInfo(formattingInfo); | 387 | | | 388 | 119k | if (currentLiteral.length() > 0) | 389 | 34.8k | { | 390 | 34.8k | patternConverters.push_back( | 391 | 34.8k | LiteralPatternConverter::newInstance(currentLiteral)); | 392 | 34.8k | } | 393 | 119k | } | 394 | 127k | } | 395 | | | 396 | 133k | if (!currentLiteral.empty()) | 397 | 48.5k | { | 398 | 48.5k | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 399 | 48.5k | } | 400 | | | 401 | 133k | return i; | 402 | 133k | } |
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> > >&) Line | Count | Source | 353 | 124k | { | 354 | 124k | LogString convBuf; | 355 | 124k | i = extractConverter(c, pattern, i, convBuf, currentLiteral); | 356 | | | 357 | 124k | if (convBuf.empty()) | 358 | 4.53k | { | 359 | 4.53k | LogLog::error(LOG4CXX_STR("Empty conversion specifier")); | 360 | 4.53k | patternConverters.push_back( | 361 | 4.53k | LiteralPatternConverter::newInstance(currentLiteral)); | 362 | 4.53k | } | 363 | 120k | else | 364 | 120k | { | 365 | 120k | LogString converterId(convBuf); | 366 | | | 367 | 120k | std::vector<LogString> options; | 368 | 120k | i = extractOptions(pattern, i, options); | 369 | | | 370 | 120k | PatternConverterPtr pc( | 371 | 120k | createConverter( | 372 | 120k | converterId, currentLiteral, rules, options)); | 373 | | | 374 | 120k | if (pc == NULL) | 375 | 5.04k | { | 376 | 5.04k | LogString msg(LOG4CXX_STR("Unrecognized conversion specifier [")); | 377 | 5.04k | msg.append(converterId); | 378 | 5.04k | msg.append(LOG4CXX_STR("] in conversion pattern.")); | 379 | 5.04k | LogLog::error(msg); | 380 | 5.04k | patternConverters.push_back( | 381 | 5.04k | LiteralPatternConverter::newInstance(currentLiteral)); | 382 | 5.04k | } | 383 | 115k | else | 384 | 115k | { | 385 | 115k | patternConverters.push_back(pc); | 386 | 115k | pc->setFormattingInfo(formattingInfo); | 387 | | | 388 | 115k | if (currentLiteral.length() > 0) | 389 | 30.0k | { | 390 | 30.0k | patternConverters.push_back( | 391 | 30.0k | LiteralPatternConverter::newInstance(currentLiteral)); | 392 | 30.0k | } | 393 | 115k | } | 394 | 120k | } | 395 | | | 396 | 124k | if (!currentLiteral.empty()) | 397 | 39.6k | { | 398 | 39.6k | currentLiteral.erase(currentLiteral.begin(), currentLiteral.end()); | 399 | 39.6k | } | 400 | | | 401 | 124k | return i; | 402 | 124k | } |
|