Add map for sproto

This commit is contained in:
Cloud Wu
2020-10-10 13:55:15 +08:00
parent eaa60ca8dd
commit 4484c1ed50
5 changed files with 245 additions and 94 deletions

View File

@@ -16,6 +16,9 @@ struct sproto_type;
#define SPROTO_TDOUBLE 3
#define SPROTO_TSTRUCT 4
// container type
#define SPROTO_TARRAY 0x80
// sub type of string (sproto_arg.extra)
#define SPROTO_TSTRING_STRING 0
#define SPROTO_TSTRING_BINARY 1
@@ -46,9 +49,13 @@ struct sproto_arg {
struct sproto_type *subtype;
void *value;
int length;
int index; // array base 1
int index; // array base 1, negative value indicates that it is a empty array
int mainindex; // for map
int extra; // SPROTO_TINTEGER: decimal ; SPROTO_TSTRING 0:utf8 string 1:binary
// When interpretd two fields struct as map, the following fields must not be NULL.
const char *ktagname;
const char *vtagname;
};
typedef int (*sproto_callback)(const struct sproto_arg *args);