libdas2
das2 core C utilities
|
Provides utilities for reading remote data source catalogs and caching their contents in RAM. More...
Provides utilities for reading remote data source catalogs and caching their contents in RAM.
There are two basic methods of catalog object acquisition, finding a node by it's path from the global root of the federated das2 catalog system: (ex: tag:das2.org,2012:site:/swri/mars_express/aspera3/sciels) or by an loading an explicit URL (ex: http://das2.org/catalog/das/site/uiowa/cassini/rpws/survey.json).
When describing the das2 catalog C-API there are two meanings for the word Root.
1) Memory Roots - A node can be the in-memory root of a linked list of nodes.
2) Global Root - Root can also refer to the global das2 top-level un-named node which resides at http://das2.org/catalog/index.json and it's mirrors.
Any node loaded using new_RootNode() or new_RootNode_url() is an in memory root node. It might not be the root of a federated catalog system, but it is still a top level memory item that manages a memory cache for it's subnodes. If new_RootNode() happens to be called with a URI of 'NULL' then the in-memory root corresponds to the federated catalog root. The reason for splitting the concept of the in-memory root from the global catalog root is to provide for isolated catalogs that are not part of the global system.
When you instantiate a node from a random URL you have to give it a name. Just like files on a disk, catalog nodes do not know their name, it is derived from the name provided by the higher level catalog entries (up to root, which has no name).
An Example of getting a data source interface definition follows:
You now have a JSON object providing the query definition see http://das2.org/datasource.html for more information on the content of das2 data source definitions.
For isolated sites, or for testing purposes catalog nodes can be loaded directly. The following example acquires a local test root and then a specific test node.
Data Structures | |
struct | das_json_str |
A JSON string value. More... | |
struct | das_json_str_ex |
A JSON string value (extended) More... | |
struct | das_json_num |
A JSON number value. More... | |
struct | das_json_dict_el |
An element of a JSON dictionary. More... | |
struct | das_json_dict |
a JSON dictionary payload More... | |
struct | das_json_ary_el |
an element of a JSON array More... | |
struct | das_json_ary |
a JSON array value More... | |
struct | DasJdo |
JSON Dom Element. More... | |
struct | das_json_val_ex |
a JSON value (extended) More... | |
struct | das_json_parse_result_s |
error report from json_parse_ex() More... | |
struct | DasNode |
Base type for das2 catalog nodes. More... | |
Functions | |
DasDesc * | dsdf_parse (const char *sFileName) |
Parse a DSDF file into a descriptor object. More... | |
double * | dsdf_valToArray (const char *sValue, size_t *pLen) |
Helper function to parse a DSDF value as a double array. More... | |
const char * | dsdf_setIdlBin (const char *sIdlBin) |
Set the location of the IDL binary. More... | |
char * | dsdf_valToNormParam (const char *sRawParam, char *sNormParam, size_t uNormLen) |
Normalize a general reader command line parameter set. More... | |
const char * | json_parse_error_info (const struct das_json_parse_result_s *pRes, char *sTmp, size_t uLen) |
Provide error string describing a parsing error result. | |
DasJdo * | das_json_parse_ex (const void *src, size_t src_size, size_t flags_bitset, void *(*alloc_func_ptr)(void *, size_t), void *user_data, struct das_json_parse_result_s *result) |
Parse a JSON text file, returning a pointer to the root of the JSON structure. More... | |
DasJdo * | das_json_parse (const void *src, size_t src_size) |
Parse a JSON text file with default options and without detailed error reporting. More... | |
const das_json_dict_el * | DasJdo_dictFirst (const DasJdo *pThis) |
Get the first dictionary element from a JSON dictionary. | |
const das_json_ary_el * | DasJdo_aryFirst (const DasJdo *pThis) |
Get the first array element from a JSON array. | |
const char * | DasJdo_string (const DasJdo *pThis) |
Get a string value from a JSON DOM element. More... | |
void * | DasJdo_writePretty (const DasJdo *pThis, const char *indent, const char *newline, size_t *out_size) |
Write out a pretty JSON utf-8 string. More... | |
const DasJdo * | DasJdo_get (const DasJdo *pThis, const char *sRelPath) |
Given a DOM path retrieve a JSON element. More... | |
void * | DasJdo_writeMinified (const DasJdo *pThis, size_t *out_size) |
Write out a minified JSON utf-8 string. More... | |
enum das_json_type_e |
The various types JSON values can be.
Used to identify what a value is
Flag useed by dasj_parse() and dasj_parse_ex() to alter parsing behavior.
enum das_jparse_error_e |
JSON parsing error codes.
DasDesc* dsdf_parse | ( | const char * | sFileName | ) |
Parse a DSDF file into a descriptor object.
This DSDF parser supports IDL continuation characters, which are '$' immediately followed by a newline (
). The total line buffer across all continuation lines is 22499 bytes long.
sFileName | - The DSDF file to open and parse |
double* dsdf_valToArray | ( | const char * | sValue, |
size_t * | pLen | ||
) |
Helper function to parse a DSDF value as a double array.
Certian Das1 DSDF values such as the y_coordinate contained executable IDL code instead of a simple array of values. If a global IDL executable has been set via dsdf_setIdlBin, then any arrays this function cannot parse will be handed by an IDL subprocess.
[in] | sValue | - The DSDF value to parse |
[out] | pLen | - a pointer to a size_t that will receive the length of the returned double array |
const char* dsdf_setIdlBin | ( | const char * | sIdlBin | ) |
Set the location of the IDL binary.
By default the library does not know how to find IDL, use this function to set the location of the idl startup program. Note that IDL is not needed when parsing Das 2.2 (or higher) compliant DSDF files. Only programs that read older Das1 DSDF files may have the need to call IDL.
char* dsdf_valToNormParam | ( | const char * | sRawParam, |
char * | sNormParam, | ||
size_t | uNormLen | ||
) |
Normalize a general reader command line parameter set.
The normalization rules are as follows:
0. If the raw parameter string is NULL or empty the string '_noparam' is copied into the norm-param buffer and the function returns.
[in] | sRawParam | - The parameter string to normalize |
[out] | sNormParam | - A buffer to hold the normalized parameter string |
[in] | uNormLen | - The length of the sNormParam buffer |
DasJdo* das_json_parse_ex | ( | const void * | src, |
size_t | src_size, | ||
size_t | flags_bitset, | ||
void *(*)(void *, size_t) | alloc_func_ptr, | ||
void * | user_data, | ||
struct das_json_parse_result_s * | result | ||
) |
Parse a JSON text file, returning a pointer to the root of the JSON structure.
src | a pointer to a utf-8 encoded JSON document, type is void* to emphasize that the data may contain byte values > 127. |
src_size | The size in bytes of the document string to parse |
flags_bitset | values from enum das_jparse_flags_e OR'ed together to configure parsing preferences. |
alloc_func_ptr | May be use to allocate memory via some method other than malloc. |
user_data | A user data pointer pto be passed as the first argument to alloc_func_ptr, if alloc_func_ptr is not NULL. |
result | (if not NULL) will explain the type of error, and the location in the input it occurred. |
DasJdo* das_json_parse | ( | const void * | src, |
size_t | src_size | ||
) |
Parse a JSON text file with default options and without detailed error reporting.
This is just shorthand for das_json_parse_ex(src, size, 0, NULL, NULL, NULL);
const char* DasJdo_string | ( | const DasJdo * | pThis | ) |
Get a string value from a JSON DOM element.
pThis | The element in question |
void* DasJdo_writePretty | ( | const DasJdo * | pThis, |
const char * | indent, | ||
const char * | newline, | ||
size_t * | out_size | ||
) |
Write out a pretty JSON utf-8 string.
This string is encoded such that the resultant JSON is pretty in that it is easily human readable. The indent and newline parameters allow a user to specify what kind of indentation and newline they want (two spaces / three spaces / tabs? ,
,
?). Both indent and newline can be NULL, indent defaults to two spaces (" "), and newline defaults to linux newlines ('
' as the newline character).
DasJdo_writePretty performs 1 call to malloc for the entire encoding.
Given a DOM path retrieve a JSON element.
pThis | |
sRelPath | Pointer to a utf-8 string providing a relative path to the sub object. This has the form: [STRING | INTEGER] [ / [STRING | INTEGER] [ / [STRING | INTEGER]]] For example: "cassini/ephemeris/CONTACTS/0/EMAIL". For Arrays sub items are denoted by ascii integers 0 - size, for dictionaries sub items can be denoted by either keys strings or by ascii integers. Objects of type string, number, true, false and null have no sub items |
void * DasJdo_writeMinified | ( | const DasJdo * | pThis, |
size_t * | out_size | ||
) |
Write out a minified JSON utf-8 string.
This string is an encoding of the minimal string characters required to still encode the same data. DasJdo_writeMinified performs 1 call to malloc for the entire encoding.
pThis | The top level document object to write, all sub-objects will be written as well. |
The out_size parameter is optional as the utf-8 string is null terminated.