Public Member Functions | Public Attributes | Protected Attributes | List of all members
MapReader< K, V > Class Template Reference

General utility for reading text entries of type KEY=VALUE into a map.
More...

#include <MapReader.h>

Collaboration diagram for MapReader< K, V >:
Collaboration graph
[legend]

Public Member Functions

 MapReader (std::map< K, V > &target)
 
void setMap (std::map< K, V > &target)
 
void setKeySyntax (const std::string &regExp)
 Defines the std::strings recognized (accepted) as keys. By default: [a-zA-Z][a-zA-Z0-9_\.]* TODO: make short/long spex strictness: -a –accept.
 
void trim (std::string &s)
 
void read (const std::string &filename)
 
void read (std::istream &istr=std::cin)
 
void readConfigEntry (const std::string &line)
 
void readCommandLineEntry (const std::string &s)
 
void readPendingCommandLineArgument (const std::string &s)
 
void readEntry (const std::string &line, drain::RegExp &regExp)
 
void read (int argc, char **argv)
 
const std::string & getKey ()
 
const std::string & getValue ()
 
bool hasArgument ()
 

Public Attributes

std::string trimChars
 Leading and trailing characters to be pruned.
 
bool limited
 

Protected Attributes

std::map< K, V > * m
 
std::map< K, V > defaultMap
 
drain::RegExp configLineParser
 
drain::RegExp commandLineParser
 
std::string key
 
std::string value
 
bool argumentRegistered
 

Detailed Description

template<class K, class V>
class drain::MapReader< K, V >

General utility for reading text entries of type KEY=VALUE into a map.

TODO: separate from maps, allow user to assign map[key]=value because key maybe an alias of another (longer) key.

Member Function Documentation

◆ read() [1/3]

void read ( const std::string &  filename)
inline

! Read from file, typically a config file.

◆ read() [2/3]

void read ( int  argc,
char **  argv 
)
inline

! Reads command line arguments TODO: if exists (declared) then...
TODO: one at the time, calling read(int argc, char **argv, int i){

◆ read() [3/3]

void read ( std::istream &  istr = std::cin)
inline

! Read from a stream.

◆ readCommandLineEntry()

void readCommandLineEntry ( const std::string &  s)
inline

! Read a single commandLine entry, ie. a –KEY=VALUE pair. TODO: –out-file=koe, –out-file koe, -o koe

◆ readConfigEntry()

void readConfigEntry ( const std::string &  line)
inline

! Read a single line, ie. a KEY=VALUE pair.

◆ readEntry()

void readEntry ( const std::string &  line,
drain::RegExp regExp 
)
inline

! Read a single line, ie. a KEY=VALUE pair.


The documentation for this class was generated from the following file: