RT
Data Structures | Macros | Typedefs | Functions
parse.h File Reference
#include <stddef.h>
#include "rtstruct.h"
#include "t_data.h"
Include dependency graph for parse.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  s_parse
 
struct  s_parse_txt
 
struct  s_objset
 
struct  s_built
 

Macros

#define ERR_P_CAMERA   "Err : camera is missing"
 
#define ERR_P_CONTENT   "Err : content is missing"
 
#define ERR_UNKNWD_OBJ   "Err : Unknown object"
 
#define ERR_UNKNWD_MAT   "Err : Unknown material"
 
#define ERR_UNKNWD_OBJ_A   "Err : Unknown object in animation list"
 
#define ERR_UNKNWD_MOTION   "Err : Unknown motion in animation list"
 
#define ERR_PARSE_VEC3   "Err : [Vec3] Wrong number of args"
 
#define ERR_PARSE_FLOAT   "Err : [Float] Wrong number of args"
 
#define ERR_PARSE_COLOR   "Err : [Color] Wrong number of args"
 
#define ERR_PARSE_VEC2   "Err : [Vec2] Wrong number of args"
 
#define ERR_OP_EQUAL_OBJ   "Err : [Csg] sizeof(t_obj) == sizeof(t_csg_op)"
 
#define ERR_PARSE_STRN   "Err : line is NULL"
 
#define ERR_GREED_NULL   "Err : greed is NULL"
 
#define ERR_PARSE_OUTR   "Err : line_idx out of range"
 
#define ERR_P_CLOSE_PAR   "Err : Missing parenthese"
 
#define ERR_P_BRACKET_CLSE   "Err : Missing closing bracket"
 
#define ERR_P_BRACKET_OPEN   "Err : Missing opening bracket"
 
#define ERR_P_KEY   "Err : Missing key"
 
#define ERR_PARSE_SET_SP   "Err : *sphere is null"
 
#define ERR_PARSE_SET_CY   "Err : *cylinder is null"
 
#define ERR_PARSE_SET_PL   "Err : *plan is null"
 
#define ERR_PARSE_SET_CO   "Err : *cone is null"
 
#define ERR_PARSE_SET_LI   "Err : *light is null"
 
#define ERR_PARSE_SET_CSG   "Err : *csg is null"
 
#define ERR_FILE   "Err : File is too small to be valid"
 
#define CSV_MATERIAL_COLUMN_COUNT   17
 

Typedefs

typedef struct s_parse_txt t_parse_txt
 
typedef struct s_parse t_parse
 
typedef struct s_objset t_objset
 
typedef struct s_built t_built
 

Functions

void err_set (t_parse_txt *scene_file, const char err_func[], int line_in_code, const char err_file[])
 Save data that produce the exit. More...
 
void err_exit (char *err_msg, t_parse_txt *scene_file)
 Print the exit message and exit after cleaning the data allocated. More...
 
char * pop_line (t_parse_txt *scene_file)
 Return the curr_line and move line_idx to the next line. More...
 
char * get_curr_line (t_parse_txt *scene_file)
 Check if the line_idx is in range and return the curr_line. More...
 
void init_parse_cfg (int type, t_parse *config)
 Setting config for the type of object we want to parse. More...
 
int load_parse_txt (t_parse_txt *s_f, t_data *app, char *filename)
 : Load a file into the t_parse_txt & bind the hooks and t_data app More...
 
void check_opening_bracket (t_parse_txt *scene_file)
 Verify that the curr_line is a opening bracket. More...
 
void check_closing_bracket (t_parse_txt *scene_file)
 Verify that the curr_line is a closing bracket. More...
 
void create_obj_from_txt (t_obj *obj, t_parse_txt *scene_f, int type)
 General parser for all of the shapes. More...
 
void parse_light (t_parse_txt *scene_file)
 Built a light obj and add it to the scene.lst_light. More...
 
void parse_shape (t_parse_txt *scene_file, int type)
 Built a shape obj and add it to the scene.lst_obj. More...
 
void parse_anim (t_parse_txt *scene_file)
 
void parse_motion (t_parse_txt *scene_file, t_anim *anim)
 
t_color parse_color (char *key, t_parse_txt *scene_file)
 
float parse_fval (char *key, t_parse_txt *scene_file)
 
t_vec3 parse_vector (char *key, t_parse_txt *scene_file)
 
t_vec2 parse_vec2 (char *key, t_parse_txt *scene_file)
 
char * parse_str (t_parse_txt *scene_file, char *key)
 
t_textureparse_texture (char *key_name, t_parse_txt *scene_file)
 
int parse_int (char *key, t_parse_txt *scene_file)
 
void sphere_new (t_obj *obj, void *res)
 
void plane_new (t_obj *obj, void *res)
 
void cylinder_new (t_obj *obj, void *res)
 
void cone_new (t_obj *obj, void *res)
 
void cube_new (t_obj *obj, void *res)
 
char * name_obj (int type, int *nb)
 
int matcmp (void *content, void *key)
 
int texcmp (void *content, void *key)
 
int obj_cmp_key (void *content, void *key)
 
int light_cmp_key (void *content, void *key)
 
void load_texture (t_texture *tex)
 
void load_nbind_texture (t_texture *tex, uint32_t *bind)
 
void open_textures (t_data *app)
 
int get_obj_type (char *obj_type)
 
char * get_args_key_require (t_parse_txt *scene_file, const char *key)
 Verify curr_line is containing the proper value and key. More...
 
char * get_args_after_key (t_parse_txt *scene_file, const char *key)
 
void obj_set (t_obj *obj, int type)
 Setting the obj struct. More...
 
void light_set (t_light *light, t_parse_txt *scene_file)
 
void cone_set (t_obj *obj, void *cone, t_parse_txt *scene_file)
 
void cylinder_set (t_obj *obj, void *cylinder, t_parse_txt *scene_fi)
 
void plane_set (t_obj *obj, void *plane, t_parse_txt *scene_file)
 
void sphere_set (t_obj *obj, void *sphere, t_parse_txt *scene_file)
 
void csg_set (t_obj *obj, void *root, t_parse_txt *scene_file)
 
void cube_set (t_obj *obj, void *root, t_parse_txt *scene_file)
 
void tore_set (t_obj *obj, void *root, t_parse_txt *scene_file)
 
int csg_is_op (t_parse_txt *scene_file)
 

Macro Definition Documentation

◆ CSV_MATERIAL_COLUMN_COUNT

#define CSV_MATERIAL_COLUMN_COUNT   17

◆ ERR_FILE

#define ERR_FILE   "Err : File is too small to be valid"

◆ ERR_GREED_NULL

#define ERR_GREED_NULL   "Err : greed is NULL"

◆ ERR_OP_EQUAL_OBJ

#define ERR_OP_EQUAL_OBJ   "Err : [Csg] sizeof(t_obj) == sizeof(t_csg_op)"

◆ ERR_P_BRACKET_CLSE

#define ERR_P_BRACKET_CLSE   "Err : Missing closing bracket"

◆ ERR_P_BRACKET_OPEN

#define ERR_P_BRACKET_OPEN   "Err : Missing opening bracket"

◆ ERR_P_CAMERA

#define ERR_P_CAMERA   "Err : camera is missing"

◆ ERR_P_CLOSE_PAR

#define ERR_P_CLOSE_PAR   "Err : Missing parenthese"

◆ ERR_P_CONTENT

#define ERR_P_CONTENT   "Err : content is missing"

◆ ERR_P_KEY

#define ERR_P_KEY   "Err : Missing key"

◆ ERR_PARSE_COLOR

#define ERR_PARSE_COLOR   "Err : [Color] Wrong number of args"

◆ ERR_PARSE_FLOAT

#define ERR_PARSE_FLOAT   "Err : [Float] Wrong number of args"

◆ ERR_PARSE_OUTR

#define ERR_PARSE_OUTR   "Err : line_idx out of range"

◆ ERR_PARSE_SET_CO

#define ERR_PARSE_SET_CO   "Err : *cone is null"

◆ ERR_PARSE_SET_CSG

#define ERR_PARSE_SET_CSG   "Err : *csg is null"

◆ ERR_PARSE_SET_CY

#define ERR_PARSE_SET_CY   "Err : *cylinder is null"

◆ ERR_PARSE_SET_LI

#define ERR_PARSE_SET_LI   "Err : *light is null"

◆ ERR_PARSE_SET_PL

#define ERR_PARSE_SET_PL   "Err : *plan is null"

◆ ERR_PARSE_SET_SP

#define ERR_PARSE_SET_SP   "Err : *sphere is null"

◆ ERR_PARSE_STRN

#define ERR_PARSE_STRN   "Err : line is NULL"

◆ ERR_PARSE_VEC2

#define ERR_PARSE_VEC2   "Err : [Vec2] Wrong number of args"

◆ ERR_PARSE_VEC3

#define ERR_PARSE_VEC3   "Err : [Vec3] Wrong number of args"

◆ ERR_UNKNWD_MAT

#define ERR_UNKNWD_MAT   "Err : Unknown material"

◆ ERR_UNKNWD_MOTION

#define ERR_UNKNWD_MOTION   "Err : Unknown motion in animation list"

◆ ERR_UNKNWD_OBJ

#define ERR_UNKNWD_OBJ   "Err : Unknown object"

◆ ERR_UNKNWD_OBJ_A

#define ERR_UNKNWD_OBJ_A   "Err : Unknown object in animation list"

Typedef Documentation

◆ t_built

typedef struct s_built t_built

◆ t_objset

typedef struct s_objset t_objset

◆ t_parse

typedef struct s_parse t_parse

◆ t_parse_txt

typedef struct s_parse_txt t_parse_txt

Function Documentation

◆ check_closing_bracket()

void check_closing_bracket ( t_parse_txt scene_file)

Verify that the curr_line is a closing bracket.

Parameters
scene_file

◆ check_opening_bracket()

void check_opening_bracket ( t_parse_txt scene_file)

Verify that the curr_line is a opening bracket.

Parameters
scene_file

◆ cone_new()

void cone_new ( t_obj obj,
void *  res 
)

◆ cone_set()

void cone_set ( t_obj obj,
void *  cone,
t_parse_txt scene_file 
)

◆ create_obj_from_txt()

void create_obj_from_txt ( t_obj obj_dst,
t_parse_txt scene_file,
int  type 
)

General parser for all of the shapes.

Parameters
obj_dst: Dst of the data
scene_file: Parsing struct
type: Type of the shape to parse

◆ csg_is_op()

int csg_is_op ( t_parse_txt scene_file)

◆ csg_set()

void csg_set ( t_obj obj,
void *  root,
t_parse_txt scene_file 
)

◆ cube_new()

void cube_new ( t_obj obj,
void *  res 
)

◆ cube_set()

void cube_set ( t_obj obj,
void *  root,
t_parse_txt scene_file 
)

◆ cylinder_new()

void cylinder_new ( t_obj obj,
void *  res 
)

◆ cylinder_set()

void cylinder_set ( t_obj obj,
void *  cylinder,
t_parse_txt scene_fi 
)

◆ err_exit()

void err_exit ( char *  err_msg,
t_parse_txt scene_file 
)

Print the exit message and exit after cleaning the data allocated.

Parameters
err_msg: message to explain the error.
scene_file: data in txt to parse

◆ err_set()

void err_set ( t_parse_txt scene_file,
const char  err_func[],
int  line_in_code,
const char  err_file[] 
)

Save data that produce the exit.

Parameters
scene_file: data in txt to parse
err_func: function where the error occure
line_in_code: line where the error occure
err_file: file where the error occure

◆ get_args_after_key()

char* get_args_after_key ( t_parse_txt scene_file,
const char *  key 
)

◆ get_args_key_require()

char* get_args_key_require ( t_parse_txt scene_file,
const char *  key 
)

Verify curr_line is containing the proper value and key.

Parameters
scene_file
key: key to find
Returns
char* : A pointer to the beginning of the value for the parameter

◆ get_curr_line()

char* get_curr_line ( t_parse_txt scene_file)

Check if the line_idx is in range and return the curr_line.

Parameters
scene_file: data in txt to parse
Returns
char* : curr_line

◆ get_obj_type()

int get_obj_type ( char *  obj_type)

◆ init_parse_cfg()

void init_parse_cfg ( int  type,
t_parse config 
)

Setting config for the type of object we want to parse.

Parameters
type: type of the object requested
config: Dst of the data

◆ light_cmp_key()

int light_cmp_key ( void *  content,
void *  key 
)

◆ light_set()

void light_set ( t_light light,
t_parse_txt scene_file 
)

◆ load_nbind_texture()

void load_nbind_texture ( t_texture tex,
uint32_t *  bind 
)

◆ load_parse_txt()

int load_parse_txt ( t_parse_txt scene_file,
t_data app,
char *  filename 
)

: Load a file into the t_parse_txt & bind the hooks and t_data app

Parameters
scene_file: data in txt to parse
app: link to the data
filename: file to load
Returns
int : status of the function

◆ load_texture()

void load_texture ( t_texture tex)

◆ matcmp()

int matcmp ( void *  content,
void *  key 
)

◆ name_obj()

char* name_obj ( int  type,
int *  nb 
)

◆ obj_cmp_key()

int obj_cmp_key ( void *  content,
void *  key 
)

◆ obj_set()

void obj_set ( t_obj obj,
int  type 
)

Setting the obj struct.

Parameters
obj: Dst of the data
type: type of the object requested

◆ open_textures()

void open_textures ( t_data app)

◆ parse_anim()

void parse_anim ( t_parse_txt scene_file)

◆ parse_color()

t_color parse_color ( char *  key,
t_parse_txt scene_file 
)

◆ parse_fval()

float parse_fval ( char *  key,
t_parse_txt scene_file 
)

◆ parse_int()

int parse_int ( char *  key,
t_parse_txt scene_file 
)

◆ parse_light()

void parse_light ( t_parse_txt scene_file)

Built a light obj and add it to the scene.lst_light.

Parameters
scene_file: Parsing struct

◆ parse_motion()

void parse_motion ( t_parse_txt scene_file,
t_anim anim 
)

◆ parse_shape()

void parse_shape ( t_parse_txt scene_file,
int  type 
)

Built a shape obj and add it to the scene.lst_obj.

Parameters
scene_file: Parsing struct
type: Type of the shape to parse

◆ parse_str()

char* parse_str ( t_parse_txt scene_file,
char *  key 
)

◆ parse_texture()

t_texture* parse_texture ( char *  key_name,
t_parse_txt scene_file 
)

◆ parse_vec2()

t_vec2 parse_vec2 ( char *  key,
t_parse_txt scene_file 
)

◆ parse_vector()

t_vec3 parse_vector ( char *  key,
t_parse_txt scene_file 
)

◆ plane_new()

void plane_new ( t_obj obj,
void *  res 
)

◆ plane_set()

void plane_set ( t_obj obj,
void *  plane,
t_parse_txt scene_file 
)

◆ pop_line()

char* pop_line ( t_parse_txt scene_file)

Return the curr_line and move line_idx to the next line.

Parameters
scene_file: data in txt to parse
Returns
char* : curr_line before the increment of line_idx

◆ sphere_new()

void sphere_new ( t_obj obj,
void *  res 
)

◆ sphere_set()

void sphere_set ( t_obj obj,
void *  sphere,
t_parse_txt scene_file 
)

◆ texcmp()

int texcmp ( void *  content,
void *  key 
)

◆ tore_set()

void tore_set ( t_obj obj,
void *  root,
t_parse_txt scene_file 
)