diff options
Diffstat (limited to 'buf.h')
-rw-r--r-- | buf.h | 37 |
1 files changed, 36 insertions, 1 deletions
@@ -5,16 +5,20 @@ #include <stdio.h> #include <string.h> #include <ctype.h> +#include <unistd.h> +/* typedef struct bbuf { int size; //total size int buf_size; //used size char *buf; } bbuf; +*/ //operations on plain buffers also operations on bufer to buffer should be //supoorted +/* //create new buffer without content bbuf* bbuf_new(int size); @@ -33,7 +37,8 @@ int bbuf_inc(bbuf *a, char *b, int size); //decrease buffer for size int bbuf_dec(bbuf *a, char *b, int size); //free buffer -void bbuf_free(bbuf *buf); +int bbuf_set_max(bbuf *buf); +int bbuf_memset(bbuf *buf, char c); int bbuf_concat(bbuf *a, bbuf *b); @@ -42,5 +47,35 @@ int bbuf_size(bbuf *a); int bbuf_print(bbuf *a); void bbuf_free(bbuf *buf); +*/ + +class Buf +{ +private: + int cur_size; + int buf_size; + char *buf; +public: + Buf(int size); + ~Buf(); + + int set(char *val, int size); + int set(char *val); + Buf* copy(); + int get(char **val, int *size); + int realloc(int size); + int reduce(); + int inc(int size); + int dec(int size); + int set_max(); + int memset(char c); + int concat(Buf *b); + int size(); + int cursize(); + int print(); + int setc(int idx, char c); + int pushc(char c); + int getc(int idx, char *c); +}; #endif
\ No newline at end of file |