Mescal
Loading...
Searching...
No Matches
files.h File Reference

Management of savefiles. More...

#include "main.h"
#include "nfa.h"
#include "parser.h"
#include "regexp.h"
#include "shell_languages.h"
#include "shell_memb.h"
#include "type_basic.h"
#include <json-c/json.h>

Go to the source code of this file.

Macros

#define OUTPUT_DIR   "./outputs"
 
#define EXPSIZE   2048
 Maximal size of a regular expression that can be saved.
 

Functions

int files_save_exall (const char *filename, exall_profile *profile)
 Initializes the json description for example generation.
 
int files_read_exall (const char *filename, exall_profile *profile)
 
void reg_to_string (regexp *, char *)
 Converts a regular expression into a string.
 
json_object * files_regexp_to_json (regexp *)
 Converts a regular expression into a json object.
 
json_object * files_nfa_to_json (nfa *)
 Converts a NFA into a json object.
 
json_object * files_dfa_to_json (dfa *)
 Converts a DFA into a json object.
 
void * files_json_to_automaton (json_object *, bool *)
 Reads a json object encoding an automaton and extracts this automaton.
 
void files_save_object (object *, char *)
 Saves a shell object into a file.
 
int files_read_object (char *, char *)
 Reads a shell object from a file and assigns it to a variable name.
 
void files_save_session (char *)
 Saves a complete session in a file.
 
void files_load_session (char *)
 Loads a complete session from a file.
 

Detailed Description

Management of savefiles.

Contains all the functions that can be used to save objects in files and then load these files in the software.

Remarks
Savefiles are formatted in JSON. All functions depend on the json-c library.

Function Documentation

◆ files_dfa_to_json()

json_object * files_dfa_to_json ( dfa * A)

Converts a DFA into a json object.

Returns
The json object
Parameters
AThe automaton.

◆ files_json_to_automaton()

void * files_json_to_automaton ( json_object * root,
bool * is_dfa )

Reads a json object encoding an automaton and extracts this automaton.

Returns
The automaton (or NULL is the json object does not encode an automaton).

Reads a json object encoding an automaton and extracts this automaton.

Remarks
The return point is eiether a DFA or a NFA, depending on the json object. A boolean is set to true if the automaton is a DFA, false if it is a NFA.
Returns
The automaton (or NULL is the json object does not encode an automaton).
Parameters
rootThe json object.
is_dfaSet to true if the automaton is a DFA, false if it is a NFA.

◆ files_load_session()

void files_load_session ( char * filename)

Loads a complete session from a file.

Parameters
filenameThe path to the file that needs to be read.

◆ files_nfa_to_json()

json_object * files_nfa_to_json ( nfa * A)

Converts a NFA into a json object.

Returns
The json object
Parameters
AThe automaton.

◆ files_read_exall()

int files_read_exall ( const char * filename,
exall_profile * profile )
Parameters
filenameThe path to the file that needs to be read.
profileThe profile to fill with the data read from the file.

◆ files_read_object()

int files_read_object ( char * filename,
char * varname )

Reads a shell object from a file and assigns it to a variable name.

Returns
The index of the object in the table.
Parameters
filenameThe path to the file that needs to be read.
varnameThe variable name.

◆ files_regexp_to_json()

json_object * files_regexp_to_json ( regexp * exp)

Converts a regular expression into a json object.

Returns
The json object
Parameters
expThe regular expression.

◆ files_save_exall()

int files_save_exall ( const char * filename,
exall_profile * profile )

Initializes the json description for example generation.

Returns
The json object.
Parameters
filenameThe path to the file where the data has to be saved.
profileThe profile to save in the file.

◆ files_save_object()

void files_save_object ( object * theobj,
char * filename )

Saves a shell object into a file.

Parameters
theobjThe object that needs to be saved.
filenameThe path to the file in which the save has to be made.

◆ files_save_session()

void files_save_session ( char * filename)

Saves a complete session in a file.

Parameters
filenameThe path to the file in which the save has to be made.

◆ reg_to_string()

void reg_to_string ( regexp * r,
char * buffer )

Converts a regular expression into a string.

Remarks
The string is returned by writing into the second parameter which has to be large enough.
Parameters
rThe regular expression.
bufferThe buffer used to return the string (it needs to be large enough).