Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# socketbuffer.h

Go to the documentation of this file.

    00001 // Module:  Log4CPLUS
    00002 // File:    socketbuffer.h
    00003 // Created: 5/2003
    00004 // Author:  Tad E. Smith
    00005 //
    00006 //
    00007 // Copyright (C) Tad E. Smith  All rights reserved.
    00008 //
    00009 // This software is published under the terms of the Apache Software
    00010 // License version 1.1, a copy of which has been included with this
    00011 // distribution in the LICENSE.APL file.
    00012 //
    00013
    00016 #ifndef LOG4CPLUS_HELPERS_SOCKET_BUFFER_HEADER_
    00017 #define LOG4CPLUS_HELPERS_SOCKET_BUFFER_HEADER_
    00018
    00019 #include <log4cplus/config.h>
    00020 #include <log4cplus/tstring.h>
    00021 #include <log4cplus/helpers/logloguser.h>
    00022
    00023
    00024 namespace log4cplus {
    00025     namespace helpers {
    00026
    00030         class LOG4CPLUS_EXPORT SocketBuffer : protected log4cplus::helpers::LogLogUser
    00031         {
    00032         public:
    00033             SocketBuffer(size_t max);
    00034             SocketBuffer(const SocketBuffer& rhs);
    00035             ~SocketBuffer();
    00036
    00037             SocketBuffer& operator=(const SocketBuffer& rhs);
    00038
    00039             char *getBuffer() const { return buffer; }
    00040             size_t getMaxSize() const { return maxsize; }
    00041             size_t getSize() const { return size; }
    00042             void setSize(size_t s) { size = s; }
    00043             size_t getPos() const { return pos; }
    00044
    00045             unsigned char readByte();
    00046             unsigned short readShort();
    00047             unsigned int readInt();
    00048             tstring readString(unsigned char sizeOfChar);
    00049
    00050             void appendByte(unsigned char val);
    00051             void appendShort(unsigned short val);
    00052             void appendInt(unsigned int val);
    00053             void appendSize_t(size_t val);
    00054             void appendString(const tstring& str);
    00055             void appendBuffer(const SocketBuffer& buffer);
    00056
    00057         private:
    00058           // Methods
    00059             void copy(const SocketBuffer& rhs);
    00060
    00061           // Data
    00062             size_t maxsize;
    00063             size_t size;
    00064             size_t pos;
    00065             char *buffer;
    00066         };
    00067
    00068     } // end namespace helpers
    00069 } // end namespace log4cplus
    00070
    00071 #endif // LOG4CPLUS_HELPERS_SOCKET_HEADER_
    00072