log4cplus 2.0.8
socketbuffer.h
Go to the documentation of this file.
1// -*- C++ -*-
2// Module: Log4CPLUS
3// File: socketbuffer.h
4// Created: 5/2003
5// Author: Tad E. Smith
6//
7//
8// Copyright 2003-2017 Tad E. Smith
9//
10// Licensed under the Apache License, Version 2.0 (the "License");
11// you may not use this file except in compliance with the License.
12// You may obtain a copy of the License at
13//
14// http://www.apache.org/licenses/LICENSE-2.0
15//
16// Unless required by applicable law or agreed to in writing, software
17// distributed under the License is distributed on an "AS IS" BASIS,
18// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19// See the License for the specific language governing permissions and
20// limitations under the License.
21
24#ifndef LOG4CPLUS_HELPERS_SOCKET_BUFFER_HEADER_
25#define LOG4CPLUS_HELPERS_SOCKET_BUFFER_HEADER_
26
27#include <log4cplus/config.hxx>
28
29#if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
30#pragma once
31#endif
32
33#include <log4cplus/tstring.h>
34
35
36namespace log4cplus {
37namespace helpers {
38
43{
44public:
45 explicit SocketBuffer(std::size_t max);
46 virtual ~SocketBuffer();
47
48 char *getBuffer() const { return buffer; }
49 std::size_t getMaxSize() const { return maxsize; }
50 std::size_t getSize() const { return size; }
51 void setSize(std::size_t s) { size = s; }
52 std::size_t getPos() const { return pos; }
53
54 unsigned char readByte();
55 unsigned short readShort();
56 unsigned int readInt();
57 tstring readString(unsigned char sizeOfChar);
58
59 void appendByte(unsigned char val);
60 void appendShort(unsigned short val);
61 void appendInt(unsigned int val);
62 void appendString(const tstring& str);
63 void appendBuffer(const SocketBuffer& buffer);
64
65private:
66 // Data
67 std::size_t maxsize;
68 std::size_t size;
69 std::size_t pos;
70 char *buffer;
71
72 SocketBuffer(SocketBuffer const & rhs);
73 SocketBuffer& operator= (SocketBuffer const& rhs);
74};
75
76} // end namespace helpers
77} // end namespace log4cplus
78
79#endif // LOG4CPLUS_HELPERS_SOCKET_HEADER_
tstring readString(unsigned char sizeOfChar)
void appendByte(unsigned char val)
std::size_t getMaxSize() const
void appendString(const tstring &str)
void appendBuffer(const SocketBuffer &buffer)
void appendInt(unsigned int val)
void appendShort(unsigned short val)
std::basic_string< tchar > tstring
Definition tstring.h:39
#define LOG4CPLUS_EXPORT
Definition win32.h:141