Coverage Report

Created: 2025-08-24 06:21

/src/logging-log4cxx/src/main/cpp/namepatternconverter.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/namepatternconverter.h>
20
#include <log4cxx/pattern/nameabbreviator.h>
21
#include <log4cxx/spi/loggingevent.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
28
38.1k
#define priv static_cast<NamePatternConverterPrivate*>(m_priv.get())
29
30
struct NamePatternConverter::NamePatternConverterPrivate : public PatternConverterPrivate
31
{
32
  NamePatternConverterPrivate( const LogString& name, const LogString& style, const NameAbbreviatorPtr abbrev ) :
33
19.8k
    PatternConverterPrivate( name, style ),
34
19.8k
    abbreviator(abbrev) {}
log4cxx::pattern::NamePatternConverter::NamePatternConverterPrivate::NamePatternConverterPrivate(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> > const&, std::__1::shared_ptr<log4cxx::pattern::NameAbbreviator>)
Line
Count
Source
33
8.86k
    PatternConverterPrivate( name, style ),
34
8.86k
    abbreviator(abbrev) {}
log4cxx::pattern::NamePatternConverter::NamePatternConverterPrivate::NamePatternConverterPrivate(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> > const&, std::__1::shared_ptr<log4cxx::pattern::NameAbbreviator>)
Line
Count
Source
33
10.9k
    PatternConverterPrivate( name, style ),
34
10.9k
    abbreviator(abbrev) {}
35
36
  /**
37
   * Abbreviator.
38
   */
39
  const NameAbbreviatorPtr abbreviator;
40
};
41
42
IMPLEMENT_LOG4CXX_OBJECT(NamePatternConverter)
43
44
NamePatternConverter::NamePatternConverter(
45
  const LogString& name1,
46
  const LogString& style1,
47
  const std::vector<LogString>& options) :
48
19.8k
  LoggingEventPatternConverter(std::make_unique<NamePatternConverterPrivate>(name1, style1,
49
19.8k
      getAbbreviator(options)))
50
19.8k
{
51
19.8k
}
log4cxx::pattern::NamePatternConverter::NamePatternConverter(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> > 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> > > > const&)
Line
Count
Source
48
8.86k
  LoggingEventPatternConverter(std::make_unique<NamePatternConverterPrivate>(name1, style1,
49
8.86k
      getAbbreviator(options)))
50
8.86k
{
51
8.86k
}
log4cxx::pattern::NamePatternConverter::NamePatternConverter(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> > 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> > > > const&)
Line
Count
Source
48
10.9k
  LoggingEventPatternConverter(std::make_unique<NamePatternConverterPrivate>(name1, style1,
49
10.9k
      getAbbreviator(options)))
50
10.9k
{
51
10.9k
}
52
53
NameAbbreviatorPtr NamePatternConverter::getAbbreviator(
54
  const std::vector<LogString>& options)
55
19.8k
{
56
19.8k
  if (options.size() > 0)
57
19.7k
  {
58
19.7k
    return NameAbbreviator::getAbbreviator(options[0]);
59
19.7k
  }
60
61
4
  return NameAbbreviator::getDefaultAbbreviator();
62
19.8k
}
log4cxx::pattern::NamePatternConverter::getAbbreviator(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&)
Line
Count
Source
55
8.86k
{
56
8.86k
  if (options.size() > 0)
57
8.86k
  {
58
8.86k
    return NameAbbreviator::getAbbreviator(options[0]);
59
8.86k
  }
60
61
2
  return NameAbbreviator::getDefaultAbbreviator();
62
8.86k
}
log4cxx::pattern::NamePatternConverter::getAbbreviator(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&)
Line
Count
Source
55
10.9k
{
56
10.9k
  if (options.size() > 0)
57
10.9k
  {
58
10.9k
    return NameAbbreviator::getAbbreviator(options[0]);
59
10.9k
  }
60
61
2
  return NameAbbreviator::getDefaultAbbreviator();
62
10.9k
}
63
64
/**
65
 * Abbreviate name in string buffer.
66
 * @param nameStart starting position of name to abbreviate.
67
 * @param buf string buffer containing name.
68
 */
69
void NamePatternConverter::abbreviate(LogString::size_type nameStart, LogString& buf) const
70
19.0k
{
71
19.0k
  priv->abbreviator->abbreviate(nameStart, buf);
72
19.0k
}
log4cxx::pattern::NamePatternConverter::abbreviate(unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) const
Line
Count
Source
70
6.09k
{
71
6.09k
  priv->abbreviator->abbreviate(nameStart, buf);
72
6.09k
}
log4cxx::pattern::NamePatternConverter::abbreviate(unsigned long, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >&) const
Line
Count
Source
70
12.9k
{
71
12.9k
  priv->abbreviator->abbreviate(nameStart, buf);
72
12.9k
}