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

parse struct definition file. More...

#include "struct/struct_parse.h"
#include <ctype.h>
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include "utils/hash_map.h"
#include "utils/io.h"
#include "utils/sstr.h"
Include dependency graph for struct_parse.c:

Macros

#define PERROR(parser, fmt, ...)
 

Functions

struct struct_parserstruct_parser_new ()
 create and init a struct_parser instance. More...
 
void struct_parser_free (struct struct_parser *parser)
 free a struct_parser instance. More...
 
int struct_parser_parse (struct struct_parser *parser, sstr_t content)
 parse a struct definition file, and store the parsed structs in struct_parser. More...
 

Detailed Description

parse struct definition file.

Macro Definition Documentation

◆ PERROR

#define PERROR (   parser,
  fmt,
  ... 
)
Value:
fprintf(stderr, "file %s, line %d, col %d: " fmt, parser->name, \
parser->pos.line, parser->pos.col, ##__VA_ARGS__)

Function Documentation

◆ struct_parser_free()

void struct_parser_free ( struct struct_parser parser)

free a struct_parser instance.

Parameters
parserstruct struct_parser*

◆ struct_parser_new()

struct struct_parser* struct_parser_new ( )

create and init a struct_parser instance.

Returns
struct struct_parser* if success, NULL otherwise.

◆ struct_parser_parse()

int struct_parser_parse ( struct struct_parser parser,
sstr_t  content 
)

parse a struct definition file, and store the parsed structs in struct_parser.

Parameters
parsercontext of parser.
contentcontent of the file.
Returns
int 0 if success, -1 otherwise.