Apache Log4cxx  Version 1.7.0
Loading...
Searching...
No Matches
bytebuffer.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#ifndef _LOG4CXX_HELPERS_BYTEBUFFER_H
19#define _LOG4CXX_HELPERS_BYTEBUFFER_H
20
21#include <log4cxx/log4cxx.h>
22#include <stdio.h>
23
24namespace LOG4CXX_NS
25{
26
27namespace helpers
28{
29
40class LOG4CXX_EXPORT ByteBuffer
41{
42 private:
43 LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(ByteBufferPriv, m_priv)
44
45 public:
47 ByteBuffer(char* data, size_t capacity);
49
52 void carry();
53
56 void clear();
57
60 void flip();
61
63 char* data();
65 const char* data() const;
66
68 char* current();
70 const char* current() const;
71
75 size_t limit() const;
76
77#if LOG4CXX_ABI_VERSION <= 15
83 [[ deprecated( "Use flip instead" ) ]]
84 void limit(size_t newLimit);
85#endif
86
88 size_t position() const;
89
92 size_t remaining() const;
93
94#if LOG4CXX_ABI_VERSION <= 15
99 [[ deprecated( "Use increment_position instead" ) ]]
100 void position(size_t newPosition);
101#endif
106 size_t increment_position(size_t byteCount);
107
111 bool put(char byteValue);
112
113
114 private:
115 ByteBuffer(const ByteBuffer&);
116 ByteBuffer& operator=(const ByteBuffer&);
117};
118} // namespace helpers
119
120} //namespace log4cxx
121
122#endif //_LOG4CXX_HELPERS_BYTEBUFFER_H
size_t position() const
The offset of the current cursor from the start of the memory area.
void clear()
Set the cursor to the start of the memory area and use the capacity as the extent to which the cursor...
bool put(char byteValue)
Store byteValue at the cursor position and advance the cursor position unless the cursor cannot advan...
size_t remaining() const
The number of bytes from the current cursor until the cursor can no longer advance.
const char * data() const
The start of the memory area.
size_t increment_position(size_t byteCount)
Advance the cursor by byteCount if that does not exceed the extent to which the cursor can advance,...
void limit(size_t newLimit)
Use newLimit as the extent to which the cursor can advance.
char * current()
The memory at the cursor position.
size_t limit() const
The extent to which the cursor can advance as an offset from the start of the memory area.
const char * current() const
The memory at the cursor position.
ByteBuffer(char *data, size_t capacity)
A capacity sized area of memory at data.
void position(size_t newPosition)
Use newPosition as the cursor position providing it is less than the extent to which the cursor can a...
void flip()
Set the extent to which the cursor can advance, limit(), to the current cursor position and move the ...
char * data()
The start of the memory area.
void carry()
Move the remaining bytes to the start of the memory area and set the cursor to the end of the those b...