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

generate json manipulate codes. More...

#include "utils/hash_map.h"
#include "utils/sstr.h"
Include dependency graph for gencode.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define OUTPUT_C_FILENAME   "json.gen.c"
 
#define OUTPUT_H_FILENAME   "json.gen.h"
 
#define OUTPUT_MSGPACK_C_FILENAME   "msgpack.gen.c"
 
#define OUTPUT_MSGPACK_H_FILENAME   "msgpack.gen.h"
 
#define OUTPUT_CBOR_C_FILENAME   "cbor.gen.c"
 
#define OUTPUT_CBOR_H_FILENAME   "cbor.gen.h"
 
#define OUTPUT_CPP_FILENAME   "json_gen_c.gen.hpp"
 
#define OUTPUT_RUST_FILENAME   "json_gen_c.gen.rs"
 
#define OUTPUT_GO_FILENAME   "json_gen_c.gen.go"
 

Functions

int gencode_source (struct hash_map *struct_map, struct hash_map *enum_map, struct hash_map *oneof_map, sstr_t source, sstr_t header)
 generate json manipulate codes by struct_map, enum_map and oneof_map into source and header.
 
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.
 
int gencode_cbor_source (struct hash_map *struct_map, struct hash_map *enum_map, struct hash_map *oneof_map, sstr_t source, sstr_t header)
 generate CBOR (RFC 8949) pack/unpack codes.
 
int gencode_cpp_wrapper (struct hash_map *struct_map, struct hash_map *enum_map, struct hash_map *oneof_map, const char *c_header_name, int format, sstr_t output)
 generate C++ wrapper header (.gen.hpp) that provides RAII classes around the generated C structs.
 
int gencode_rust (struct hash_map *struct_map, struct hash_map *enum_map, struct hash_map *oneof_map, sstr_t output)
 generate a Rust module (.rs) with native serde-compatible structs and enums.
 
int gencode_go (struct hash_map *struct_map, struct hash_map *enum_map, struct hash_map *oneof_map, const char *package_name, sstr_t output)
 generate a Go source file (.go) with native encoding/json-compatible structs and enums.
 

Detailed Description

generate json manipulate codes.

Author
your name (you@d.nosp@m.omai.nosp@m.n.com)

Function Documentation

◆ gencode_cpp_wrapper()

int gencode_cpp_wrapper ( struct hash_map struct_map,
struct hash_map enum_map,
struct hash_map oneof_map,
const char *  c_header_name,
int  format,
sstr_t  output 
)
extern

generate C++ wrapper header (.gen.hpp) that provides RAII classes around the generated C structs.

Parameters
struct_mapparsed struct definitions.
enum_mapparsed enum definitions.
oneof_mapparsed oneof (tagged union) definitions.
c_header_namefilename of the generated C header to include.
formatoutput format (0=json, 1=msgpack, 2=cbor) for marshal prefix.
outputthe output C++ header content.
Returns
0 on success, -1 on failure.

◆ gencode_go()

int gencode_go ( struct hash_map struct_map,
struct hash_map enum_map,
struct hash_map oneof_map,
const char *  package_name,
sstr_t  output 
)
extern

generate a Go source file (.go) with native encoding/json-compatible structs and enums.

Parameters
struct_mapparsed struct definitions.
enum_mapparsed enum definitions.
oneof_mapparsed oneof (tagged union) definitions.
package_nameGo package name to use.
outputthe output Go source content.
Returns
0 on success, -1 on failure.

◆ 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 
)
extern

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.

◆ gencode_rust()

int gencode_rust ( struct hash_map struct_map,
struct hash_map enum_map,
struct hash_map oneof_map,
sstr_t  output 
)
extern

generate a Rust module (.rs) with native serde-compatible structs and enums.

Parameters
struct_mapparsed struct definitions.
enum_mapparsed enum definitions.
oneof_mapparsed oneof (tagged union) definitions.
outputthe output Rust source content.
Returns
0 on success, -1 on failure.

◆ gencode_source()

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

generate json manipulate codes by struct_map, enum_map and oneof_map into source and header.

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.