Flow123d  release_2.2.0-914-gf1a3a4f
Macros | Functions | Variables
read_ini.cc File Reference

OPTIONS RUTINES - get program parameters, reading from options/ini file. More...

#include <strings.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include "system/system.hh"
#include "system/xio.h"
#include "io/read_ini.h"
#include <boost/tokenizer.hpp>
#include "boost/lexical_cast.hpp"
#include <boost/algorithm/string.hpp>

Go to the source code of this file.

Macros

#define FOR_INI_ITEMS(i)   for((i)=read_ini->ini_item;(i)!=NULL;(i)=(i)->next)
 

Functions

static void make_ini_item_list (const char *fname)
 
static char * section_test (char *section)
 
static char * strip_spaces (char *string)
 
static struct Ini_itemnew_item (struct Ini_item *prev, char *section, char *key, char *value)
 
char * xstrtok (char *s, int position)
 STRTOK WITH ERROR HANDLING and whitespace delimiters. More...
 
char * xstrtok (char *s1, const char *delim, int position)
 STRTOK WITH ERROR HANDLING and user specified delimiters. More...
 
char * OptGetStr (const char *section, const char *key, const char *defval)
 Create new string from selected variable from ini file. More...
 
char * OptGetFileName (const char *section, const char *key, const char *defval)
 
long int OptGetInt (const char *section, const char *key, const char *defval)
 
double OptGetDbl (const char *section, const char *key, const char *defval)
 
bool OptGetBool (const char *section, const char *key, const char *defval)
 
void OptionsInit (const char *fname)
 Load options file. More...
 
void OptGetDblArray (const char *section, const char *key, const char *defval, std::vector< double > &array)
 
void OptGetIntArray (const char *section, const char *key, const char *defval, int ArrSize, int *Array)
 

Variables

static struct Read_iniread_ini = NULL
 

Detailed Description

OPTIONS RUTINES - get program parameters, reading from options/ini file.

 * Copyright (C) 2015 Technical University of Liberec. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

DESCRIPTION

 Functions OptGet* are implemented through OptGetStr - only one interface routine for
 various implementation the parameter default is always char *, which can be NULL in the case that
 explicit value is necessary and program should produce an error if corresponding
 parameter is not given.

 Current implementation is based on SimpleINI C++ library.

Definition in file read_ini.cc.

Macro Definition Documentation

#define FOR_INI_ITEMS (   i)    for((i)=read_ini->ini_item;(i)!=NULL;(i)=(i)->next)

Definition at line 43 of file read_ini.cc.

Function Documentation

void make_ini_item_list ( const char *  fname)
static

Definition at line 113 of file read_ini.cc.

Here is the caller graph for this function:

struct Ini_item * new_item ( struct Ini_item prev,
char *  section,
char *  key,
char *  value 
)
static

Definition at line 205 of file read_ini.cc.

Here is the caller graph for this function:

bool OptGetBool ( const char *  section,
const char *  key,
const char *  defval 
)

Definition at line 325 of file read_ini.cc.

Here is the caller graph for this function:

double OptGetDbl ( const char *  section,
const char *  key,
const char *  defval 
)

Definition at line 306 of file read_ini.cc.

Here is the caller graph for this function:

void OptGetDblArray ( const char *  section,
const char *  key,
const char *  defval,
std::vector< double > &  array 
)

Read value of particular key as list of doubles and store them into array. defval string is used if the key is not found.

Definition at line 378 of file read_ini.cc.

char* OptGetFileName ( const char *  section,
const char *  key,
const char *  defval 
)

Definition at line 278 of file read_ini.cc.

long int OptGetInt ( const char *  section,
const char *  key,
const char *  defval 
)

Definition at line 288 of file read_ini.cc.

Here is the caller graph for this function:

void OptGetIntArray ( const char *  section,
const char *  key,
const char *  defval,
int  ArrSize,
int *  Array 
)

Definition at line 405 of file read_ini.cc.

char* OptGetStr ( const char *  section,
const char *  key,
const char *  defval 
)

Create new string from selected variable from ini file.

Parameters
[in]sectionInifile section
[in]keyInifile key
[in]defvalDefault value, if key is not found in inifile
Returns
Ptr to new string with option value from Inifile or to default value

Definition at line 251 of file read_ini.cc.

Here is the caller graph for this function:

void OptionsInit ( const char *  fname)

Load options file.

Parameters
[in]fnameFile name

Definition at line 347 of file read_ini.cc.

char * section_test ( char *  section)
static

Definition at line 234 of file read_ini.cc.

Here is the caller graph for this function:

char * strip_spaces ( char *  string)
static

Definition at line 190 of file read_ini.cc.

Here is the caller graph for this function:

char* xstrtok ( char *  s,
int  position 
)

STRTOK WITH ERROR HANDLING and whitespace delimiters.

Parameters
[in]sstrtok string pointer
[in]positionrequested position of the token
Returns
strtok return

Definition at line 61 of file read_ini.cc.

Here is the caller graph for this function:

char* xstrtok ( char *  s1,
const char *  delim,
int  position 
)

STRTOK WITH ERROR HANDLING and user specified delimiters.

Parameters
[in]s1strtok string pointer
[in]delimdelimiters
[in]positionrequested position of the token
Returns
strtok return

Function behaves like original strtok

Definition at line 79 of file read_ini.cc.

Variable Documentation

struct Read_ini* read_ini = NULL
static

Definition at line 41 of file read_ini.cc.