ifw-core 7.0.0
 
Loading...
Searching...
No Matches
ifw::core::dit::did::Did Class Reference

Data Interface Dictionary class. More...

#include <did.hpp>

Public Member Functions

 Did ()
 
 ~Did ()
 
void Load (const std::string &did_filename, const bool clear=false)
 Load the referenced dictionary.
 
void Clear ()
 Clear the object.
 
const std::vector< std::string > & GetDidsLoaded () const
 Get the filenames of the DIDs, currently loaded (el [0] = first DID loaded).
 
const std::vector< std::string > & GetDidsLoadedCompletePath () const
 Get the complete filenames of the DIDs, currently loaded (el [0] = first DID loaded).
 
const std::vector< ifw::core::dit::did::Header > & GetHeaders () const
 Get the header objects for the DIDs loaded (el [0] = first DID loaded).
 
bool HasRecord (const std::string &pattern, const bool allow_idx_subst=true) const
 Check if a record, is contained in the object.
 
bool LookUp (const std::string &pattern, ifw::core::dit::did::Record &record, const bool allow_idx_subst=true, const bool exception=true) const
 Look up a key in the DIDs loaded. First occurrence taken.
 
bool LookUp (const std::string &pattern, std::vector< ifw::core::dit::did::Record > &records, const bool allow_idx_subst=true, const bool exception=false) const
 LookUp Scan the dictionary for keys with the given regular expression pattern.
 
void GetKeys (std::vector< std::string > &keys) const
 Generate list of keys defined.
 
std::string ToString (HdrSpec header=HdrSpec::LAST, const std::string &pattern="", const bool compact=false) const
 Create a DID from the content in the object in a string buffer.
 

Static Public Member Functions

static std::string SubstituteIndeces (const std::string &key)
 Substitutes numeric indeces of keyword components to the generic representation.
 
static std::string SubstituteIndex (const std::string &key)
 Substitutes a numeric index of a keyword to obtain the generic representation.
 

Friends

std::ostream & operator<< (std::ostream &os, const Did &did)
 Dump the contents of the class on the output stream.
 

Detailed Description

Data Interface Dictionary class.

Constructor & Destructor Documentation

◆ Did()

ifw::core::dit::did::Did::Did ( )

◆ ~Did()

ifw::core::dit::did::Did::~Did ( )

Member Function Documentation

◆ Clear()

void ifw::core::dit::did::Did::Clear ( )

Clear the object.

◆ GetDidsLoaded()

const std::vector< std::string > & ifw::core::dit::did::Did::GetDidsLoaded ( ) const

Get the filenames of the DIDs, currently loaded (el [0] = first DID loaded).

◆ GetDidsLoadedCompletePath()

const std::vector< std::string > & ifw::core::dit::did::Did::GetDidsLoadedCompletePath ( ) const

Get the complete filenames of the DIDs, currently loaded (el [0] = first DID loaded).

◆ GetHeaders()

const std::vector< Header > & ifw::core::dit::did::Did::GetHeaders ( ) const

Get the header objects for the DIDs loaded (el [0] = first DID loaded).

◆ GetKeys()

void ifw::core::dit::did::Did::GetKeys ( std::vector< std::string > & keys) const

Generate list of keys defined.

◆ HasRecord()

bool ifw::core::dit::did::Did::HasRecord ( const std::string & pattern,
const bool allow_idx_subst = true ) const

Check if a record, is contained in the object.

◆ Load()

void ifw::core::dit::did::Did::Load ( const std::string & did_filename,
const bool clear = false )

Load the referenced dictionary.

Parameters
did_filenameName of the file of the dictionary.
clearClear the object before loading. If false, new DIDs are merged.

The filename of the DID shall be given as the relative path, according to the module in which it is residing, e.g.: "<project>/<package>/<module>/MyDid.did.yaml". This is the name in the root directory, where the DID is located.

DIDs are searched for in the paths defined in the CFGPATH variable.

◆ LookUp() [1/2]

bool ifw::core::dit::did::Did::LookUp ( const std::string & pattern,
ifw::core::dit::did::Record & record,
const bool allow_idx_subst = true,
const bool exception = true ) const

Look up a key in the DIDs loaded. First occurrence taken.

Parameters
patternName of key. May be a regular expression.
recordRecord object, in which the information about the key will be stored.
allow_idx_substIf true, indeces may be substituted with #'s.
exceptionIf true, an exception is thrown if no key matching was found.
Returns
True if a record matched.

◆ LookUp() [2/2]

bool ifw::core::dit::did::Did::LookUp ( const std::string & pattern,
std::vector< ifw::core::dit::did::Record > & records,
const bool allow_idx_subst = true,
const bool exception = false ) const

LookUp Scan the dictionary for keys with the given regular expression pattern.

Parameters
patternName of key. May be a regular expression.
recordsList with record objects of keys matching.
allow_idx_substIf true, indeces may be substituted with #'s.
exceptionIf true, an exception is thrown if no key matching was found.
Returns
True if at least one key matched the reg ex.

◆ SubstituteIndeces()

std::string ifw::core::dit::did::Did::SubstituteIndeces ( const std::string & key)
static

Substitutes numeric indeces of keyword components to the generic representation.

Parameters
keyKey to be processed.

The method checks a keyword of the form "<str>[<nb>][.<str>[<nb>]" or "<str>[<nb>][ <str>[<nb>]" (latter space vs dot separated keyword components) to obtain the generic 'DID representation' for indeces: "<str>[#][.<str>[#]".

Returns
Processed key or the input key, if no processing was done.

◆ SubstituteIndex()

std::string ifw::core::dit::did::Did::SubstituteIndex ( const std::string & key)
static

Substitutes a numeric index of a keyword to obtain the generic representation.

Parameters
keyKey to be processed.

The method checks a keyword of the form "<str>[<nb>] to obtain the generic 'DID representation' for indeces: "<str>[#]".

Returns
Processed key or the input key, if no processing was done.

◆ ToString()

std::string ifw::core::dit::did::Did::ToString ( HdrSpec header = HdrSpec::LAST,
const std::string & pattern = "",
const bool compact = false ) const

Create a DID from the content in the object in a string buffer.

Parameters
headerIndicates which header(s) to print.
patternIf specified, print only the keys matching (may be regular expression).
Returns
Buffer with the generated DID.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const Did & did )
friend

Dump the contents of the class on the output stream.


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