json-gen-c  0.1.5
json-gen-c generate C code for json manipulation
gencode_msgpack.c File Reference

Generate MessagePack pack/unpack C code from parsed schema. More...

#include "gencode/gencode.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "struct/struct_parse.h"
#include "utils/hash_map.h"
#include "utils/sstr.h"
#include "utils/hash.h"
#include "extra_codes_msgpack.inc"
Include dependency graph for gencode_msgpack.c:

Classes

struct  mp_gen_struct_param
 
struct  mp_gen_oneof_param
 

Macros

#define DEPENDENCY_HASH_MAP_BUCKET_SIZE   4096
 
#define WIRE_KEY(f)   sstr_cstr((f)->json_name ? (f)->json_name : (f)->name)
 

Functions

int gencode_msgpack_source (struct hash_map *struct_map, struct hash_map *enum_map, struct hash_map *oneof_map, sstr_t source, sstr_t header)
 generate MessagePack pack/unpack codes.
 

Detailed Description

Generate MessagePack pack/unpack C code from parsed schema.

Parallel to gencode.c (JSON) but emits binary MessagePack codec using the msgpack_codec.h/c embedded runtime.

Function Documentation

◆ gencode_msgpack_source()

int gencode_msgpack_source ( struct hash_map struct_map,
struct hash_map enum_map,
struct hash_map oneof_map,
sstr_t  source,
sstr_t  header 
)

generate MessagePack pack/unpack codes.

Parameters
struct_mapthe hash map that store all structs parsed from struct defintion files.
enum_mapthe hash map that store all enums parsed from enum definitions.
oneof_mapthe hash map that store all oneof (tagged union) definitions.
sourcethe output source code.
headerthe output header code.
Returns
int 0 if success, -1 if failed.