libsheepy

C lib for handling text files, strings and json like data structure with an object oriented system
git clone https://spartatek.se/git/libsheepy.git
Log | Files | Refs | README | LICENSE

commit 24052ac4c0ccf0c9b493ff35172f4dfc64580c43
parent a9543b431036410a9c8aa976cb504c072f178902
Author: Remy Noulin <loader2x@gmail.com>
Date:   Sat, 12 Oct 2019 10:44:18 +0200

add smallBytes support in isEmptyG

documentation.md                    |  8 ++++++++
release/json/libsheepyCSmallBytes.h |  9 +++++++++
release/libsheepy.h                 |  2 +-
release/libsheepyObject.h           |  3 ++-
src/json/libsheepyCSmallBytes.c     | 13 +++++++++++++
src/json/libsheepyCSmallBytes.h     |  9 +++++++++
src/libsheepy.h                     |  2 +-
src/libsheepyObject.h               |  3 ++-
8 files changed, 45 insertions(+), 4 deletions(-)

Diffstat:
Mdocumentation.md | 8++++++++
Mrelease/json/libsheepyCSmallBytes.h | 9+++++++++
Mrelease/libsheepy.h | 2+-
Mrelease/libsheepyObject.h | 3++-
Msrc/json/libsheepyCSmallBytes.c | 13+++++++++++++
Msrc/json/libsheepyCSmallBytes.h | 9+++++++++
Msrc/libsheepy.h | 2+-
Msrc/libsheepyObject.h | 3++-
8 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/documentation.md b/documentation.md @@ -18477,6 +18477,7 @@ smallBytest* push (smallBytest *self, char data); smallBytest* pushBuffer (smallBytest *self, void *data, uint32_t size); char getAt (smallBytest *self, uint32_t index); size_t len (smallBytest *self); +bool isEmpty(smallBytest *self); smallBytest* readFile(smallBytest *self, const char *filePath); smallBytest* readFileSmallJson(smallBytest *self, smallJsont *filePath); smallBytest* readFileSmallString(smallBytest *self, smallStringt *filePath); @@ -52914,6 +52915,13 @@ bool isEmptySmallArrayG (smallArrayt *self); * true when self is empty (len=0) * false when len > 0 */ +bool isEmptySmallBytes(smallBytest *self); +bool isEmptySmallBytesG(smallBytest *self); +/* + * \return + * true when self is empty (len=0) + * false when len > 0 + */ bool isEmptySmallDict (smallDictt *self); bool isEmptySmallDictG (smallDictt *self); /* diff --git a/release/json/libsheepyCSmallBytes.h b/release/json/libsheepyCSmallBytes.h @@ -89,6 +89,13 @@ typedef char (*getAtSmallBytesFt) (smallBytest *self, uint32_t index); typedef size_t (*lenSmallBytesFt) (smallBytest *self); /** + * \return + * true when self is empty (len=0) + * false when len > 0 + */ +typedef bool (*isEmptySmallBytesFt)(smallBytest *self); + +/** * read file to self * * \param @@ -179,6 +186,7 @@ typedef bool (*equalSmallBytesBaseFt)(smallBytest *self, baset *value); getAtSmallBytesFt getAt;\ /*setAt*/\ lenSmallBytesFt len;\ + isEmptySmallBytesFt isEmpty;\ readFileSmallBytesFt readFile;\ readFileSmallJsonSmallBytesFt readFileSmallJson;\ readFileSmallStringSmallBytesFt readFileSmallString;\ @@ -246,6 +254,7 @@ void freeSmallBytesG (smallBytest *self); char getAtSmallBytesG(smallBytest *self, char retType UNUSED, uint32_t index); smallBytest* pushSmallBytesG (smallBytest *self, char data); size_t lenSmallBytesG(smallBytest *self); +bool isEmptySmallBytesG(smallBytest *self); smallBytest* readFileSmallJsonSmallBytesG(smallBytest *self, smallJsont *filePath); smallBytest* readFileSmallStringSmallBytesG(smallBytest *self, smallStringt *filePath); smallBytest* readFileSmallBytesG(smallBytest *self, const char *filePath); diff --git a/release/libsheepy.h b/release/libsheepy.h @@ -96,7 +96,7 @@ // version accoring to the version package: Release.Major.minor.patch // https://noulin.net/version/file/README.md.html -#define LIBSHEEPY_VERSION "1.0.8" +#define LIBSHEEPY_VERSION "1.0.9" #ifndef SH_PREFIX #define SH_PREFIX(NAME) NAME diff --git a/release/libsheepyObject.h b/release/libsheepyObject.h @@ -3454,7 +3454,7 @@ void finishManyOF(void *paramType, ...); char *: copySmallJsonOS, \ const char*: copySmallJsonOS, \ smallJsont *: copySmallJsonSmallJson, \ - smallStringt *: copySmallJsonO) \ + smallStringt *: copySmallJsonO), \ smallStringt *: _Generic((path2), \ char *: copyOS, \ const char*: copyOS, \ @@ -6018,6 +6018,7 @@ void finishManyOF(void *paramType, ...); const char *: isEmptyS, \ char **: listIsEmptyS, \ smallArrayt *: isEmptySmallArrayG, \ + smallBytest *: isEmptySmallBytesG, \ smallDictt *: isEmptySmallDictG, \ smallJsont *: isEmptySmallJsonG, \ smallStringt *: isEmptySmallStringG \ diff --git a/src/json/libsheepyCSmallBytes.c b/src/json/libsheepyCSmallBytes.c @@ -53,6 +53,7 @@ internal smallBytest* pushSmallBytes(smallBytest *self, char data); internal smallBytest* pushBufferSmallBytes(smallBytest *self, void *data, uint32_t size); internal char getAtSmallBytes(smallBytest *self, uint32_t index); internal size_t lenSmallBytes(smallBytest *self); +internal bool isEmptySmallBytes(smallBytest *self); internal smallBytest* readFileSmallBytes(smallBytest *self, const char *filePath); internal smallBytest* readFileSmallJsonSmallBytes(smallBytest *self, smallJsont *filePath); internal smallBytest* readFileSmallStringSmallBytes(smallBytest *self, smallStringt *filePath); @@ -80,6 +81,7 @@ smallBytest* duplicateSmallBytesG (smallBytest *self); char getAtSmallBytesG(smallBytest *self, char retType UNUSED, uint32_t index); smallBytest* pushSmallBytesG (smallBytest *self, char data); size_t lenSmallBytesG(smallBytest *self); +bool isEmptySmallBytesG(smallBytest *self); smallBytest* readFileSmallBytesG(smallBytest *self, const char *filePath); smallBytest* readFileSmallJsonSmallBytesG(smallBytest *self, smallJsont *filePath); smallBytest* readFileSmallStringSmallBytesG(smallBytest *self, smallStringt *filePath); @@ -129,6 +131,7 @@ void registerMethodsSmallBytes(smallBytesFunctionst *f) { f->pushBuffer = pushBufferSmallBytes; f->getAt = getAtSmallBytes; f->len = lenSmallBytes; + f->isEmpty = isEmptySmallBytes; f->readFile = readFileSmallBytes; f->readFileSmallJson = readFileSmallJsonSmallBytes; f->readFileSmallString = readFileSmallStringSmallBytes; @@ -303,6 +306,11 @@ internal size_t lenSmallBytes(smallBytest *self) { return(self->B->count); } +internal bool isEmptySmallBytes(smallBytest *self) { + + return(!lenSmallBytes(self)); +} + internal smallBytest* readFileSmallBytes(smallBytest *self, const char *filePath) { FILE *f = NULL; ssize_t len; @@ -788,6 +796,11 @@ size_t lenSmallBytesG(smallBytest *self) { return(self->f->len(self)); } +bool isEmptySmallBytesG(smallBytest *self) { + + return(self->f->isEmpty(self)); +} + smallBytest* readFileSmallBytesG(smallBytest *self, const char *filePath) { return(self->f->readFile(self, filePath)); diff --git a/src/json/libsheepyCSmallBytes.h b/src/json/libsheepyCSmallBytes.h @@ -89,6 +89,13 @@ typedef char (*getAtSmallBytesFt) (smallBytest *self, uint32_t index); typedef size_t (*lenSmallBytesFt) (smallBytest *self); /** + * \return + * true when self is empty (len=0) + * false when len > 0 + */ +typedef bool (*isEmptySmallBytesFt)(smallBytest *self); + +/** * read file to self * * \param @@ -179,6 +186,7 @@ typedef bool (*equalSmallBytesBaseFt)(smallBytest *self, baset *value); getAtSmallBytesFt getAt;\ /*setAt*/\ lenSmallBytesFt len;\ + isEmptySmallBytesFt isEmpty;\ readFileSmallBytesFt readFile;\ readFileSmallJsonSmallBytesFt readFileSmallJson;\ readFileSmallStringSmallBytesFt readFileSmallString;\ @@ -246,6 +254,7 @@ void freeSmallBytesG (smallBytest *self); char getAtSmallBytesG(smallBytest *self, char retType UNUSED, uint32_t index); smallBytest* pushSmallBytesG (smallBytest *self, char data); size_t lenSmallBytesG(smallBytest *self); +bool isEmptySmallBytesG(smallBytest *self); smallBytest* readFileSmallJsonSmallBytesG(smallBytest *self, smallJsont *filePath); smallBytest* readFileSmallStringSmallBytesG(smallBytest *self, smallStringt *filePath); smallBytest* readFileSmallBytesG(smallBytest *self, const char *filePath); diff --git a/src/libsheepy.h b/src/libsheepy.h @@ -96,7 +96,7 @@ // version accoring to the version package: Release.Major.minor.patch // https://noulin.net/version/file/README.md.html -#define LIBSHEEPY_VERSION "1.0.8" +#define LIBSHEEPY_VERSION "1.0.9" #ifndef SH_PREFIX #define SH_PREFIX(NAME) NAME diff --git a/src/libsheepyObject.h b/src/libsheepyObject.h @@ -3454,7 +3454,7 @@ void finishManyOF(void *paramType, ...); char *: copySmallJsonOS, \ const char*: copySmallJsonOS, \ smallJsont *: copySmallJsonSmallJson, \ - smallStringt *: copySmallJsonO) \ + smallStringt *: copySmallJsonO), \ smallStringt *: _Generic((path2), \ char *: copyOS, \ const char*: copyOS, \ @@ -6018,6 +6018,7 @@ void finishManyOF(void *paramType, ...); const char *: isEmptyS, \ char **: listIsEmptyS, \ smallArrayt *: isEmptySmallArrayG, \ + smallBytest *: isEmptySmallBytesG, \ smallDictt *: isEmptySmallDictG, \ smallJsont *: isEmptySmallJsonG, \ smallStringt *: isEmptySmallStringG \