Back to index

lshw  02.16
Public Member Functions | Private Attributes
sqlite::value Class Reference

#include <db.h>

Collaboration diagram for sqlite::value:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 value ()
 value (const char *)
 value (const std::string &)
 value (long long)
 value (double)
 value (const value &)
 ~value ()
valueoperator= (const value &)
type getType () const
std::string asText () const
long long asInteger () const
double asReal () const
std::ostream & print (std::ostream &) const

Private Attributes

struct value_iimplementation

Detailed Description

Definition at line 36 of file db.h.


Constructor & Destructor Documentation

Definition at line 143 of file db.cc.

value::value ( const char *  s)

Definition at line 110 of file db.cc.

{
  implementation = new value_i;

  if(implementation)
  {
    implementation->value_type = text;
    implementation->text_value = new string(s);
  }
}
value::value ( const std::string &  s)

Definition at line 99 of file db.cc.

{
  implementation = new value_i;

  if(implementation)
  {
    implementation->value_type = text;
    implementation->text_value = new string(s);
  }
}
value::value ( long long  l)

Definition at line 121 of file db.cc.

value::value ( double  d)

Definition at line 132 of file db.cc.

value::value ( const value v)

Definition at line 148 of file db.cc.

Definition at line 155 of file db.cc.


Member Function Documentation

long long value::asInteger ( ) const

Definition at line 206 of file db.cc.

{
  if(!implementation || (implementation->value_type == null))
    throw exception("Can't convert NULL value to integer");

  switch(implementation->value_type)
  {
    case integer:
       return implementation->integer_value;
    default:
        throw exception("Can't convert value to integer");
  }
}

Here is the caller graph for this function:

double value::asReal ( ) const

Definition at line 220 of file db.cc.

{
  if(!implementation || (implementation->value_type == null))
    throw exception("Can't convert NULL value to real");

  switch(implementation->value_type)
  {
    case real:
       return implementation->real_value;
    default:
       throw exception("Can't convert value to real");
  }

}

Here is the caller graph for this function:

string value::asText ( ) const

Definition at line 189 of file db.cc.

{
  if(!implementation || (implementation->value_type == null))
    throw exception("Can't convert NULL value to text");

  switch(implementation->value_type)
  {
    case text:
    case blob:
       return *(implementation->text_value);
    default:
        throw exception("Can't convert value to text");
  }

  throw exception("Can't convert value to text");
}

Here is the caller graph for this function:

type value::getType ( ) const

Definition at line 181 of file db.cc.

{
  if(implementation)
    return implementation->value_type;
  else
    return null;
}

Here is the caller graph for this function:

value & value::operator= ( const value v)

Definition at line 164 of file db.cc.

{
  if(&v == this) return *this; // self-affectation

  if(implementation)
  {
    implementation->ref--;
    if(implementation->ref<=0) delete implementation;
  }

  implementation = v.implementation;

  if(implementation) implementation->ref++;

  return *this;
}
ostream & value::print ( std::ostream &  out) const

Definition at line 235 of file db.cc.

{
  if(!implementation)
    out << "NULL";
  else
  switch(implementation->value_type)
  {
    case integer:
       out << implementation->integer_value;
       break;
    case real:
       out << implementation->real_value;
       break;
    case text:
       out << *(implementation->text_value);
       break;
    case blob:
       out << "BLOB";
       break;
    case null:
       out << "NULL";
       break;

  }

  return out;
}

Member Data Documentation

Definition at line 58 of file db.h.


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