libbbb  1.2.1
Groups common code used in some applications and libraries.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
bbb::VarMap Class Reference

Class capable of storing a list of variables and associated values. More...

#include <varmap.h>

Public Types

enum  UniteType { FavorMine, FavorOther, AppendOther }
 ways two maps may be united
 
typedef QMap< QString, VarData * > vmap
 actual map type
 
typedef QMap< QString, VarData * >
::iterator 
iterator
 may be used to iterate the variables
 

Public Member Functions

 VarMap (void)
 constructor;
 
virtual ~VarMap (void)
 destructor;
 
void add (VarData *vd)
 add a variable;
 
int count (void) const
 get the number of variables
 
int count (const QString &s_name) const
 get the number of values in the array
 
void clear (void)
 clear all variables
 
void clear (const QString &s_name)
 clears the array
 
bool delVar (const QString &s_name)
 delete a variable; returns false if it was not found
 
QStringList names (void) const
 get a list with all variable names
 
iterator begin (void)
 get an iterator
 
iterator end (void)
 iterator to indicate last invalid position
 
void unite (const VarMap &other, UniteType ut=FavorOther)
 unite two variable sets and keep the result in this one
 
void extendToFit (const QString &s_name, int i)
 makes sure that at least specified number of entries exist in array
 
Change

Methods that add/set content to variables

void setValue (const QString &s_name, const QStringList &sl)
 set/change the value
 
void setValue (const QString &s_name, QString s, int index=0)
 set/change the value
 
void setValue (const QString &s_name, qint64 i, int index=0)
 set/change the value
 
void setValue (const QString &s_name, bool b, int index=0)
 set/change the value
 
void setValue (const QString &s_name, double d, int index=0)
 set/change the value
 
void appendValue (const QString &s_name, QString s)
 append a value
 
void appendValue (const QString &s_name, qint64 i)
 append a value
 
void appendValue (const QString &s_name, bool b)
 append a value
 
void appendValue (const QString &s_name, double d)
 append a value
 
void append (const QString &s_name, const QStringList &sl)
 append a list of values
 
Querry the value

Methods that look at the content of the variable

bool contains (const QString &s_name) const
 tell if the given variable is part of the map
 
VarDatavalue (const QString &s_name) const
 get the value associated with a variable
 
VarDatasureValue (const QString &s_name)
 get the value associated with a variable or construct a new one if not found
 
QString valueS (const QString &s_name, int i=0) const
 get the value associated with a variable
 
QStringList valueSL (const QString &s_name) const
 get the value associated with a variable
 
Conversions

Convert the string storage into other types

bool isInteger (const QString &s_name, int i=0) const
 tell if the value may be converted to a 64-bit integer
 
bool isDouble (const QString &s_name, int i=0) const
 tell if the value may be converted to a double precision floating point
 
bool isBool (const QString &s_name, int i=0) const
 tell if the value may be converted to a boolean value
 
qint64 toInteger (const QString &s_name, bool *b_ok=NULL, int i=0) const
 convert the value at specified index to a 64-bit integer
 
double toDouble (const QString &s_name, bool *b_ok=NULL, int i=0) const
 convert the value at specified index to a double precision floating point
 
bool toBool (const QString &s_name, bool *b_ok=NULL, int i=0) const
 convert the value at specified index to a boolean value
 

Static Public Member Functions

static QStringList toNamespaceList (const QString &s)
 separate a string into namespaces and final part More...
 

Protected Attributes

vmap vars_
 the actual list of variables
 

Detailed Description

Class capable of storing a list of variables and associated values.

Variables are always stored as arrays and have no type associated with them. A variable's value may always be used as a string (it always has a string representation).

Member Function Documentation

QStringList VarMap::toNamespaceList ( const QString &  s)
static

separate a string into namespaces and final part

The method uses :: to split the string into components.

Parameters
sinput string
Returns
a list of namespaces and final part (variable/method/etc)

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