Character Tree  1.0.0
A PDF tree builder from CSV
Classes | Macros | Typedefs | Functions
treestruct.h File Reference

Tree creator from a formatted CSV file. It write its results in a TeX file which is a Beamer document. More...

Go to the source code of this file.

Classes

struct  person
 A structure representing an indivual as a tree node. More...
 

Macros

#define MAXDEPTH   5
 A macro representing the maximum depth of the TEX tree.
 
#define MAXLEN   255
 A macro representing the maximum length of a string.
 
#define CSVSEP   ";"
 A macro representing the CSV separator (by default a semi-colon).
 
#define CSVEOL   ";\n"
 A macro representing the CSV end of line (by default a semi-colon and a carriage return).
 
#define LOGS   "logs/treeBuilder.log"
 A macro representing the path to the log file.
 
#define SRC   "data.csv"
 A macro representing the path to the CSV data file.
 
#define TEX   "tree.tex"
 A macro representing the path to the build TEX file.
 

Typedefs

typedef struct person Person
 The type definition of an individual. More...
 
typedef struct personTree
 The type definition of the binary tree. More...
 

Functions

Tree createNode (int id, char name[], int value)
 Create a new indivudal (node). More...
 
int buildTree (Tree *t, int id, char name[], int value, FILE *logs)
 
void getFields (char line[], char *tokens[])
 Read a CSV file row. More...
 
int toInt (char *str)
 Convert a string to an integer. More...
 
int readCSV (FILE *file, Tree *t, FILE *logs)
 
void displayPerson (Tree t)
 Display a tree in the standard output. More...
 
void rowMissingChildren (FILE *file, int children)
 Add missing children to the tree in the TEX file. More...
 
void missingChildren (int id, FILE *file, int rootId)
 Compute the number of missing children for the given node according to the root id. More...
 
void color (int value, char strColor[])
 Set the node color according to its value. More...
 
void writeLatexPerson (FILE *file, Tree t, int depth, int rootId)
 Write an individual as a node in the TEX file. More...
 
void writeLatexFile (FILE *file, Tree t, int rootId)
 Write a TEX file from a binary tree. More...
 
void writeLogs (FILE *logs, char message[])
 Add a line to the log file. More...
 
void formateInteger (int val, char ch[], char addOn[])
 Formate an integer to a specific string for the logs. More...
 

Detailed Description

Tree creator from a formatted CSV file. It write its results in a TeX file which is a Beamer document.

Author
Bruno Verchère
Version
1.0.0
Date
2021
Example of a PDF output

Typedef Documentation

◆ Person

The type definition of an individual.

See also
person

◆ Tree

The type definition of the binary tree.

See also
person

Function Documentation

◆ color()

void color ( int  value,
char  strColor[] 
)

Set the node color according to its value.

Parameters
valueThe current node value.
strColorThe node color as a string.

◆ createNode()

Tree createNode ( int  id,
char  name[],
int  value 
)

Create a new indivudal (node).

Parameters
idThe node identifier.
nameA string representing the individual name.
valueThe node value (representing the genetic character).
Returns
A new node.

◆ displayPerson()

void displayPerson ( Tree  t)

Display a tree in the standard output.

Parameters
tThe tree to display

◆ formateInteger()

void formateInteger ( int  val,
char  ch[],
char  addOn[] 
)

Formate an integer to a specific string for the logs.

Parameters
valThe integer to format.
chThe logs string.
addOnThe string to place before the integer.

◆ getFields()

void getFields ( char  line[],
char *  tokens[] 
)

Read a CSV file row.

Parameters
lineThe line to parse.
tokensThe parsed values of this line.

◆ missingChildren()

void missingChildren ( int  id,
FILE *  file,
int  rootId 
)

Compute the number of missing children for the given node according to the root id.

Parameters
idThe current identifider.
fileThe TEX file to write.
rootIdThe tree root identifier.

◆ rowMissingChildren()

void rowMissingChildren ( FILE *  file,
int  children 
)

Add missing children to the tree in the TEX file.

Parameters
fileThe TEX file to write.
childrenThe number of missing children to add.

◆ toInt()

int toInt ( char *  str)

Convert a string to an integer.

Parameters
strThe string to convert.
Returns
The converted string as an integer.

◆ writeLatexFile()

void writeLatexFile ( FILE *  file,
Tree  t,
int  rootId 
)

Write a TEX file from a binary tree.

Parameters
fileThe TEX file to write.
tThe binary tree.
rootIdThe tree root identifier.

◆ writeLatexPerson()

void writeLatexPerson ( FILE *  file,
Tree  t,
int  depth,
int  rootId 
)

Write an individual as a node in the TEX file.

Parameters
fileThe TEX file.
tThe binary tree.
depthThe current node depth.
rootIdThe tree root identifier.

◆ writeLogs()

void writeLogs ( FILE *  logs,
char  message[] 
)

Add a line to the log file.

Parameters
logsThe log file.
messageThe message to add to the logs.
© 2021 Bruno Verchère