diff options
author | FreeArtMan <dos21h@gmail.com> | 2019-05-12 12:46:02 +0100 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2019-05-12 12:46:02 +0100 |
commit | 654bb8b09dd90c12c3a51ffdce800b2255b753b5 (patch) | |
tree | 67591880f34d6220b9026883b0ceb54f022aa385 /buf.h | |
parent | 03bfeedc5f4c04c20764c8a9a58bd02604f27b2c (diff) | |
download | libbuf-654bb8b09dd90c12c3a51ffdce800b2255b753b5.tar.gz libbuf-654bb8b09dd90c12c3a51ffdce800b2255b753b5.zip |
Moved everything to C+. First test works
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 |