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

Class capable of storing the value of a variable. More...

#include <vardata.h>

+ Inheritance diagram for bbb::VarData:

Public Member Functions

 VarData (void)
 constructor; creates an unnamed variable
 
 VarData (const QString &s_name)
 constructor; creates a named variable
 
 VarData (const QString &s_name, const QString &s_val)
 constructor; creates a named variable with a value
 
 VarData (const QString &s_name, const QStringList &s_val)
 constructor; creates a named variable with a value
 
const QString & name (void) const
 get the name of the variable (may be empty)
 
const QStringList & valueSL (void) const
 get the value of the variable (may be empty)
 
int count (void) const
 get the number of values in the array
 
bool isInteger (int i=0) const
 tell if the value may be converted to a 64-bit integer
 
bool isDouble (int i=0) const
 tell if the value may be converted to a double precision floating point
 
bool isBool (int i=0) const
 tell if the value may be converted to a boolean value
 
QString value (int i=0) const
 get the value of the variable at specified index
 
qint64 toInteger (bool *b_ok=NULL, int i=0) const
 convert the value at specified index to a 64-bit integer
 
double toDouble (bool *b_ok=NULL, int i=0) const
 convert the value at specified index to a double precision floating point
 
bool toBool (bool *b_ok=NULL, int i=0) const
 convert the value at specified index to a boolean value
 
void setName (const QString &s)
 set/change the name
 
void setValue (const QStringList &sl)
 set/change the value
 
void set (const QString &s_name, const QStringList &sl_value)
 set/change the name and value
 
void setValue (QString s, int index=0)
 set/change the value
 
void setValue (qint64 i, int index=0)
 set/change the value
 
void setValue (bool b, int index=0)
 set/change the value
 
void setValue (double d, int index=0)
 set/change the value
 
void setAllNew (QString s)
 set/change the value; clears previous list
 
void setAllNew (qint64 i)
 set/change the value; clears previous list
 
void setAllNew (bool b)
 set/change the value; clears previous list
 
void setAllNew (double d)
 set/change the value; clears previous list
 
void appendValue (QString s)
 append a value
 
void appendValue (qint64 i)
 append a value
 
void appendValue (bool b)
 append a value
 
void appendValue (double d)
 append a value
 
void append (const QStringList &sl)
 append a list of values
 
void extendToFit (int i)
 makes sure that at least specified number of entries exist in array
 
void clear (void)
 clears the array
 
- Public Member Functions inherited from bbb::RefCnt
 RefCnt (void)
 constructor;
 
void incRef (void)
 increase reference counter
 
void decRef (void)
 decrease reference counter
 
unsigned int referenceCount (void)
 number of times this instance was referenced
 
void forceDelete (void)
 if the caller knows what is doing it should use this
 

Protected Attributes

QString s_name_
 the name of the variable; full name may include other parts
 
QStringList s_val_
 the value of the variable as a list of strings
 

Additional Inherited Members

- Protected Member Functions inherited from bbb::RefCnt
virtual ~RefCnt (void)
 destructor;
 

Detailed Description

Class capable of storing the value of a variable.

This class associates a name() with a list of values that may be obtained using value(). This is a list of strings whose components may be querried with the overload that takes the index as an argument.

All the methods that retrieve individual components work with any integer. If the index is out of bounds a default value is returned. Use count() to get the range that is actually stored. extendToFit() may be used to change that size quickly.

The contrnt of individual entries in the array may be tested, but these tests are just as fast as the methods that convert the content:

To change the value use one of the setValue() overloads or clear() the content.


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