/src/logging-log4cxx/src/main/cpp/literalpatternconverter.cpp
Line | Count | Source (jump to first uncovered line) |
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/literalpatternconverter.h> |
20 | | #include <log4cxx/spi/loggingevent.h> |
21 | | #include <log4cxx/spi/location/locationinfo.h> |
22 | | #include <log4cxx/private/patternconverter_priv.h> |
23 | | |
24 | | using namespace LOG4CXX_NS; |
25 | | using namespace LOG4CXX_NS::pattern; |
26 | | using namespace LOG4CXX_NS::spi; |
27 | | using namespace LOG4CXX_NS::helpers; |
28 | | |
29 | 0 | #define priv static_cast<LiteralPatternConverterPrivate*>(m_priv.get()) |
30 | | |
31 | | struct LiteralPatternConverter::LiteralPatternConverterPrivate : public PatternConverterPrivate |
32 | | { |
33 | | LiteralPatternConverterPrivate( const LogString& name, const LogString& style, const LogString& literal1 ) : |
34 | 0 | PatternConverterPrivate( name, style ), |
35 | 0 | literal(literal1) {} |
36 | | |
37 | | /** |
38 | | * String literal. |
39 | | */ |
40 | | const LogString literal; |
41 | | }; |
42 | | |
43 | | IMPLEMENT_LOG4CXX_OBJECT(LiteralPatternConverter) |
44 | | |
45 | | LiteralPatternConverter::LiteralPatternConverter(const LogString& literal1) : |
46 | 0 | LoggingEventPatternConverter(std::make_unique<LiteralPatternConverterPrivate> |
47 | 0 | (LOG4CXX_STR("Literal"), LOG4CXX_STR("literal"), literal1)) |
48 | 0 | { |
49 | 0 | } Unexecuted instantiation: log4cxx::pattern::LiteralPatternConverter::LiteralPatternConverter(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&) Unexecuted instantiation: log4cxx::pattern::LiteralPatternConverter::LiteralPatternConverter(std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&) |
50 | | |
51 | | PatternConverterPtr LiteralPatternConverter::newInstance( |
52 | | const LogString& literal) |
53 | 0 | { |
54 | 0 | if (literal.length() == 1 && literal[0] == 0x20 /* ' ' */) |
55 | 0 | { |
56 | 0 | static WideLife<PatternConverterPtr> blank = std::make_shared<LiteralPatternConverter>(literal); |
57 | 0 | return blank; |
58 | 0 | } |
59 | | |
60 | 0 | return std::make_shared<LiteralPatternConverter>(literal); |
61 | 0 | } |
62 | | |
63 | | void LiteralPatternConverter::format( |
64 | | const LoggingEventPtr& /* event */, |
65 | | LogString& toAppendTo, |
66 | | Pool& /* p */) const |
67 | 0 | { |
68 | 0 | toAppendTo.append(priv->literal); |
69 | 0 | } |
70 | | |
71 | | void LiteralPatternConverter::format( |
72 | | const ObjectPtr& /* event */, |
73 | | LogString& toAppendTo, |
74 | | Pool& /* p */) const |
75 | 0 | { |
76 | 0 | toAppendTo.append(priv->literal); |
77 | 0 | } |
78 | | |