Apache Log4cxx  Version 2.0.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{
29struct ByteBufferPriv;
30
41class LOG4CXX_EXPORT ByteBuffer
42{
43 private:
44 LOG4CXX_DECLARE_PRIVATE_MEMBER(std::unique_ptr<ByteBufferPriv>, m_priv);
45
46 public:
48 ByteBuffer(char* data, size_t capacity);
50
53 void carry();
54
57 void clear();
58
61 void flip();
62
64 char* data();
66 const char* data() const;
67
69 char* current();
71 const char* current() const;
72
76 size_t limit() const;
77
78
80 size_t position() const;
81
84 size_t remaining() const;
85
90 size_t increment_position(size_t byteCount);
91
95 bool put(char byteValue);
96
98 ByteBufferPriv& impl();
99 private:
100 ByteBuffer(const ByteBuffer&);
101 ByteBuffer& operator=(const ByteBuffer&);
102};
103} // namespace helpers
104
105} //namespace log4cxx
106
107#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,...
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.
ByteBufferPriv & impl()
Internal use only.
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 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...