Back to index

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

#include <hw.h>

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

List of all members.

Public Member Functions

 value ()
 ~value ()
 value (const value &)
 value (long long)
 value (const string &)
valueoperator= (const value &)
bool operator== (const value &) const
string asString () const
bool defined () const

Private Attributes

struct value_iThis

Detailed Description

Definition at line 68 of file hw.h.


Constructor & Destructor Documentation

Definition at line 2227 of file hw.cc.

{
  This = new hw::value_i;

  if(This)
  {
    This->type = nil;
    This->refcount = 1;
  }
}

Definition at line 2239 of file hw.cc.

{
  if(This)
  {
    This->refcount--;
    if(This->refcount<=0)
      delete This;
    This = NULL;
  }
}
value::value ( const value v)

Definition at line 2277 of file hw.cc.

{
  This = v.This;

  if(This)
  {
    This->refcount++;
  }
}
value::value ( long long  ll)

Definition at line 2251 of file hw.cc.

{
  This = new hw::value_i;

  if(This)
  {
    This->type = integer;
    This->ll = ll;
    This->refcount = 1;
  }
}
value::value ( const string &  s)

Definition at line 2264 of file hw.cc.

{
  This = new hw::value_i;

  if(This)
  {
    This->type = text;
    This->s = s;
    This->refcount = 1;
  }
}

Member Function Documentation

string value::asString ( ) const

Definition at line 2331 of file hw.cc.

{
  if(!This) return "";

  switch(This->type)
  {
    case hw::integer:
      return "0x"+tohex(This->ll);
    case hw::text:
      return This->s;
    case hw::boolean:
      return This->b?_("true"):_("false");
    case hw::nil:
      return _("(nil)");
  };

  return "";
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool value::defined ( ) const

Definition at line 2351 of file hw.cc.

{
  if(!This) return false;
  if(This->type==nil) return false;

  return true;
}

Here is the caller graph for this function:

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

Definition at line 2288 of file hw.cc.

{
  if(v.This == This) return *this;

  if(This)
  {
    This->refcount--;
    if(This->refcount<=0)
      delete This;
  }

  This = v.This;
  if(This)
    This->refcount++;

  return *this;
}
bool value::operator== ( const value v) const

Definition at line 2307 of file hw.cc.

{
  if(v.This == This) return true;

  if(!v.This || !This) return false;

  if(v.This->type != This->type) return false;

  switch(This->type)
  {
    case hw::integer:
      return This->ll == v.This->ll;
    case hw::text:
      return This->s == v.This->s;
    case hw::boolean:
      return This->b == v.This->b;
    case hw::nil:
      return true;
  };

  return false;
}

Member Data Documentation

struct value_i* hw::value::This [private]

Definition at line 85 of file hw.h.


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