Generic storage for hierarchical data. More...
#include <value.h>


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 value & | operator[] (int i) const |
| value & | operator[] (int i) |
| const value & | operator[] (const char *str) const |
| value & | operator[] (const char *str) |
| const value & | operator[] (const string &str) const |
| value & | operator[] (const string &str) |
| const value & | operator[] (const statstring &str) const |
| value & | operator[] (const statstring &str) |
| const value & | operator[] (const value &va) const |
| value & | operator[] (const value &va) |
| const value & | operator() (const statstring &ki) const |
| value & | operator() (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) |
| value & | setip (unsigned int) |
| value & | settime (const class timestamp &) |
| value & | operator= (const value &v) |
| value & | operator= (value *v) |
| value & | operator= (class valuable &) |
| value & | operator= (class valuable *) |
| value & | operator= (const class ipaddress &) |
| value & | operator= (const class timestamp &) |
| value & | operator= (bool bval) |
| value & | operator= (long long dval) |
| value & | operator= (const class currency &c) |
| value & | operator= (class currency &c) |
| value & | operator= (unsigned long long val) |
| value & | operator= (const char *str) |
| value & | operator= (const unsigned char *str) |
| value & | operator= (const string &str) |
| value & | operator= (string *str) |
| value & | operator= (const statstring &str) |
| value & | operator= (statstring *str) |
| value & | operator= (int i) |
| value & | operator= (unsigned int i) |
| value & | operator= (double d) |
| value & | operator<< (value *v) |
| value & | operator<< (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 string & | sval (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 statstring & | type (void) const |
| void | type (const dtenum &t) |
| int | count (void) const |
| int | arraysize (void) const |
| value & | operator+= (const string &str) |
| value & | operator+= (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) |
| value & | insertval (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) |
| value & | last (void) |
| const char * | name (void) const |
| const statstring & | label (void) const |
| const statstring & | id (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 |
| string * | encode (bool compact=false) const |
| void | decode (string &) |
| bool | loadini (const string &fn) |
| bool | loadinitree (const string &fn) |
| string * | tocsv (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) |
| string * | phpserialize (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 |
| string * | toxml (bool compact=false, class xmlschema *s=NULL) const |
| string * | toxml (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) |
| string * | tojson (void) const |
| void | encodegrace (string &into, int indent) |
| string * | tograce (void) |
| void | fromcxml (string &dat, class xmlschema &s) |
| string * | tocxml (class xmlschema &s) |
| void | saveplist (const string &fn, bool compact=false) |
| string * | toplist (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) |
| string * | toshox (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 value & | attributes (void) const |
| value & | attributes (void) |
| bool | attribexists (const statstring &id) const |
| void | rmattrib (const statstring &id) |
| void | sort (sortmethod) |
| void | sort (sortmethod, const string &) |
| value * | filter (const statstring &label, const string &what) const |
| value * | cutleft (int num) |
| value * | copyleft (int num) const |
| value * | cutright (int num) |
| value * | copyright (int num) const |
| void | cropleft (int num) |
| void | cropright (int num) |
| value * | splice (int pos, int count=-1) const |
| value * | zip (void) const |
| value * | byvalue (void) const |
| string * | join (const string &sep=" ", const string &left="", const string &right="") |
| string * | join (char c) |
| bool | treecmp (const value &other) const |
| value * | visitchild (const statstring &id) const |
| value * | visitchild (int index) const |
| void | init (bool first=true) |
| string * | left (int m) const |
| string * | right (int m) const |
| string * | mid (int p, int s=0) const |
| string * | copyuntil (char x) const |
| string * | copyuntil (const string &x) const |
| string * | copyuntillast (char x) const |
| string * | copyuntillast (const string &x) const |
| string * | copyafter (char x) const |
| string * | copyafter (const string &x) const |
| string * | copyafterlast (char x) const |
| string * | copyafterlast (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 |
| string * | encode64 (void) const |
| string * | decode64 (void) const |
Static Public Member Functions | |
| static bool | isbuiltin (const statstring &type) |
Public Attributes | |
| value *const statstring & | id |
Protected Member Functions | |
| value * | iniparse (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) |
| value * | findchild (const char *) const |
| value * | findchild (const char *) |
| value * | havechild (unsigned int, const char *) const |
| value * | findchild (unsigned int, const char *) const |
| value * | findchild (unsigned int, const char *) |
| value * | getposition (unsigned int) |
| value * | getposition (unsigned int) const |
| void | relinktree (void) |
Protected Attributes | |
| dtenum | _type |
| string | s |
| dtype | t |
| unsigned char | itype |
| unsigned int | key |
| class statstring | _name |
| value * | lower |
| value * | higher |
| value * | attrib |
| 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 |
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>
| enum value::xmlargs |
| int value::arraysize | ( | void | ) | const [inline] |
| bool value::attribexists | ( | const statstring & | id | ) | const [inline] |
Returns true if a key exists in the attributes.
| id | The key to look for. |
References attrib, and exists().
Referenced by xmlschema::resolveindexname(), xmlschema::resolveunion(), and cli< ctlclass >::tabhandler().

| 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.
| num | The number, if negative relative to the total array size. |
| value * value::copyright | ( | int | num | ) | const |
Copy a number of rightmost nodes.
| 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.
| 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.
| num | The maximum amount of nodes to keep. |
| value * value::cutleft | ( | int | num | ) |
| value * value::cutright | ( | int | num | ) |
| value * value::filter | ( | const statstring & | label, | |
| const string & | what | |||
| ) | const |
Convert from CSV format.
| 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().

Convert from CXML.
Uses a binary storage format comparable to the Apple/NeXT serialized plist. Requires a schema with CXML elements.
| dat | The binary data. | |
| s | The schema to use. |
References parsecompressed(), and string::strlen().

| bool value::fromjson | ( | const string & | j | ) |
Convert from a JSON-encoded string.
| j | JSON string. |
References string::cval().

| void value::fromplist | ( | const string & | dat | ) |
Convert from Apple's plist format.
Requires the com.apple.plist.schema.xml schema.
| dat | The text data. |
References fromxml().

| bool value::fromshox | ( | const string & | shox | ) |
Convert from SHOX string data.
| shox | The shox-encoded data. |
References string::bingetvint(), string::bingetvstr(), clear(), stringdict::get(), readshox(), string::strlen(), and t.
Referenced by dbfile::decode(), and loadshox().

Convert from string with XML data.
| d | The XML text data. | |
| s | The schema to use for parsing. NULL for none. |
References _type, arrayalloc, arraysz, attrib, xmlschema::containerhasattributes(), stack< kind >::count(), string::decode64(), exists(), xmlschema::hasnamespaces(), xmlschema::hasvalueattribute(), xmlschema::iscontainerclass(), xmlschema::isimplicitarray(), xmlschema::iswrap(), itype, xmlschema::knownclass(), string::mid(), name(), xmlschema::nstransattr(), xmlschema::nstranstype(), string::printf(), xmlschema::resolvecontainerenvelope(), xmlschema::resolvecontaineridclass(), xmlschema::resolvecontainervalueclass(), xmlschema::resolvecontainerwrapclass(), xmlschema::resolveid(), xmlschema::resolveindexname(), xmlschema::resolvetype(), xmlschema::resolveunionbase(), xmlschema::resolvevalueattribute(), setattrib(), setcurrency(), setip(), statstring::str(), string::str(), string::strcasecmp(), string::strcpy(), xmlschema::stringclassisbase64(), string::strlen(), sval(), statstring::sval(), type(), and strutil::xmlreadtag().
Referenced by cgi::cgi(), fromplist(), fromxml(), loadxml(), and httpdscriptparser::run().

| 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.
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().
| 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().

| 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.
Referenced by daemon::settargetgroups().
| bool value::ismixed | ( | void | ) | const |
| 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.
| sep | The separator between values | |
| left | Optional left delimiter string. | |
| right | Optional right delimiter stirng. |
References string::strcat().

| void value::load | ( | class file & | f | ) |
Load ASCII data from an already open file.
| 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().

| void value::load | ( | const string & | fname | ) |
Load data in plain ASCII format.
Does not support attributes.
| value::exception | Loading/parsing exception |
References file::openread().

Load from CSV format.
| 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().

| void value::loadplist | ( | const string & | fn | ) |
Load from Apple's plist format.
Requires the com.apple.plist.schema.xml schema.
| fn | File name to load. |
References loadxml().

| bool value::loadshox | ( | const string & | fname | ) |
Load from the SHOX object format.
| fname | Filename to load. |
References fromshox(), and filesystem::load().

Load from an XML file.
| path | The file name. | |
| s | The schema to be used for parsing. NULL for none. |
References fromxml(), filesystem::load(), string::strcpy(), and string::strlen().

Load from an XML file.
| 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().

| value & value::operator() | ( | const statstring & | ki | ) |
| void value::phpdeserialize | ( | const string & | phpdata | ) |
Deserialize PHP data.
| phpdata | A serialized PHP array. |
References string::str().
Referenced by phpdeserialize().

| string * value::phpserialize | ( | bool | withattr = false |
) | const |
Serialize to a PHP array.
| 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". |
References printphp().

| void value::rmattrib | ( | const statstring & | id | ) | [inline] |
| void value::rmval | ( | unsigned int | k, | |
| const char * | ks, | |||
| int | idx = -1 | |||
| ) |
Remove any child.
| 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.
| 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().

| void value::saveplist | ( | const string & | fn, | |
| bool | compact = false | |||
| ) |
Save in Apple's plist format.
Requires the com.apple.plist.schema.xml schema.
| fn | File name. | |
| compact | Either value::compact or value::nocompact. |
References savexml(), and type().

| bool value::saveshox | ( | const string & | fname, | |
| flag::savetype | tp = flag::normal | |||
| ) | const |
Save to the SHOX object format.
| 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().

| bool value::savexml | ( | const string & | fn, | |
| bool | compact, | |||
| class xmlschema & | schema, | |||
| flag::savetype | tp = flag::normal | |||
| ) | const |
Save in XML format.
| 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().

| bool value::savexml | ( | const string & | fn, | |
| flag::savetype | tp | |||
| ) | const |
| bool value::savexml | ( | const string & | fn, | |
| bool | compact, | |||
| flag::savetype | tp | |||
| ) | const |
Save in XML format.
| 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().

| bool value::savexml | ( | const string & | fn, | |
| bool | compact = false, |
|||
| class xmlschema * | schema = NULL, |
|||
| flag::savetype | tp = flag::normal | |||
| ) | const |
Save in XML format.
| 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().

| void value::setattrib | ( | const statstring & | ki, | |
| bool | val | |||
| ) |
| void value::setattrib | ( | const statstring & | ki, | |
| const char * | val | |||
| ) |
| void value::setattrib | ( | const statstring & | ki, | |
| int | val | |||
| ) |
| void value::setattrib | ( | const statstring & | ki, | |
| const string & | val | |||
| ) |
Directly set a keyed attribute.
| 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().

| 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 |
| 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().

| string * value::tocsv | ( | bool | withHeaders = true, |
|
| const char * | indexName = "id" | |||
| ) |
Convert to CSV format.
This export does not encode attributes.
| 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().

Convert to CXML.
Creates a string with a binary dump of the object and its children. Requires a schema with CXML elements.
| s | The schema to use. |
References printcompressed().

| string * value::toplist | ( | bool | compact = false |
) |
Convert to Apple's plist format.
Requires the com.apple.plist.schema.xml schema.
| compact | Either value::compact or value::nocompact. |
References toxml(), and type().

Convert to string containing XML data.
| compact | Set to value::compact or value::nocompact. | |
| schema | XML schema to apply. |
References toxml().

Convert to string containing XML data.
| 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().

| void value::type | ( | const dtenum & | t | ) | [inline] |
| 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"))
| const statstring & value::id |
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.
| 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().
1.6.1