Made to Order Software Corporation Logo

LLChatLib: LLSD Class Reference

LLSD Class Reference

#include <llsd.h>

List of all members.

Public Member Functions

void clear ()
 resets to Undefined

 LLSD ()
 initially Undefined

 ~LLSD ()
 this class may NOT be subclassed

Iterators





typedef std::vector< LLSD >
::const_iterator 
array_const_iterator
typedef std::vector< LLSD >
::iterator 
array_iterator
typedef std::map< String, LLSD >
::const_iterator 
map_const_iterator
typedef std::map< String, LLSD >
::iterator 
map_iterator
array_const_iterator beginArray () const
array_iterator beginArray ()
map_const_iterator beginMap () const
map_iterator beginMap ()
array_const_iterator endArray () const
array_iterator endArray ()
map_const_iterator endMap () const
map_iterator endMap ()
int size () const

Scalar Types

The scalar types, and how they map onto C++





typedef std::vector< U8 > Binary
typedef bool Boolean
typedef LLDate Date
typedef S32 Integer
typedef F64 Real
typedef std::string String
typedef LLURI URI
typedef LLUUID UUID

Type Testing





enum  Type
bool isArray () const
bool isBinary () const
bool isBoolean () const
bool isDate () const
bool isDefined () const
bool isInteger () const
bool isMap () const
bool isReal () const
bool isString () const
bool isUndefined () const
bool isURI () const
bool isUUID () const
Type type () const

Array Values





void append (const LLSD &)
void erase (Integer)
LLSD get (Integer) const
LLSDinsert (Integer, const LLSD &)
LLSDoperator[] (Integer)
const LLSDoperator[] (Integer) const
void set (Integer, const LLSD &)
static LLSD emptyArray ()

Scalar Accessors

Fetch a scalar value, converting if needed and possible

Conversion among the basic types, Boolean, Integer, Real and String, is fully defined. Each type can be converted to another with a reasonable interpretation. These conversions can be used as a convenience even when you know the data is in one format, but you want it in another. Of course, many of these conversions lose information.

Note: These conversions are not the same as Perl's. In particular, when converting a String to a Boolean, only the empty string converts to false. Converting the String "0" to Boolean results in true.

Conversion to and from UUID, Date, and URI is only defined to and from String. Conversion is defined to be information preserving for valid values of those types. These conversions can be used when one needs to convert data to or from another system that cannot handle these types natively, but can handle strings.

Conversion to and from Binary isn't defined.

Conversion of the Undefined value to any scalar type results in a reasonable null or zero value for the type.





Binary asBinary () const
Boolean asBoolean () const
Date asDate () const
Integer asInteger () const
Real asReal () const
String asString () const
URI asURI () const
UUID asUUID () const
 operator Binary () const
 operator Boolean () const
 operator Date () const
 operator Integer () const
 operator Real () const
 operator String () const
 operator URI () const
 operator UUID () const
bool operator! () const

Automatic Cast Protection

These are not implemented on purpose. Without them, C++ can perform some conversions that are clearly not what the programmer intended.

If you get a linker error about these being missing, you have made mistake in your code. DO NOT IMPLEMENT THESE FUNCTIONS as a fix.

All of thse problems stem from trying to support char* in LLSD or in std::string. There are too many automatic casts that will lead to using an arbitrary pointer or scalar type to std::string.





void assign (const void *)
 assign from arbitrary pointers

bool has (Integer) const
 has only works for Maps

 LLSD (const void *)
 construct from aribrary pointers

LLSDoperator= (const void *)
 assign from arbitrary pointers

Character Pointer Helpers

These are helper routines to make working with char* the same as easy as working with strings.





void assign (const char *)
 LLSD (const char *)
LLSDoperator= (const char *v)

Scalar Assignment





void assign (const Binary &)
void assign (const URI &)
void assign (const Date &)
void assign (const UUID &)
void assign (const String &)
void assign (Real)
void assign (Integer)
void assign (Boolean)
LLSDoperator= (const Binary &v)
LLSDoperator= (const URI &v)
LLSDoperator= (const Date &v)
LLSDoperator= (const UUID &v)
LLSDoperator= (const String &v)
LLSDoperator= (Real v)
LLSDoperator= (Integer v)
LLSDoperator= (Boolean v)

Copyable and Assignable





void assign (const LLSD &other)
 LLSD (const LLSD &)
LLSDoperator= (const LLSD &other)

Map Values





void erase (const String &)
LLSD get (const String &) const
bool has (const String &) const
LLSDinsert (const String &, const LLSD &)
const LLSDoperator[] (const char *c) const
const LLSDoperator[] (const String &) const
LLSDoperator[] (const char *c)
LLSDoperator[] (const String &)
static LLSD emptyMap ()

Convenience Constructors





 LLSD (F32)

Scalar Constructors





 LLSD (const Binary &)
 LLSD (const URI &)
 LLSD (const Date &)
 LLSD (const UUID &)
 LLSD (const String &)
 LLSD (Real)
 LLSD (Integer)
 LLSD (Boolean)

Unit Testing Interface





static U32 allocationCount ()
 how many Impls have been made

static U32 outstandingCount ()
 how many Impls are still alive


Detailed Description

LLSD provides a flexible data system similar to the data facilities of dynamic languages like Perl and Python. It is created to support exchange of structured data between loosly coupled systems. (Here, "loosly coupled" means not compiled together into the same module.)

Data in such exchanges must be highly tollerant of changes on either side such as:

  • recompilation
  • implementation in a different langauge
  • addition of extra parameters
  • execution of older versions (with fewer parameters)

To this aim, the C++ API of LLSD strives to be very easy to use, and to default to "the right thing" whereever possible. It is extremely tollerant of errors and unexpected situations.

The fundimental class is LLSD. LLSD is a value holding object. It holds one value that is either undefined, one of the scalar types, or a map or an array. LLSD objects have value semantics (copying them copies the value, though it can be considered efficient, due to shareing.), and mutable.

Undefined is the singular value given to LLSD objects that are not initialized with any data. It is also used as the return value for operations that return an LLSD,

The sclar data types are:

  • Boolean - true or false
  • Integer - a 32 bit signed integer
  • Real - a 64 IEEE 754 floating point value
  • UUID - a 128 unique value
  • String - a sequence of zero or more Unicode chracters
  • Date - an absolute point in time, UTC, with resolution to the second
  • URI - a String that is a URI
  • Binary - a sequence of zero or more octets (unsigned bytes)

A map is a dictionary mapping String keys to LLSD values. The keys are unique within a map, and have only one value (though that value could be an LLSD array).

An array is a sequence of zero or more LLSD values.


The documentation for this class was generated from the following files:
  • /home/doug/src/oss/slitechat/trunk/LLChatLib/llcommon/llsd.h
  • /home/doug/src/oss/slitechat/trunk/LLChatLib/llcommon/llsd.cpp
Generated on Thu Sep 23 17:18:44 2010 for LLChatLib by  doxygen 1.6.3