Coverage Report

Created: 2026-09-14 06:53

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/logging-log4cxx/src/main/cpp/bytebuffer.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
#include <log4cxx/logstring.h>
18
#include <log4cxx/private/bytebuffer_priv.h>
19
#if LOG4CXX_ABI_VERSION <= 15
20
#include <log4cxx/helpers/exception.h>
21
#endif
22
#include <cstring>
23
24
using namespace LOG4CXX_NS;
25
using namespace LOG4CXX_NS::helpers;
26
27
ByteBuffer::ByteBuffer(char* data1, size_t capacity)
28
7.51k
  : m_priv(std::make_unique<ByteBufferPriv>(data1, capacity))
29
7.51k
{
30
7.51k
}
31
32
ByteBuffer::~ByteBuffer()
33
7.51k
{
34
7.51k
}
35
36
ByteBufferPriv& ByteBuffer::impl()
37
23.1M
{
38
23.1M
    return *m_priv;
39
23.1M
}
40
41
void ByteBuffer::clear()
42
0
{
43
0
  m_priv->clear();
44
0
}
45
46
void ByteBuffer::carry()
47
0
{
48
0
  m_priv->carry();
49
0
}
50
51
void ByteBuffer::flip()
52
0
{
53
0
  m_priv->flip();
54
0
}
55
56
#if LOG4CXX_ABI_VERSION <= 15
57
void ByteBuffer::position(size_t newPosition)
58
0
{
59
0
  if (newPosition < m_priv->lim)
60
0
  {
61
0
    m_priv->pos = newPosition;
62
0
  }
63
0
  else
64
0
  {
65
0
    m_priv->pos = m_priv->lim;
66
0
  }
67
0
}
68
69
void ByteBuffer::limit(size_t newLimit)
70
0
{
71
0
  if (newLimit > m_priv->cap)
72
0
  {
73
0
    throw IllegalArgumentException(LOG4CXX_STR("newLimit"));
74
0
  }
75
76
0
  m_priv->lim = newLimit;
77
78
0
  if (m_priv->pos > m_priv->lim)
79
0
  {
80
0
    m_priv->pos = m_priv->lim;
81
0
  }
82
0
}
83
#endif
84
85
bool ByteBuffer::put(char byte)
86
0
{
87
0
  return m_priv->put(byte);
88
0
}
89
90
char* ByteBuffer::data()
91
0
{
92
0
  return m_priv->data();
93
0
}
94
95
const char* ByteBuffer::data() const
96
0
{
97
0
  return m_priv->data();
98
0
}
99
100
char* ByteBuffer::current()
101
0
{
102
0
  return m_priv->current();
103
0
}
104
105
const char* ByteBuffer::current() const
106
0
{
107
0
  return m_priv->current();
108
0
}
109
110
size_t ByteBuffer::limit() const
111
0
{
112
0
  return m_priv->limit();
113
0
}
114
115
size_t ByteBuffer::position() const
116
0
{
117
0
  return m_priv->position();
118
0
}
119
120
size_t ByteBuffer::remaining() const
121
23.1M
{
122
23.1M
  return m_priv->remaining();
123
23.1M
}
124
125
size_t ByteBuffer::increment_position(size_t byteCount)
126
23.1M
{
127
23.1M
    return m_priv->increment_position(byteCount);
128
23.1M
}