ifw-odp  2.0.0-alpha
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Functions | Variables
Test Configuration File Parser

Macros

#define MAXLINELENGTH   2048
 

Functions

int clipm_testlib_parser_strcasecmp (const char *s1, const char *s2)
 
bool clipm_testlib_parser_is_escape_char (char c)
 
char clipm_testlib_parser_escape (char c)
 
bool clipm_testlib_parser_is_space_char (char c)
 
bool clipm_testlib_parser_is_char_in_str (char c, const char *str)
 
bool clipm_testlib_parser_neol (FILE *f, char c)
 
int clipm_testlib_parser_readline (FILE *f, char *str, int maxlength)
 
void clipm_testlib_parser_store_parameter (cpl_parameterlist *parlist, const char *name, const char *description, const char *context, const char *value)
 
cpl_propertylist * clipm_testlib_parser_extract_line_tokens (const char *line, const char *operators, const char *separators, const char commentchar)
 This is an internal function of clipm/test, which is only mentioned for documentation. It extracts string tokens from a line string. More...
 
cpl_parameterlist * clipm_testlib_parser_import_configfile (const char *filename, cpl_parameterlist *append_list)
 

Variables

const char ESCAPECHAR = '\\'
 
const char ESCAPES [2][5]
 

Detailed Description

This module provides functions to parse configuration files, to store the results in a cpl_parameterlist, and to write back a parameterlist to a file.

Synopsis:
#include "clipm_parser.h"

Macro Definition Documentation

#define MAXLINELENGTH   2048

Function Documentation

char clipm_testlib_parser_escape ( char  c)
cpl_propertylist * clipm_testlib_parser_extract_line_tokens ( const char *  line,
const char *  operators,
const char *  separators,
const char  commentchar 
)

This is an internal function of clipm/test, which is only mentioned for documentation. It extracts string tokens from a line string.

Parameters
lineLine string.
operatorsA string containing characters that will be interpreted as non-text and will thus create new tokens. Contiguous characters are stored as one operator token.
separatorsA string containing characters that will also be interpreted as non-text and will thus create new tokens. Every separator character is stored in a single token.
commentcharCharacter indicating that the rest of the line is a comment, which will not be parsed.
use_commentFuture-planned flag indicating whether a comment shall be used for the recorded parameter
groupingFuture-planned string containing character pairs which indicate the starts and ends of a character group
Returns
A list of properties containing the string tokens. Each property will contain the token as its value. The name of each property will be either "TXT" indicating text, "OPR" indicating an operator, or "SEP" indicating that it contains a separator

This function parses a line string for space-separated sub-strings, called tokens. Additional operator and separator characters can be specified, which will be stored in own tokens. There are three types of tokens, text, operator and separator tokens, indicated by their respective property names.

Double-quoted parts in the input line string are regarded as text as-is.

Escape sequences are recognized and after substitution regarded as text. The following special escape sequences are known so far:

  • \n newline character
  • \r return character
  • \t tabulator

All other characters can be escaped as-well, forcing them to be interpreted as text.
Operators, separators, comment characters, quotes and the escape character should all be different! If not, the priority of interpretation is:

  1. Escape character
  2. Quotes
  3. Comment character
  4. Separators
  5. Operators

An example of usage is given below:

const char *operators = "=";
const char *separators = ";";
linetokens = clipm_testlib_parser_extract_line_tokens(line, operators, separators, '#');
cpl_parameterlist* clipm_testlib_parser_import_configfile ( const char *  filename,
cpl_parameterlist *  append_list 
)
bool clipm_testlib_parser_is_char_in_str ( char  c,
const char *  str 
)
bool clipm_testlib_parser_is_escape_char ( char  c)
bool clipm_testlib_parser_is_space_char ( char  c)
bool clipm_testlib_parser_neol ( FILE *  f,
char  c 
)
int clipm_testlib_parser_readline ( FILE *  f,
char *  str,
int  maxlength 
)
void clipm_testlib_parser_store_parameter ( cpl_parameterlist *  parlist,
const char *  name,
const char *  description,
const char *  context,
const char *  value 
)
int clipm_testlib_parser_strcasecmp ( const char *  s1,
const char *  s2 
)

Variable Documentation

const char ESCAPECHAR = '\\'
const char ESCAPES[2][5]
Initial value:
= {
"0nrt",
"\0\n\r\t"
}