1 // Module: Log4CPLUS
2 // File: socketbuffer.h
3 // Created: 5/2003
4 // Author: Tad E. Smith
5 //
6 //
7 // Copyright (C) Tad E. Smith All rights reserved.
8 //
9 // This software is published under the terms of the Apache Software
10 // License version 1.1, a copy of which has been included with this
11 // distribution in the LICENSE.APL file.
12 //
13
14 /** @file */
15
16 #ifndef LOG4CPLUS_HELPERS_SOCKET_BUFFER_HEADER_
17 #define LOG4CPLUS_HELPERS_SOCKET_BUFFER_HEADER_
18
19 #include <log4cplus/config.h>
20 #include <log4cplus/tstring.h>
21 #include <log4cplus/helpers/logloguser.h>
22
23
24 namespace log4cplus {
25 namespace helpers {
26
27 /**
28 *
29 */
30 class LOG4CPLUS_EXPORT SocketBuffer : protected log4cplus::helpers::LogLogUser
31 {
32 public:
33 SocketBuffer(size_t max);
34 SocketBuffer(const SocketBuffer& rhs);
35 ~SocketBuffer();
36
37 SocketBuffer& operator=(const SocketBuffer& rhs);
38
39 char *getBuffer() const { return buffer; }
40 size_t getMaxSize() const { return maxsize; }
41 size_t getSize() const { return size; }
42 void setSize(size_t s) { size = s; }
43 size_t getPos() const { return pos; }
44
45 unsigned char readByte();
46 unsigned short readShort();
47 unsigned int readInt();
48 tstring readString(unsigned char sizeOfChar);
49
50 void appendByte(unsigned char val);
51 void appendShort(unsigned short val);
52 void appendInt(unsigned int val);
53 void appendSize_t(size_t val);
54 void appendString(const tstring& str);
55 void appendBuffer(const SocketBuffer& buffer);
56
57 private:
58 // Methods
59 void copy(const SocketBuffer& rhs);
60
61 // Data
62 size_t maxsize;
63 size_t size;
64 size_t pos;
65 char *buffer;
66 };
67
68 } // end namespace helpers
69 } // end namespace log4cplus
70
71 #endif // LOG4CPLUS_HELPERS_SOCKET_HEADER_
syntax highlighted by Code2HTML, v. 0.9.1