From 654bb8b09dd90c12c3a51ffdce800b2255b753b5 Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Sun, 12 May 2019 12:46:02 +0100 Subject: Moved everything to C+. First test works --- buf.h | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'buf.h') diff --git a/buf.h b/buf.h index 4db4f62..212577d 100644 --- a/buf.h +++ b/buf.h @@ -5,16 +5,20 @@ #include #include #include +#include +/* 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 -- cgit v1.2.3