value Class Reference

Generic storage for hierarchical data. More...

#include <value.h>

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

List of all members.

Public Types

enum  xmlargs { compact = true, nocompact = false }

Public Member Functions

 value (void)
 value (creatorlabel, unsigned int)
 value (creatorlabel, const char *)
 value (creatorlabel, const char *, unsigned int)
 value (creatorlabel, const string &)
 value (value &)
 value (const value &)
 value (value *)
 value (const char *)
 value (double)
 value (const class valuable &)
 value (class valuable *)
 value (const string &s)
 value (string *s)
 value (const statstring &s)
 value (int)
 value (unsigned int)
 value (long long)
 value (unsigned long long)
 value (bool)
 value (const class ipaddress &)
 value (const class timestamp &)
 ~value (void)
const valueoperator[] (int i) const
valueoperator[] (int i)
const valueoperator[] (const char *str) const
valueoperator[] (const char *str)
const valueoperator[] (const string &str) const
valueoperator[] (const string &str)
const valueoperator[] (const statstring &str) const
valueoperator[] (const statstring &str)
const valueoperator[] (const value &va) const
valueoperator[] (const value &va)
const valueoperator() (const statstring &ki) const
valueoperator() (const statstring &ki)
void setattrib (const statstring &ki, const string &val)
void setattrib (const statstring &ki, int val)
void setattrib (const statstring &ki, const char *val)
void setattrib (const statstring &ki, bool val)
valuesetip (unsigned int)
valuesettime (const class timestamp &)
valueoperator= (const value &v)
valueoperator= (value *v)
valueoperator= (class valuable &)
valueoperator= (class valuable *)
valueoperator= (const class ipaddress &)
valueoperator= (const class timestamp &)
valueoperator= (bool bval)
valueoperator= (long long dval)
valueoperator= (const class currency &c)
valueoperator= (class currency &c)
valueoperator= (unsigned long long val)
valueoperator= (const char *str)
valueoperator= (const unsigned char *str)
valueoperator= (const string &str)
valueoperator= (string *str)
valueoperator= (const statstring &str)
valueoperator= (statstring *str)
valueoperator= (int i)
valueoperator= (unsigned int i)
valueoperator= (double d)
valueoperator<< (value *v)
valueoperator<< (const value &v)
 operator bool (void) const
 operator long long (void) const
 operator unsigned long long (void) const
 operator int (void) const
 operator unsigned int (void) const
 operator const string & (void) const
 operator const char * (void) const
 operator double (void) const
void assign (const class currency &)
void assign (class currency *)
void setcurrency (long long cnew)
long long getcurrency (void) const
const stringsval (void) const
const char * cval (void) const
const char * str (void) const
unsigned int uval (void) const
int ival (void) const
double dval (void) const
long long lval (void) const
unsigned long long ulval (void) const
unsigned int ipval (void)
unsigned int ipval (void) const
bool bval (void) const
const statstringtype (void) const
void type (const dtenum &t)
int count (void) const
int arraysize (void) const
valueoperator+= (const string &str)
valueoperator+= (const value &v)
bool operator< (const value &other) const
bool operator< (const value &other)
bool operator<= (const value &other) const
bool operator<= (const value &other)
bool operator>= (const value &other) const
bool operator>= (const value &other)
bool operator> (const value &other) const
bool operator> (const value &other)
bool operator== (const value &other) const
bool operator== (const value &other)
bool operator!= (const value &other) const
bool operator!= (const value &other)
bool operator== (const char *other) const
bool operator== (double other) const
bool operator== (double other)
bool operator!= (double other) const
bool operator!= (double other)
bool operator< (double other) const
bool operator< (double other)
bool operator<= (double other) const
bool operator<= (double other)
bool operator> (double other) const
bool operator> (double other)
bool operator>= (double other) const
bool operator>= (double other)
bool operator== (int other) const
bool operator== (int other)
bool operator!= (int other) const
bool operator!= (int other)
bool operator< (int other) const
bool operator< (int other)
bool operator<= (int other) const
bool operator<= (int other)
bool operator> (int other) const
bool operator> (int other)
bool operator>= (int other) const
bool operator>= (int other)
bool operator== (unsigned int other) const
bool operator== (unsigned int other)
bool operator!= (unsigned int other) const
bool operator!= (unsigned int other)
bool operator< (unsigned int other) const
bool operator< (unsigned int other)
bool operator<= (unsigned int other) const
bool operator<= (unsigned int other)
bool operator> (unsigned int other) const
bool operator> (unsigned int other)
bool operator>= (unsigned int other) const
bool operator>= (unsigned int other)
bool operator== (long long other) const
bool operator== (long long other)
bool operator!= (long long other) const
bool operator!= (long long other)
bool operator< (long long other) const
bool operator< (long long other)
bool operator<= (long long other) const
bool operator<= (long long other)
bool operator> (long long other) const
bool operator> (long long other)
bool operator>= (long long other) const
bool operator>= (long long other)
bool operator== (unsigned long long other) const
bool operator== (unsigned long long other)
bool operator!= (unsigned long long other) const
bool operator!= (unsigned long long other)
bool operator< (unsigned long long other) const
bool operator< (unsigned long long other)
bool operator<= (unsigned long long other) const
bool operator<= (unsigned long long other)
bool operator> (unsigned long long other) const
bool operator> (unsigned long long other)
bool operator>= (unsigned long long other) const
bool operator>= (unsigned long long other)
bool operator!= (const string &other) const
bool operator!= (const statstring &other) const
bool operator!= (const char *other) const
bool operator!= (const char *other)
bool operator!= (bool other) const
bool operator!= (bool other)
bool operator== (bool other) const
bool operator== (bool other)
bool operator== (const char *s)
bool operator== (const statstring &s) const
bool operator== (const statstring &s)
bool operator!= (const statstring &s)
bool operator== (const class ipaddress &o)
bool operator!= (const class ipaddress &o)
void clear (void)
void cleararray (void)
valueinsertval (int atpos=0, dtenum typ=t_unset)
void rmindex (int)
void rmval (unsigned int k, const char *ks, int idx=-1)
void rmval (unsigned int)
void rmval (const char *)
void rmval (const value &)
void rmval (const statstring &)
void rmval (const string &s)
valuelast (void)
const char * name (void) const
const statstringlabel (void) const
const statstringid (void) const
void load (const string &)
void load (class file &)
void save (const string &, bool compact=false) const
void save (class file &, bool compact=false) const
stringencode (bool compact=false) const
void decode (string &)
bool loadini (const string &fn)
bool loadinitree (const string &fn)
stringtocsv (bool withHeaders=true, const char *indexName="id")
bool savecsv (const string &fn, bool withHeaders=true, const char *indexName="id")
bool loadcsv (const string &fn, bool withHeaders=true, const string &key="")
bool fromcsv (const string &csvData, bool withHeaders=true, const string &key="")
void phpdeserialize (const string &phpdata)
stringphpserialize (bool withattr=false) const
bool savexml (const string &fn, bool compact=false, class xmlschema *schema=NULL, flag::savetype tp=flag::normal) const
bool savexml (const string &fn, bool compact, flag::savetype tp) const
bool savexml (const string &fn, class xmlschema &schema, flag::savetype tp=flag::normal) const
bool savexml (const string &fn, flag::savetype tp) const
bool savexml (const string &fn, bool compact, class xmlschema &schema, flag::savetype tp=flag::normal) const
stringtoxml (bool compact=false, class xmlschema *s=NULL) const
stringtoxml (bool compact, class xmlschema &) const
bool fromxml (const string &d, class xmlschema *s=NULL, string *err=NULL)
bool fromxml (const string &d, string &err)
bool fromxml (const string &d, class xmlschema &s)
bool loadxml (const string &path, class xmlschema &s)
bool loadxml (const string &path, class xmlschema *s=NULL, string *err=NULL)
bool loadxml (const string &path, string &err)
bool loadxml (const string &p, class xmlschema &s, string &er)
bool fromxml (const string &p, class xmlschema &s, string &er)
bool fromjson (const string &j)
stringtojson (void) const
void encodegrace (string &into, int indent)
stringtograce (void)
void fromcxml (string &dat, class xmlschema &s)
stringtocxml (class xmlschema &s)
void saveplist (const string &fn, bool compact=false)
stringtoplist (bool compact=false)
void fromplist (const string &dat)
void loadplist (const string &fn)
bool loadshox (const string &fname)
bool saveshox (const string &fname, flag::savetype tp=flag::normal) const
bool fromshox (const string &shox)
stringtoshox (void) const
bool isempty (void) const
int strlen (void) const
bool exists (const char *) const
bool exists (unsigned int, const char *) const
bool exists (const string &) const
bool exists (const statstring &) const
bool exists (const value &) const
bool isarray (void) const
bool isdict (void) const
bool ismixed (void) const
bool haveattributes (void) const
bool hasattributes (void) const
const valueattributes (void) const
valueattributes (void)
bool attribexists (const statstring &id) const
void rmattrib (const statstring &id)
void sort (sortmethod)
void sort (sortmethod, const string &)
valuefilter (const statstring &label, const string &what) const
valuecutleft (int num)
valuecopyleft (int num) const
valuecutright (int num)
valuecopyright (int num) const
void cropleft (int num)
void cropright (int num)
valuesplice (int pos, int count=-1) const
valuezip (void) const
valuebyvalue (void) const
stringjoin (const string &sep=" ", const string &left="", const string &right="")
stringjoin (char c)
bool treecmp (const value &other) const
valuevisitchild (const statstring &id) const
valuevisitchild (int index) const
void init (bool first=true)



stringleft (int m) const
stringright (int m) const
stringmid (int p, int s=0) const
stringcopyuntil (char x) const
stringcopyuntil (const string &x) const
stringcopyuntillast (char x) const
stringcopyuntillast (const string &x) const
stringcopyafter (char x) const
stringcopyafter (const string &x) const
stringcopyafterlast (char x) const
stringcopyafterlast (const string &x) const
int strcmp (const string &o) const
int strncmp (const string &o, int sz=0) const
int strcasecmp (const string &o) const
int strncasecmp (const string &o, int sz=0) const
bool globcmp (const string &str) const
bool regcmp (const string &str) const
int countchr (char c, int e=0) const
stringencode64 (void) const
stringdecode64 (void) const

Static Public Member Functions

static bool isbuiltin (const statstring &type)

Public Attributes

value *const statstringid

Protected Member Functions

valueiniparse (const string &)
void print (int, class file &, bool compact=false) const
void printstr (int, string &, bool compact=false) const
void printxml (int, string &, bool, class xmlschema *, value *, const statstring &, const statstring &) const
void printplist (int, string &, bool compact=false) const
void printphp (string &into, bool withattr) const
const char * phpdeserialize (const char *, bool)
size_t printcompressed (size_t, string &, const value &, class xmlschema &) const
size_t parsecompressed (size_t, string &, class xmlschema &)
size_t compressbuiltin (size_t, string &, const char *, const statstring &, const value &) const
size_t compressbuiltin (size_t sz, string &a, const char *b, const string &c, const value &d) const
bool readshox (class stringdict &, size_t &, const string &)
void printshox (string &, stringdict &) const
void encodejsonstring (string &into) const
void encodejsonid (string &into) const
void encodejson (string &into) const
const char * decodejson (const char *)
const char * readjsonstring (const char *, string &)
const char * readjsonnumber (const char *, string &)
void alloc (unsigned int c)
valuefindchild (const char *) const
valuefindchild (const char *)
valuehavechild (unsigned int, const char *) const
valuefindchild (unsigned int, const char *) const
valuefindchild (unsigned int, const char *)
valuegetposition (unsigned int)
valuegetposition (unsigned int) const
void relinktree (void)

Protected Attributes

dtenum _type
string s
dtype t
unsigned char itype
unsigned int key
class statstring _name
valuelower
valuehigher
valueattrib
value ** array
unsigned int arraysz
unsigned int arrayalloc
unsigned int ucount
threadref_t threadref

Friends

class visitor< value >
class iterator< value, value >
class iterator< const value, const value >
class visitor< const value >
class validator

Detailed Description

Generic storage for hierarchical data.

A value object can either contain direct data (either an integer, a string or some other intrinsic type) or a mixed array of child values, where some or all array members may also have a string key. The class is designed to make it easy to access its data. This means a number of overloaded operators. Typical code is very compact and easy to read, though:

#include <grace/value.h>

void foo (void)
{
    value v;
    v.type ("phoneBook");
    
    v["john"]["firstName"] = "John";
    v[-1]("type") = "friend";
    v[-1]["lastName"] = "Smith";
    v[-1]["phoneNumber"] = "212-555-1234";
    v[-1]["userId"] = 15;
    
    v["pete"]["firstName"] = "Peter";
    v[-1]("type") = "coworker";
    v[-1]["lastName"] = "O'Connor";
    v[-1]["phoneNumber"] = "212-555-4321";
    v[-1]["userId"] = 43;
}

The data created in this example would encode to XML like this:

<?xml version="1.0" encoding="utf=8"?>
<phoneBook>
  <dict id="john" type="friend">
    <string id="firstName">John</string>
    <string id="lastName">Smith</string>
    <string id="phoneNumber">212-555-1234</string>
    <integer id="userId">15</integer>
  </dict>
  <dict id="pete" type="coworker">
    <string id="firstName">Peter</string>
    <string id="lastName">O'Connor</string>
    <string id="phoneNumber">212-555-4321</string>
    <integer id="userId">43</integer>
  </dict>
</phoneBook>

Member Enumeration Documentation

Options for xml encoding.

Enumerator:
compact 

Compacted output.

nocompact 

Indented output.


Member Function Documentation

int value::arraysize ( void   )  const [inline]

Return count of numbered array members.

Only child nodes that have no key are counted.

References ucount.

bool value::attribexists ( const statstring id  )  const [inline]

Returns true if a key exists in the attributes.

Parameters:
id The key to look for.

References attrib, and exists().

Referenced by xmlschema::resolveindexname(), xmlschema::resolveunion(), and cli< ctlclass >::tabhandler().

Here is the call graph for this function:

value * value::byvalue ( void   )  const

Returns a value object that contains copies of the object's children, but with their keys and values switched.

This can be useful to change, e.g., a split string array into a list of keys that can be probed through value::exists().

value * value::copyleft ( int  num  )  const

Copy a number of leftmost nodes.

Parameters:
num The number, if negative relative to the total array size.
value * value::copyright ( int  num  )  const

Copy a number of rightmost nodes.

Parameters:
num The number, if negative relative to the total array size.
void value::cropleft ( int  num  ) 

Crop an array to the left half that has a set maximum number of nodes.

Parameters:
num The maximum amount of nodes to keep.
void value::cropright ( int  num  ) 

Crop an array to the right half that has a set aximum number of nodes.

Parameters:
num The maximum amount of nodes to keep.
value * value::cutleft ( int  num  ) 

Cut off a number of leftmost nodes.

Parameters:
num The number, if negative relative to the total array size.

References rmindex().

Here is the call graph for this function:

value * value::cutright ( int  num  ) 

Cut off a number of rightmost nodes.

Parameters:
num The number, if negative relative to the total array size.

References rmindex().

Here is the call graph for this function:

value * value::filter ( const statstring label,
const string what 
) const

Filter out children that have a child node with a specified value.

Parameters:
label The grandchild key to investigate.
what The value to look out for.

References _name, sval(), and type().

Here is the call graph for this function:

bool value::fromcsv ( const string csvData,
bool  withHeaders = true,
const string key = "" 
)

Convert from CSV format.

Parameters:
csvData String containing the CSV data as text.
withHeaders True if the file has a header row.
key Label of the index row (empty for index on first row).

References clear(), count(), strutil::splitcsv(), strutil::splitlines(), strutil::splitquoted(), string::strlen(), and sval().

Here is the call graph for this function:

void value::fromcxml ( string dat,
class xmlschema s 
)

Convert from CXML.

Uses a binary storage format comparable to the Apple/NeXT serialized plist. Requires a schema with CXML elements.

Parameters:
dat The binary data.
s The schema to use.

References parsecompressed(), and string::strlen().

Here is the call graph for this function:

bool value::fromjson ( const string j  ) 

Convert from a JSON-encoded string.

Parameters:
j JSON string.

References string::cval().

Here is the call graph for this function:

void value::fromplist ( const string dat  ) 

Convert from Apple's plist format.

Requires the com.apple.plist.schema.xml schema.

Parameters:
dat The text data.

References fromxml().

Here is the call graph for this function:

bool value::fromshox ( const string shox  ) 

Convert from SHOX string data.

Parameters:
shox The shox-encoded data.

References string::bingetvint(), string::bingetvstr(), clear(), stringdict::get(), readshox(), string::strlen(), and t.

Referenced by dbfile::decode(), and loadshox().

Here is the call graph for this function:

bool value::fromxml ( const string p,
class xmlschema s,
string er 
)

Convert from an XML string with schema and error reporting.

Parameters:
p The file name.
s The XML schema to use.
err Output string for the parser errors.

References fromxml().

Here is the call graph for this function:

bool value::fromxml ( const string d,
class xmlschema s 
)

Convert from string with XML data.

Parameters:
d The XML text data.
s The schema to use for parsing.

References fromxml().

Here is the call graph for this function:

bool value::fromxml ( const string d,
class xmlschema s = NULL,
string err = NULL 
)
long long value::getcurrency ( void   )  const

Get the value as a fixed point decimal number with three digits behind the decimal point, giving a resolution of 0.1 cents of an arbitrary currency.

References itype, and s.

Referenced by compressbuiltin(), currency::currency(), printxml(), savecsv(), and tocsv().

bool value::haveattributes ( void   )  const [inline]

Returns true if the object has attributes.

Deprecated, use value::hasattributes().

References attrib.

Referenced by xmlschema::validate().

value & value::insertval ( int  atpos = 0,
dtenum  typ = t_unset 
)

Return reference to a new unkeyed child.

Parameters:
atpos Insertion point.
typ Registered type of the new child.
Type Constraints

References alloc(), and ucount.

Here is the call graph for this function:

bool value::isarray ( void   )  const

Returns true if the object is an array, with keyed and/or numbered child nodes.

bool value::isbuiltin ( const statstring type  )  [static]

Returns true if the provided type string represents a grace built-in.

References statstring::key().

Referenced by operator[](), printshox(), and setcurrency().

Here is the call graph for this function:

bool value::isdict ( void   )  const

Returns true if the object is a pure dict with only keyed child nodes.

References ucount.

bool value::isempty ( void   )  const

Return true if the value is empty: No data, no attributes and no children.

References attrib, and itype.

Referenced by daemon::settargetgroups().

bool value::ismixed ( void   )  const

Returns true if the object is an array mix of numbered and keyed child nodes.

References ucount.

string * value::join ( const string sep = " ",
const string left = "",
const string right = "" 
)

Join the string representations of all array values together into a new string.

Parameters:
sep The separator between values
left Optional left delimiter string.
right Optional right delimiter stirng.

References string::strcat().

Here is the call graph for this function:

void value::load ( class file f  ) 

Load ASCII data from an already open file.

Exceptions:
value::exception Loading/parsing exception

References arraysz, file::close(), stack< kind >::count(), dval(), findchild(), file::gets(), ipval(), ival(), string::mid(), name(), strutil::regexp(), strutil::splitquoted(), string::str(), string::strchr(), and sval().

Here is the call graph for this function:

void value::load ( const string fname  ) 

Load data in plain ASCII format.

Does not support attributes.

Exceptions:
value::exception Loading/parsing exception

References file::openread().

Here is the call graph for this function:

bool value::loadcsv ( const string fn,
bool  withHeaders = true,
const string key = "" 
)

Load from CSV format.

Parameters:
fn File name.
withHeaders True if the file has a header row.
key Label of the index row (empty for index on first row).

References clear(), file::close(), count(), file::eof(), file::gets(), file::openread(), strutil::splitcsv(), string::strlen(), and sval().

Here is the call graph for this function:

void value::loadplist ( const string fn  ) 

Load from Apple's plist format.

Requires the com.apple.plist.schema.xml schema.

Parameters:
fn File name to load.

References loadxml().

Here is the call graph for this function:

bool value::loadshox ( const string fname  ) 

Load from the SHOX object format.

Parameters:
fname Filename to load.

References fromshox(), and filesystem::load().

Here is the call graph for this function:

bool value::loadxml ( const string p,
class xmlschema s,
string er 
)

Load from an XML file with schema and error reporting.

Parameters:
p The file name.
s The XML schema to use.
err Output string for the parser errors.

References loadxml().

Here is the call graph for this function:

bool value::loadxml ( const string path,
string err 
) [inline]

Load from an XML file using the default grace schema.

Parameters:
path The file name.
err Output string for parser errors.

References loadxml().

Here is the call graph for this function:

bool value::loadxml ( const string path,
class xmlschema s = NULL,
string err = NULL 
)

Load from an XML file.

Parameters:
path The file name.
s The schema to be used for parsing. NULL for none.

References fromxml(), filesystem::load(), string::strcpy(), and string::strlen().

Here is the call graph for this function:

bool value::loadxml ( const string path,
class xmlschema s 
)

Load from an XML file.

Parameters:
path The file name.
s The schema to be used for parsing.

Referenced by xmlschema::load(), validator::load(), configdb< appclass >::load(), loadplist(), loadxml(), and xmlschema::xmlschema().

const char * value::name ( void   )  const

Cast key as a c-string.

Use id() and format if possible.

References _name, and statstring::str().

Referenced by decode(), fromxml(), load(), printphp(), savecsv(), and tocsv().

Here is the call graph for this function:

value & value::operator() ( const statstring ki  ) 

Access to object's attributes.

Although this operator casts to a value object, attributes should not have children of their own or XML encoding will not be possible.

Parameters:
ki Key for the attribute.

References attrib.

void value::phpdeserialize ( const string phpdata  ) 

Deserialize PHP data.

Parameters:
phpdata A serialized PHP array.

References string::str().

Referenced by phpdeserialize().

Here is the call graph for this function:

string * value::phpserialize ( bool  withattr = false  )  const

Serialize to a PHP array.

Parameters:
withattr If set, all objects will be split in two levels. Arrays will gain at least one extra node called ".attr" if there are attributes. Data objects will end up with their actual value inside a child-node called ".data" with, again, any attributes inside ".attr".
Returns:
A new string object.

References printphp().

Here is the call graph for this function:

void value::rmattrib ( const statstring id  )  [inline]

Remove attribute for a key.

Parameters:
id The key to remove.

References attrib, and rmval().

Here is the call graph for this function:

void value::rmval ( unsigned int  k,
const char *  ks,
int  idx = -1 
)

Remove any child.

Parameters:
k Key value of the child to remove.
ks String key value of the child.
idx Array index of value to remove (-1 to use key).

References arrayalloc, and ucount.

Referenced by httpsocket::post(), rmattrib(), rmindex(), rmval(), dbrecord::rmval(), and strutil::xmlreadtag().

bool value::savecsv ( const string fn,
bool  withHeaders = true,
const char *  indexName = "id" 
)

Save in CSV format.

This export does not encode attributes.

Parameters:
fn Filename to save.
withHeaders If true, add a header row.
indexName Column name for the index field.

References arraysz, file::close(), count(), strutil::encodecsv(), getcurrency(), label(), name(), file::openwrite(), string::printf(), file::printf(), string::str(), and sval().

Here is the call graph for this function:

void value::saveplist ( const string fn,
bool  compact = false 
)

Save in Apple's plist format.

Requires the com.apple.plist.schema.xml schema.

Parameters:
fn File name.
compact Either value::compact or value::nocompact.

References savexml(), and type().

Here is the call graph for this function:

bool value::saveshox ( const string fname,
flag::savetype  tp = flag::normal 
) const

Save to the SHOX object format.

Parameters:
fname Filename to save.
tp Optional save type, set to flag::atomic to do an atomic save (flush to tempfile followed by a rename).

References filesystem::save(), and toshox().

Here is the call graph for this function:

bool value::savexml ( const string fn,
bool  compact,
class xmlschema schema,
flag::savetype  tp = flag::normal 
) const

Save in XML format.

Parameters:
fn File name to save.
compact Set to value::compact or value::nocompact.
schema XML schema to apply.
tp Set to 'atomic' to write atomically using a temporary file.

References savexml().

Here is the call graph for this function:

bool value::savexml ( const string fn,
flag::savetype  tp 
) const

Save in XML format.

Parameters:
fn File name to save.
tp Set to 'atomic' to write atomically using a temporary file.

References savexml().

Here is the call graph for this function:

bool value::savexml ( const string fn,
class xmlschema schema,
flag::savetype  tp = flag::normal 
) const [inline]

Save in XML format.

Parameters:
fn File name to save.
schema XML schema to use.
tp Set to 'atomic' to write atomically using a temporary file.

References nocompact, and savexml().

Here is the call graph for this function:

bool value::savexml ( const string fn,
bool  compact,
flag::savetype  tp 
) const

Save in XML format.

Parameters:
fn File name to save.
compact Set to value::compact or value::nocompact.
tp Set to 'atomic' to write atomically using a temporary file.

References savexml().

Here is the call graph for this function:

bool value::savexml ( const string fn,
bool  compact = false,
class xmlschema schema = NULL,
flag::savetype  tp = flag::normal 
) const

Save in XML format.

Parameters:
fn File name to save.
compact Set to value::compact or value::nocompact.
schema XML schema to apply, NULL for none.
tp Set to 'atomic' to write atomically using a temporary file.

References filesystem::save(), and toxml().

Referenced by smtpd::deliver(), saveplist(), and savexml().

Here is the call graph for this function:

void value::setattrib ( const statstring ki,
bool  val 
)

Directly set a keyed attribute.

Parameters:
ki Attribute's key.
val Attribute's value.

References attrib.

void value::setattrib ( const statstring ki,
const char *  val 
)

Directly set a keyed attribute.

Parameters:
ki Attribute's key.
val Attribute's value.

References attrib.

void value::setattrib ( const statstring ki,
int  val 
)

Directly set a keyed attribute.

Parameters:
ki Attribute's key.
val Attribute's value.

References attrib.

void value::setattrib ( const statstring ki,
const string val 
)

Directly set a keyed attribute.

Parameters:
ki Attribute's key.
val Attribute's value.

References attrib.

Referenced by xmlschema::addbaseclass(), cgi::cgi(), fromxml(), parsecompressed(), and strutil::parsehdr().

void value::setcurrency ( long long  cnew  ) 

Set the value as a fixed point decimal number with three digits behind the decimal point.

References _type, cleararray(), isbuiltin(), and itype.

Referenced by fromxml().

Here is the call graph for this function:

void value::sort ( sortmethod  cmpare,
const string opt 
)

Sort this object's child nodes.

Accepts an optional key string to be used by some sort methods.

References arrayalloc, arraysz, and ucount.

value * value::splice ( int  pos,
int  count = -1 
) const

Get a copy of a sub-range of the array.

Parameters:
pos Starting position.
count Max number of nodes to copy.

References count().

Here is the call graph for this function:

int value::strlen ( void   )  const

Returns the length of this node's string representation.

References string::strlen(), and sval().

Referenced by xmlschema::nstranstype(), phpdeserialize(), printphp(), xmlschema::resolveclass(), timestamp::rfc822(), cliutil::splitwords(), and cli< ctlclass >::tabhandler().

Here is the call graph for this function:

string * value::tocsv ( bool  withHeaders = true,
const char *  indexName = "id" 
)

Convert to CSV format.

This export does not encode attributes.

Parameters:
withHeaders If true, add a header row.
indexName Column name for the index field.

References arraysz, count(), dval(), strutil::encodecsv(), getcurrency(), itype, ival(), label(), name(), string::printf(), string::str(), and sval().

Here is the call graph for this function:

string * value::tocxml ( class xmlschema s  ) 

Convert to CXML.

Creates a string with a binary dump of the object and its children. Requires a schema with CXML elements.

Parameters:
s The schema to use.

References printcompressed().

Here is the call graph for this function:

string * value::toplist ( bool  compact = false  ) 

Convert to Apple's plist format.

Requires the com.apple.plist.schema.xml schema.

Parameters:
compact Either value::compact or value::nocompact.

References toxml(), and type().

Here is the call graph for this function:

string * value::toxml ( bool  compact,
class xmlschema schema 
) const

Convert to string containing XML data.

Parameters:
compact Set to value::compact or value::nocompact.
schema XML schema to apply.

References toxml().

Here is the call graph for this function:

string * value::toxml ( bool  compact = false,
class xmlschema s = NULL 
) const

Convert to string containing XML data.

Parameters:
compact Set to value::compact or value::nocompact.
s XML schema to apply, NULL for none.

References attributes(), xmlschema::doctype(), xmlschema::hasdoctype(), and printxml().

Referenced by savexml(), toplist(), and toxml().

Here is the call graph for this function:

void value::type ( const dtenum t  )  [inline]

Set type string.

Parameters:
t The registered type (i.e. "string" or "myclass").

References _type.

const statstring& value::type ( void   )  const [inline]

Return registered type.

This can either be a statstring reflection of an intrinsic type like "string" or "integer", but it can also be a custom 'class'.

References _type.

Referenced by xmlschema::addbaseclass(), xmlschema::addbasemembers(), cgi::cgi(), filter(), fromxml(), loadinitree(), operator[](), parsecompressed(), smtpworker::run(), httpdworker::run(), httpd::run(), logthread::run(), saveplist(), toplist(), xmlschema::validate(), and xmlschema::xmlschema().

value * value::zip ( void   )  const

'zip' up a two dimentional dictionary or array, where the rowcount remains the same, but the two dimensions are swapped.

$($("name","john"))->$($("name","steve")) will be turned into: $("name", $("john")->$("steve"))


Member Data Documentation

Continuation method for the valuebuilder syntax.

The first node in an arraybuilder declaration is actually a $(...)-style function that creates a new object. Further nodes are chained using the regular '->' pointer follower.

Parameters:
id Key for the new node.
v Value for the new node.

Referenced by cli< ctlclass >::fullexpand(), httpsocket::get(), xmlschema::nstransattr(), httpsocket::post(), cmdtoken_loop::run(), and cli< ctlclass >::tabhandler().


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

Generated on Sun Feb 28 10:37:16 2010 for GRACE by  doxygen 1.6.1