Apache Log4cxx  Version 2.0.0
Loading...
Searching...
No Matches
patternparser.h
Go to the documentation of this file.
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
19#ifndef _LOG4CXX_HELPER_PATTERN_CONVERTER_H
20#define _LOG4CXX_HELPER_PATTERN_CONVERTER_H
21
22#include <map>
23#include <vector>
24#include <functional>
28
29namespace LOG4CXX_NS
30{
31namespace pattern
32{
33
34typedef std::function<PatternConverterPtr(const std::vector<LogString>& options)> PatternConstructor;
35typedef std::map<LogString, PatternConstructor> PatternMap;
36LOG4CXX_LIST_DEF(PatternConverterList, PatternConverterPtr);
37
38// Contributors: Nelson Minar <(nelson@monkey.org>
39// Igor E. Poteryaev <jah@mail.ru>
40// Reinhard Deschler <reinhard.deschler@web.de>
41
50class LOG4CXX_EXPORT PatternParser
51{
55 static const logchar ESCAPE_CHAR;
56
57 enum
58 {
59 LITERAL_STATE = 0,
60 CONVERTER_STATE = 1,
61 DOT_STATE = 3,
62 MIN_STATE = 4,
63 MAX_STATE = 5
64 };
65
69 PatternParser();
70
71 private:
87 static size_t extractConverter(
88 logchar lastChar, const LogString& pattern,
89 LogString::size_type i, LogString& convBuf,
90 LogString& currentLiteral);
91
99 static size_t extractOptions(const LogString& pattern, LogString::size_type i,
100 std::vector<LogString>& options);
101
102 public:
108 static PatternConverterList parse
109 ( const LogString& pattern
110 , const PatternMap& rules
111 );
112
113 private:
125 static PatternConverterPtr createConverter(
126 const LogString& converterId,
127 LogString& currentLiteral,
128 const PatternMap& rules,
129 std::vector<LogString>& options);
130
144 static size_t finalizeConverter(
145 logchar c, const LogString& pattern, size_t i,
146 LogString& currentLiteral, const FormattingInfoPtr& formattingInfo,
147 const PatternMap& rules,
148 PatternConverterList& patternConverter
149 );
150
151 static bool isUnicodeIdentifierStart(logchar c);
152 static bool isUnicodeIdentifierPart(logchar c);
153
154
155};
156
157}
158}
159
160
161#endif
static PatternConverterList parse(const LogString &pattern, const PatternMap &rules)
Convert pattern to converters using rules.
Definition cacheddateformat.h:26
std::function< PatternConverterPtr(const std::vector< LogString > &options)> PatternConstructor
Definition patternparser.h:34
std::map< LogString, PatternConstructor > PatternMap
Definition patternparser.h:35
std::shared_ptr< FormattingInfo > FormattingInfoPtr
Definition formattinginfo.h:32
LOG4CXX_LIST_DEF(PatternConverterList, PatternConverterPtr)
std::basic_string< logchar > LogString
Definition logstring.h:51