spbuffer.hpp
1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* Copyright 2007 Stephen Liu
* For license terms, see the file COPYING along with this library.
*/
#ifndef __spbuffer_hpp__
#define __spbuffer_hpp__
#include <stdlib.h>
#include <event2/buffer.h>
#ifdef WIN32
typedef struct spwin32buffer sp_evbuffer_t;
#else
typedef struct evbuffer sp_evbuffer_t;
#endif
struct evbuffer;
class SP_Buffer {
public:
SP_Buffer();
~SP_Buffer();
int append( const void * buffer, int len = 0 );
int append( const SP_Buffer * buffer );
int printf( const char *fmt, ... );
void erase( int len );
void reset();
int truncate( int len );
void reserve( int len );
int getCapacity();
const void * getBuffer() const;
const void * getRawBuffer() const;
size_t getSize() const;
int take( char * buffer, int len );
char * getLine();
const void * find( const void * key, size_t len );
SP_Buffer * take();
private:
sp_evbuffer_t * mBuffer;
friend class SP_IOChannel;
friend class SP_IocpEventCallback;
};
#endif