/home/laradmin/lar/utils/mit_darpa_logs_player/src/config.cpp File Reference

configuration cpp where LCM communications are defined More...

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include <stdarg.h>
#include <ctype.h>
#include <features.h>
#include <bits/types.h>
#include <endian.h>
#include <assert.h>
Include dependency graph for config.cpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _Config
struct  _ConfigElement
struct  _Parser
struct  _ParserFile



#define DEFAULT_CONFIG_PATH   "../lr3.cfg"
#define err(args...)   fprintf(stderr, args)
#define PRINT_KEY_NOT_FOUND(key)   err("WARNING: Config: could not find key %s!\n", (key));
enum  ConfigDataType { ConfigDataString, ConfigDataInt, ConfigDataBool, ConfigDataDouble }
enum  ConfigToken {
  TokInvalid, TokIdentifier, TokOpenStruct, TokCloseStruct,
  TokOpenArray, TokCloseArray, TokArraySep, TokAssign,
  TokString, TokEndStatement, TokCast, TokEOF
}
enum  ConfigType { ConfigContainer, ConfigArray }
enum  ParserType { ParserTypeFile }
typedef struct _ConfigElement ConfigElement
typedef int(* GetChFunc )(Parser *)
typedef struct _Parser Parser
typedef struct _ParserFile ParserFile
static int add_child (Parser *p, ConfigElement *el, ConfigElement *child)
static int add_value (Parser *p, ConfigElement *el, const char *str)
static int cast_to_boolean (const char *key, const char *val, int *out)
static double cast_to_double (const char *key, const char *val, double *out)
static int cast_to_int (const char *key, const char *val, int *out)
Configconfig_alloc (void)
void config_free (Config *conf)
int config_get_array_len (Config *conf, const char *key)
int config_get_boolean (Config *conf, const char *key, int *val)
int config_get_boolean_array (Config *conf, const char *key, int *vals, int len)
int config_get_boolean_or_default (Config *conf, const char *key, int def)
int config_get_default_src (char *buf, int buflen)
int config_get_double (Config *conf, const char *key, double *val)
int config_get_double_array (Config *conf, const char *key, double *vals, int len)
double config_get_double_or_default (Config *conf, const char *key, double def)
double config_get_double_or_fail (Config *conf, const char *key)
int config_get_int (Config *conf, const char *key, int *val)
int config_get_int_array (Config *conf, const char *key, int *vals, int len)
int config_get_int_or_default (Config *conf, const char *key, int def)
int config_get_num_subkeys (Config *conf, const char *containerKey)
int config_get_str (Config *conf, const char *key, char **val)
int config_get_str_array (Config *conf, const char *key, char **vals, int len)
char ** config_get_str_array_alloc (Config *conf, const char *key)
char * config_get_str_or_default (Config *conf, const char *key, char *def)
char * config_get_str_or_fail (Config *conf, const char *key)
char ** config_get_subkeys (Config *conf, const char *containerKey)
int config_has_key (Config *conf, const char *key)
Configconfig_parse_default (void)
Configconfig_parse_file (FILE *f, char *filename)
int config_print (Config *conf)
int config_set_boolean (Config *conf, const char *key, int val)
int config_set_boolean_array (Config *conf, const char *key, int *vals, int len)
int config_set_double (Config *conf, const char *key, double val)
int config_set_double_array (Config *conf, const char *key, double *vals, int len)
int config_set_int (Config *conf, const char *key, int val)
int config_set_int_array (Config *conf, const char *key, int *vals, int len)
int config_set_str (Config *conf, const char *key, char *val)
int config_set_str_array (Config *conf, const char *key, char **vals, int len)
void config_str_array_free (char **data)
static ConfigElementcreate_key (ConfigElement *el, const char *key)
static ConfigElementfind_key (ConfigElement *el, const char *key, int inherit)
static void free_element (ConfigElement *el)
static int get_ch_file (Parser *p)
static int get_token (Parser *p, ConfigToken *tok, char *str, int len)
static ConfigElementnew_element (const char *name)
static int parse_array (Parser *p, ConfigElement *el)
static int parse_container (Parser *p, ConfigElement *cont, ConfigToken end_token)
static int parse_right_side (Parser *p, ConfigElement *el)
static int print_array (ConfigElement *el, int indent)
static int print_container (ConfigElement *el, int indent)
static int print_msg (Parser *p, char *format,...)
static int set_value (Config *conf, const char *key, const char *val)
static int unget_ch (Parser *p, int ch)

Detailed Description

configuration cpp where LCM communications are defined

Definition in file config.cpp.


Define Documentation

#define DEFAULT_CONFIG_PATH   "../lr3.cfg"

Definition at line 42 of file config.cpp.

#define err ( args...   )     fprintf(stderr, args)

Definition at line 44 of file config.cpp.

#define PRINT_KEY_NOT_FOUND ( key   )     err("WARNING: Config: could not find key %s!\n", (key));

Definition at line 715 of file config.cpp.


Typedef Documentation

typedef struct _ConfigElement ConfigElement

Definition at line 48 of file config.cpp.

typedef int(* GetChFunc)(Parser *)

Definition at line 50 of file config.cpp.

typedef struct _Parser Parser

Definition at line 46 of file config.cpp.

typedef struct _ParserFile ParserFile

Definition at line 47 of file config.cpp.


Enumeration Type Documentation

Enumerator:
ConfigDataString 
ConfigDataInt 
ConfigDataBool 
ConfigDataDouble 

Definition at line 91 of file config.cpp.

Enumerator:
TokInvalid 
TokIdentifier 
TokOpenStruct 
TokCloseStruct 
TokOpenArray 
TokCloseArray 
TokArraySep 
TokAssign 
TokString 
TokEndStatement 
TokCast 
TokEOF 

Definition at line 71 of file config.cpp.

enum ConfigType
Enumerator:
ConfigContainer 
ConfigArray 

Definition at line 86 of file config.cpp.

enum ParserType
Enumerator:
ParserTypeFile 

Definition at line 52 of file config.cpp.


Function Documentation

static int add_child ( Parser p,
ConfigElement el,
ConfigElement child 
) [static]

Definition at line 359 of file config.cpp.

static int add_value ( Parser p,
ConfigElement el,
const char *  str 
) [static]

Definition at line 371 of file config.cpp.

static int cast_to_boolean ( const char *  key,
const char *  val,
int *  out 
) [static]

Definition at line 686 of file config.cpp.

static double cast_to_double ( const char *  key,
const char *  val,
double *  out 
) [static]

Definition at line 703 of file config.cpp.

static int cast_to_int ( const char *  key,
const char *  val,
int *  out 
) [static]

Definition at line 673 of file config.cpp.

Config* config_alloc ( void   ) 

Definition at line 1001 of file config.cpp.

void config_free ( Config conf  ) 

Definition at line 639 of file config.cpp.

int config_get_array_len ( Config conf,
const char *  key 
)

Returns: the number of elements in the specified array, or -1 if the key does not correspond to an array

Definition at line 963 of file config.cpp.

int config_get_boolean ( Config conf,
const char *  key,
int *  val 
)

Definition at line 780 of file config.cpp.

int config_get_boolean_array ( Config conf,
const char *  key,
int *  vals,
int  len 
)

Definition at line 897 of file config.cpp.

int config_get_boolean_or_default ( Config conf,
const char *  key,
int  def 
)

Definition at line 844 of file config.cpp.

int config_get_default_src ( char *  buf,
int  buflen 
)

Copies the filename of the default config file into buf. In the future, it might also indicate that LC is to be used for the config source

Returns: 0 on success, -1 if buf isn't big enough

Definition at line 629 of file config.cpp.

int config_get_double ( Config conf,
const char *  key,
double *  val 
)

Definition at line 790 of file config.cpp.

int config_get_double_array ( Config conf,
const char *  key,
double *  vals,
int  len 
)

Definition at line 920 of file config.cpp.

double config_get_double_or_default ( Config conf,
const char *  key,
double  def 
)

Definition at line 854 of file config.cpp.

double config_get_double_or_fail ( Config conf,
const char *  key 
)

Definition at line 799 of file config.cpp.

int config_get_int ( Config conf,
const char *  key,
int *  val 
)

Definition at line 770 of file config.cpp.

int config_get_int_array ( Config conf,
const char *  key,
int *  vals,
int  len 
)

Definition at line 874 of file config.cpp.

int config_get_int_or_default ( Config conf,
const char *  key,
int  def 
)

Definition at line 834 of file config.cpp.

int config_get_num_subkeys ( Config conf,
const char *  containerKey 
)

Definition at line 726 of file config.cpp.

int config_get_str ( Config conf,
const char *  key,
char **  val 
)

Definition at line 812 of file config.cpp.

int config_get_str_array ( Config conf,
const char *  key,
char **  vals,
int  len 
)

Definition at line 943 of file config.cpp.

char** config_get_str_array_alloc ( Config conf,
const char *  key 
)

Definition at line 973 of file config.cpp.

char* config_get_str_or_default ( Config conf,
const char *  key,
char *  def 
)

Definition at line 864 of file config.cpp.

char* config_get_str_or_fail ( Config conf,
const char *  key 
)

Definition at line 822 of file config.cpp.

char** config_get_subkeys ( Config conf,
const char *  containerKey 
)

Definition at line 744 of file config.cpp.

int config_has_key ( Config conf,
const char *  key 
)

Returns: 1 if the key is present, 0 if not

Definition at line 720 of file config.cpp.

Config* config_parse_default ( void   ) 

Definition at line 603 of file config.cpp.

Config* config_parse_file ( FILE *  f,
char *  filename 
)

Definition at line 576 of file config.cpp.

int config_print ( Config conf  ) 

Definition at line 556 of file config.cpp.

int config_set_boolean ( Config conf,
const char *  key,
int  val 
)

Definition at line 1086 of file config.cpp.

int config_set_boolean_array ( Config conf,
const char *  key,
int *  vals,
int  len 
)

Definition at line 1147 of file config.cpp.

int config_set_double ( Config conf,
const char *  key,
double  val 
)

Definition at line 1094 of file config.cpp.

int config_set_double_array ( Config conf,
const char *  key,
double *  vals,
int  len 
)

Definition at line 1179 of file config.cpp.

int config_set_int ( Config conf,
const char *  key,
int  val 
)

Definition at line 1076 of file config.cpp.

int config_set_int_array ( Config conf,
const char *  key,
int *  vals,
int  len 
)

Definition at line 1117 of file config.cpp.

int config_set_str ( Config conf,
const char *  key,
char *  val 
)

Definition at line 1104 of file config.cpp.

int config_set_str_array ( Config conf,
const char *  key,
char **  vals,
int  len 
)

Definition at line 1209 of file config.cpp.

void config_str_array_free ( char **  data  ) 

Definition at line 991 of file config.cpp.

static ConfigElement* create_key ( ConfigElement el,
const char *  key 
) [static]

Definition at line 1015 of file config.cpp.

static ConfigElement* find_key ( ConfigElement el,
const char *  key,
int  inherit 
) [static]

Definition at line 646 of file config.cpp.

static void free_element ( ConfigElement el  )  [static]

Definition at line 325 of file config.cpp.

static int get_ch_file ( Parser p  )  [static]

Definition at line 142 of file config.cpp.

static int get_token ( Parser p,
ConfigToken tok,
char *  str,
int  len 
) [static]

Definition at line 195 of file config.cpp.

static ConfigElement* new_element ( const char *  name  )  [static]

Definition at line 311 of file config.cpp.

static int parse_array ( Parser p,
ConfigElement el 
) [static]

Definition at line 385 of file config.cpp.

static int parse_container ( Parser p,
ConfigElement cont,
ConfigToken  end_token 
) [static]

Definition at line 478 of file config.cpp.

static int parse_right_side ( Parser p,
ConfigElement el 
) [static]

Definition at line 431 of file config.cpp.

static int print_array ( ConfigElement el,
int  indent 
) [static]

Definition at line 519 of file config.cpp.

static int print_container ( ConfigElement el,
int  indent 
) [static]

Definition at line 532 of file config.cpp.

static int print_msg ( Parser p,
char *  format,
  ... 
) [static]

Definition at line 116 of file config.cpp.

static int set_value ( Config conf,
const char *  key,
const char *  val 
) [static]

Definition at line 1055 of file config.cpp.

static int unget_ch ( Parser p,
int  ch 
) [static]

Definition at line 182 of file config.cpp.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines


mit_darpa_logs_player
Author(s): Miguel Oliveira
autogenerated on Wed Jul 23 04:34:16 2014