libwreport  2.9
Public Member Functions | Static Public Member Functions | Protected Attributes
wreport::Vartable Class Reference

Holds a variable information table. More...

#include <vartable.h>

Inheritance diagram for wreport::Vartable:

Public Member Functions

const std::string & id () const
 Return the Vartable ID.
 
bool loaded () const
 Return true if the Vartable has been loaded.
 
void load (const std::pair< std::string, std::string > &idfile)
 Load contents from the table with the given ID.
 
Varinfo query (Varcode code) const
 Query the Vartable. More...
 
bool contains (Varcode code) const
 Check if the code can be resolved to a varinfo.
 
Varinfo query_altered (Varcode var, int scale, unsigned bit_len) const
 Query an altered version of the vartable. More...
 

Static Public Member Functions

static const Vartableget (const char *id)
 Return a Vartable by id, loading it if necessary. More...
 
static const Vartableget (const std::pair< std::string, std::string > &idfile)
 Return a Vartable by id and pathname. More...
 
static std::pair< std::string,
std::string > 
find_table (const std::vector< std::string > &ids)
 Look for a table for one of the given table IDs. More...
 
static std::pair< std::string,
std::string > 
find_table (const std::string &id)
 Look for the table file given a table ID. More...
 

Protected Attributes

std::string m_id
 ID of the table.
 

Detailed Description

Holds a variable information table.

It never needs to be deallocated, as all the Vartable returned by DB-ALLe are pointers to memory-cached versions that are guaranteed to exist for all the lifetime of the program.

Member Function Documentation

static std::pair<std::string, std::string> wreport::Vartable::find_table ( const std::vector< std::string > &  ids)
static

Look for a table for one of the given table IDs.

The IDs are tried in order on the various configured paths and on those configured in the environment

Returns
A pair (the ID selected for the table, the pathname to the table)
static std::pair<std::string, std::string> wreport::Vartable::find_table ( const std::string &  id)
static

Look for the table file given a table ID.

Returns
A pair (id, pathname to the table)
static const Vartable* wreport::Vartable::get ( const char *  id)
static

Return a Vartable by id, loading it if necessary.

Once loaded, the table will be cached in memory for reuse, and further calls to get() will return the cached version.

The cached tables are never deallocated, so the returned pointer is valid through the whole lifetime of the program.

Parameters
idID of the Vartable data to access
static const Vartable* wreport::Vartable::get ( const std::pair< std::string, std::string > &  idfile)
static

Return a Vartable by id and pathname.

Parameters
idfilea pair (id, pathname) identifying the table to load
Varinfo wreport::Vartable::query ( Varcode  code) const

Query the Vartable.

Throws an exception if not found.

Parameters
codewreport::Varcode to query
Returns
the wreport::varinfo with the results of the query.
Varinfo wreport::Vartable::query_altered ( Varcode  var,
int  scale,
unsigned  bit_len 
) const

Query an altered version of the vartable.

Parameters
varwreport::Varcode to query
scaleScale to use instead of the default
bit_lenBit length to use instead of the default
Returns
the wreport::Varinfo structure with the results of the query. The returned Varinfo is stored inside the dba_vartable, can be freely copied around and does not need to be deallocated.

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