libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
|
Contains the attributes for a dataset. More...
#include <AttrTable.h>
Classes | |
struct | entry |
Public Types | |
typedef std::vector< entry * >::const_iterator | Attr_citer |
typedef std::vector< entry * >::iterator | Attr_iter |
Public Member Functions | |
virtual AttrTable * | get_parent () const |
bool | is_dap4_type (const std::string &path, std::vector< std::string > &inventory) const |
virtual bool | is_global_attribute () const |
virtual void | set_is_global_attribute (bool ga) |
Accessors using an attribute name | |
Each of the following accessors get information using the name of an attribute. They perform a simple search for the name in this attribute table only; sub-tables are not searched and the dot notation is not recognized. | |
virtual AttrTable * | get_attr_table (const string &name) |
Get an attribute container. | |
virtual string | get_type (const string &name) |
Get the type name of an attribute within this attribute table. | |
virtual AttrType | get_attr_type (const string &name) |
Get the type of an attribute. | |
virtual unsigned int | get_attr_num (const string &name) |
Get the number of attributes in this container. | |
virtual vector< string > * | get_attr_vector (const string &name) |
Get a vector-valued attribute. | |
virtual void | del_attr (const string &name, int i=-1) |
Deletes an attribute. | |
Protected Member Functions | |
void | clone (const AttrTable &at) |
Friends | |
class | AttrTableTest |
Instance management functions | |
AttrTable () | |
AttrTable (const AttrTable &rhs) | |
virtual | ~AttrTable () |
AttrTable & | operator= (const AttrTable &rhs) |
virtual unsigned int | get_size () const |
Get the number of entries in this attribute table. | |
virtual string | get_name () const |
Get the name of this attribute table. | |
virtual void | set_name (const string &n) |
Set the name of this attribute table. | |
virtual unsigned int | append_attr (const string &name, const string &type, const string &value) |
Add an attribute to the table. | |
virtual unsigned int | append_attr (const string &name, const string &type, vector< string > *values) |
Add an attribute to the table. | |
virtual unsigned int | append_attr (const string &name, const string &type, const string &value, bool is_utf8_str) |
Add an attribute to the table. | |
virtual unsigned int | append_attr (const string &name, const string &type, vector< string > *values, bool is_utf8_str) |
Add an attribute to the table. | |
virtual AttrTable * | append_container (const string &name) |
Add a container to the attribute table. | |
virtual AttrTable * | append_container (AttrTable *at, const string &name) |
Add a container to the attribute table. | |
virtual void | find (const string &target, AttrTable **at, Attr_iter *iter) |
virtual AttrTable * | find_container (const string &target) |
Find an attribute with a given name. | |
virtual AttrTable * | recurrsive_find (const string &target, Attr_iter *location) |
Attr_iter | simple_find (const string &target) |
AttrTable * | simple_find_container (const string &target) |
get information using an iterator | |
void | simple_print (FILE *out, string pad, Attr_iter i, bool dereference) |
void | simple_print (ostream &out, string pad, Attr_iter i, bool dereference) |
virtual void | erase () |
Erase the attribute table. | |
virtual string | get_attr (const string &name, unsigned int i=0) |
virtual Attr_iter | attr_begin () |
virtual Attr_iter | attr_end () |
virtual Attr_iter | get_attr_iter (int i) |
virtual string | get_name (Attr_iter iter) |
virtual bool | is_container (Attr_iter iter) |
virtual AttrTable * | get_attr_table (Attr_iter iter) |
virtual Attr_iter | del_attr_table (Attr_iter iter) |
virtual string | get_type (Attr_iter iter) |
virtual AttrType | get_attr_type (Attr_iter iter) |
virtual unsigned int | get_attr_num (Attr_iter iter) |
virtual string | get_attr (Attr_iter iter, unsigned int i=0) |
virtual std::vector< string > * | get_attr_vector (Attr_iter iter) |
virtual bool | is_global_attribute (Attr_iter iter) |
virtual void | set_is_global_attribute (Attr_iter iter, bool ga) |
virtual void | add_container_alias (const string &name, AttrTable *src) |
Add an alias to a container held by this attribute table. | |
virtual void | add_value_alias (AttrTable *at, const string &name, const string &source) |
Add an alias for an attribute. | |
virtual bool | attr_alias (const string &alias, AttrTable *at, const string &name) |
Adds an alias to the set of attributes. | |
virtual bool | attr_alias (const string &alias, const string &name) |
bool | has_dap4_types (const std::string &path, std::vector< std::string > &inventory) const |
virtual void | print (FILE *out, string pad=" ", bool dereference=false) |
Prints the attribute table. | |
virtual void | print (ostream &out, string pad=" ", bool dereference=false) |
Prints the attribute table. | |
virtual void | print_xml (FILE *out, string pad=" ", bool constrained=false) |
virtual void | print_xml (ostream &out, string pad=" ", bool constrained=false) |
void | print_xml_writer (XMLWriter &xml) |
void | print_dap4 (XMLWriter &xml) |
virtual void | dump (ostream &strm) const |
dumps information about this object | |
Contains the attributes for a dataset.
An AttrTable (`‘Attribute Table’') stores a set of names and, for each name, either a type and a value, or another attribute table. The attribute value can be a vector containing many values of the same type. The attributes can have any of the types listed in the AttrType
list. However, all attribute types are stored as string data, except for the container type, which is stored as a pointer to another attribute table.
Each element in the attribute table can itself be an attribute table. The table can also contain `‘alias’' attributes whose value is given by the value of another attribute to which it is linked.
The attribute tables have a standard printed representation. There is a member function print()
for writing this form. Use the DAS::parse()
function to read the printed form.
An attribute table might look something like this:
string long_name "Weekly Means of Sea Surface Temperature"; actual_range { Float64 min -1.8; Float64 max 35.09; } string units "degC"; conversion_data { Float64 add_offset 0.; Float64 scale_factor 0.0099999998; } Int32 missing_value 32767;
Here, long_name
, units
, and missing_value
are simple attributes, and actual_range
and conversion_data
are container attributes containing other attribute tables.
Definition at line 150 of file AttrTable.h.
typedef std::vector<entry*>::const_iterator libdap::AttrTable::Attr_citer |
Definition at line 257 of file AttrTable.h.
typedef std::vector<entry*>::iterator libdap::AttrTable::Attr_iter |
Definition at line 258 of file AttrTable.h.
libdap::AttrTable::AttrTable | ( | ) |
Definition at line 210 of file AttrTable.cc.
libdap::AttrTable::AttrTable | ( | const AttrTable & | rhs | ) |
Definition at line 212 of file AttrTable.cc.
|
virtual |
Definition at line 222 of file AttrTable.cc.
Add an alias to a container held by this attribute table.
name | The name of the alias. May not use dot notation. |
src | The existing attribute container to alias. |
Error | if an attribute, container or alias called name already exists in this attribute table. |
Definition at line 963 of file AttrTable.cc.
|
virtual |
Add an alias for an attribute.
Assume source names an attribute value in some container. Add an alias name for that value in this object.
das | |
name | The name of the alias. May not use dot notation. |
source | The name of the attribute to alias. May use dot notation. |
Error | if the attribute table already contains an attribute, container or alias called name or if an attribute called source does not exist. |
Definition at line 997 of file AttrTable.cc.
|
virtual |
Add an attribute to the table.
If the given name already refers to an attribute, and the attribute has a value, the given value is appended to the attribute vector. Calling this function repeatedly is the way to append to an attribute vector.
The function throws an Error if the attribute is a container, or if the type of the input value does not match the existing attribute's type. Use append_container()
to add container attributes.
This method performs a simple search for name
in this attribute table only; sub-tables are not searched and the dot notation is not recognized.
name | The name of the attribute to add or modify. |
type | The type of the attribute to add or modify. |
value | The value to add to the attribute table. |
Definition at line 308 of file AttrTable.cc.
|
virtual |
Add an attribute to the table.
If the given name already refers to an attribute, and the attribute has a value, the given value is appended to the attribute vector. Calling this function repeatedly is the way to append to an attribute vector.
The function throws an Error if the attribute is a container, or if the type of the input value does not match the existing attribute's type. Use append_container()
to add container attributes.
This method performs a simple search for name
in this attribute table only; sub-tables are not searched and the dot notation is not recognized.
name | The name of the attribute to add or modify. |
type | The type of the attribute to add or modify. |
value | The value to add to the attribute table. |
is_utf8_str | The flag to indicate if this is a utf8 string. |
Definition at line 415 of file AttrTable.cc.
|
virtual |
Add an attribute to the table.
This version of append_attr() takes a vector<string> of values. If the given name already refers to an attribute, and the attribute has values, append the new values to the existing ones.
The function throws an Error if the attribute is a container, or if the type of the input value does not match the existing attribute's type. Use append_container()
to add container attributes.
This method performs a simple search for name
in this attribute table only; sub-tables are not searched and the dot notation is not recognized.
name | The name of the attribute to add or modify. |
type | The type of the attribute to add or modify. |
values | A vector of values. Note: The vector is COPIED, not stored. |
Definition at line 361 of file AttrTable.cc.
|
virtual |
Add an attribute to the table.
This version of append_attr() takes a vector<string> of values. If the given name already refers to an attribute, and the attribute has values, append the new values to the existing ones.
The function throws an Error if the attribute is a container, or if the type of the input value does not match the existing attribute's type. Use append_container()
to add container attributes.
This method performs a simple search for name
in this attribute table only; sub-tables are not searched and the dot notation is not recognized.
name | The name of the attribute to add or modify. |
type | The type of the attribute to add or modify. |
values | A vector of values. Note: The vector is COPIED, not stored. |
is_utf8_str | The flag to indicate if this is a utf8 string. |
Definition at line 471 of file AttrTable.cc.
Add a container to the attribute table.
Append a new attribute container to this attribute table. The new container is at
and its name is set to name
. If this attribute table already contains an attribute container called name
an exception is thrown.
at | A pointer to the new attribute table to append. |
name | The name of the new attribute table. |
Definition at line 545 of file AttrTable.cc.
Add a container to the attribute table.
Create and append an attribute container to this AttrTable. If this attribute table already contains an attribute container called name
an exception is thrown. Return a pointer to the new container.
name | The name of the container to create. |
Definition at line 517 of file AttrTable.cc.
|
virtual |
Adds an alias to the set of attributes.
Once an alias is inserted into an attribute table, reading the attributes for alias will return those stored for name.
Two forms for this function exist: one searches for name in the AttrTable referenced by at while the other uses this
. You can use DAS::get_attr_table()
to get the attribute table for an arbitrary name.
alias | The alias to insert into the attribute table. |
name | The name of the already-existing attribute to which the alias will refer. |
at | An attribute table in which to insert the alias. |
Definition at line 1069 of file AttrTable.cc.
alias | The alias to insert into the attribute table. |
name | The name of the already-existing attribute to which the alias will refer. |
Definition at line 1081 of file AttrTable.cc.
|
virtual |
Get an iterator to the first entry in this attribute table.
Definition at line 793 of file AttrTable.cc.
|
virtual |
Get an iterator to the end attribute table. Does not point to the last attribute in the table
Definition at line 798 of file AttrTable.cc.
|
protected |
Clone the given attribute table in this
. Protected.
Definition at line 182 of file AttrTable.cc.
|
virtual |
Deletes an attribute.
Delete the attribute named name
. If i
is given, and the attribute has a vector value, delete the i
$^th$ element of the vector.
You can use this function to delete container attributes, although the i
parameter has no meaning for that operation.
name | The name of the attribute to delete. This can be an attribute of any type, including containers. However, this method looks only in this attribute table and does not recognize the dot notation. |
i | If the named attribute is a vector, and i is non-negative, the i-th entry in the vector is deleted, and the array is repacked. If i equals -1 (the default), the entire attribute is deleted. |
Definition at line 759 of file AttrTable.cc.
|
virtual |
Delete the iterator. Since AttrTable stores pointers to AttrTable objects, the caller should be sure to delete the AttrTable itself. The caller will gain control of the AttrTable* located at get_attr_table(iter) prior to this call.
iter | points to the entry to be deleted. |
Definition at line 848 of file AttrTable.cc.
|
virtual |
dumps information about this object
Displays the pointer value of this instance and all attributes stored
strm | C++ i/o stream to dump the information to |
Implements libdap::DapObj.
Definition at line 1595 of file AttrTable.cc.
|
virtual |
Erase the attribute table.
Erase the entire attribute table. This returns an AttrTable to the empty state that's the same as the object generated by the null constructor.
Definition at line 1105 of file AttrTable.cc.
Look for an attribute or an attribute container. If used to search for an attribute container, this method returns the container's parent using the value-result parameter at
and a reference to the container using the iterator value-result parameter iter
. If used to search for an attribute, the attribute's container is returned using at
; the attribute itself can be accessed using the iterator iter
.
target | The name (using dot notation) of the attribute or container to find. |
at | A value-result used to return the attribute container in which target was found. Null if target was not found. |
iter | The iterator which will reference the attribute found. Can be used to access target from within at . References dim_end() within at if the attribute or container does not exist. |
Definition at line 586 of file AttrTable.cc.
Find an attribute with a given name.
Look in this attribute table for an attribute container named target
. The search starts at this attribute table; target
should use the dot notation to name containers held within children of this attribute table.
To search the entire DAS object, make sure to invoke this method from that object.
target | The attribute container to find. |
Definition at line 663 of file AttrTable.cc.
Returns the value of an attribute. If the attribute has a vector value, you can indicate which is the desired value with the index argument, i. If the argument is omitted, the first value is returned. If the attribute has only a single value, the index argument is ignored. If i is greater than the number of elements in the attribute, an error is produced.
All values in an attribute table are stored as string data. They may be converted to a more appropriate internal format by the calling program.
iter | Reference to an attribute |
i | The attribute value index, zero-based. Default value: 0 |
Definition at line 912 of file AttrTable.cc.
Definition at line 918 of file AttrTable.cc.
|
virtual |
Given an index i
, return the Attr_iter
to the corresponding element. This method provides a way to use all the methods that take an Attr_iter
using a simple integer index. Use the get_attr_num() or get_size() methods to determine how many items the AttrTable contains.
i | The index |
Definition at line 808 of file AttrTable.cc.
|
virtual |
If the attribute referenced by iter is a container attribute, this method returns the number of attributes in its attribute table. If the indicated attribute is not a container, the method returns the number of values for the attribute (1 for a scalar attribute, N for a vector attribute value).
iter | Reference to an attribute |
Definition at line 891 of file AttrTable.cc.
|
virtual |
Get the number of attributes in this container.
If the indicated attribute is a container attribute, this function returns the number of attributes in its attribute table. If the indicated attribute is not a container, the method returns the number of values for the attribute (1 for a scalar attribute, N for a vector attribute value).
Definition at line 721 of file AttrTable.cc.
Get the attribute container referenced by iter. If no such container exists, then return a reference to the end of the table.
iter | Reference to a table contained by this object. |
Definition at line 825 of file AttrTable.cc.
Get an attribute container.
Definition at line 699 of file AttrTable.cc.
Get the type of the attribute referenced by iter.
iter |
Definition at line 882 of file AttrTable.cc.
Get the type of an attribute.
AttrType
value describing the attribute. Definition at line 709 of file AttrTable.cc.
Returns a pointer to the vector of values associated with the attribute referenced by iterator iter.
Note that all values in an attribute table are stored as string data. They may be converted to a more appropriate internal format by the calling program.
iter | Reference to the Attribute. |
Definition at line 934 of file AttrTable.cc.
Get a vector-valued attribute.
Get a pointer to the vector of values associated with the attribute referenced by Pix p
or named name
.
Note that all values in an attribute table are stored as string data. They may be converted to a more appropriate internal format by the calling program.
Definition at line 738 of file AttrTable.cc.
|
virtual |
Get the name of this attribute table.
Definition at line 243 of file AttrTable.cc.
Returns the name of the attribute referenced by iter.
Definition at line 811 of file AttrTable.cc.
|
inlinevirtual |
Return a pointer to the AttrTable which holds this table (aka, its parent. If this AttrTable has no parent, this returns null.
Definition at line 298 of file AttrTable.h.
|
virtual |
Get the number of entries in this attribute table.
Attributes that are containers count as one attribute, as do attributes with both scalar and vector values.
Definition at line 239 of file AttrTable.cc.
Get the type name of an attribute referenced by iter.
iter | Reference to the Attribute. |
Definition at line 874 of file AttrTable.cc.
Get the type name of an attribute within this attribute table.
Definition at line 702 of file AttrTable.cc.
bool libdap::AttrTable::has_dap4_types | ( | const std::string & | path, |
std::vector< std::string > & | inventory ) const |
Checks the child Attributes for ones with dap4 types and, when found, adds a description of each to the inventory
path | |
inventory |
Definition at line 1089 of file AttrTable.cc.
|
virtual |
Returns true if the attribute referenced by i is a container.
Definition at line 818 of file AttrTable.cc.
bool libdap::AttrTable::is_dap4_type | ( | const std::string & | path, |
std::vector< std::string > & | inventory ) const |
|
inlinevirtual |
Definition at line 300 of file AttrTable.h.
|
virtual |
Definition at line 939 of file AttrTable.cc.
Definition at line 224 of file AttrTable.cc.
|
virtual |
Prints the attribute table.
Prints an ASCII representation of the attribute table to the indicated FILE pointer. The pad
argument is prefixed to each line of the output to provide control of indentation.
out | Print to the given output FILE. |
pad | Indent elements of a table using this string of spaces. By default this is a string of four spaces |
dereference | If true, follow aliases. Default is false. |
Definition at line 1327 of file AttrTable.cc.
Prints the attribute table.
Prints an ASCII representation of the attribute table to the indicated output stream. The pad
argument is prefixed to each line of the output to provide control of indentation.
out | Print to the given output stream. |
pad | Indent elements of a table using this string of spaces. By default this is a string of four spaces |
dereference | If true, follow aliases. Default is false. |
Definition at line 1368 of file AttrTable.cc.
void libdap::AttrTable::print_dap4 | ( | XMLWriter & | xml | ) |
Write the DAP4 XML representation for this attribute table. This method is used to build the DAP4 DMR response object.
xml | An XMLWriter that will do the serialization |
Definition at line 1586 of file AttrTable.cc.
|
virtual |
Print the attribute table in XML.
out | Destination |
pad | Indent lines of text/xml this much. Default is four spaces. |
constrained | Not used |
Definition at line 1392 of file AttrTable.cc.
|
virtual |
Definition at line 1456 of file AttrTable.cc.
void libdap::AttrTable::print_xml_writer | ( | XMLWriter & | xml | ) |
Print the attribute table in XML.
out | Destination stream |
pad | Indent lines of text/xml this much. Default is four spaces. |
constrained | Not used |
Definition at line 1502 of file AttrTable.cc.
|
virtual |
This method scans for attributes using recursion to look inside containers even when the name of the attribute is not fully qualified. It starts looking in itself and descends into its children depth first. It will find attributes and attribute containers.
target | Look for the attribute with this name. |
location | A value-result parameter. This returns an iterator to the attribute within the returned AttrTable object |
Definition at line 614 of file AttrTable.cc.
|
virtual |
Definition at line 947 of file AttrTable.cc.
|
inlinevirtual |
Definition at line 301 of file AttrTable.h.
|
virtual |
Set the name of this attribute table.
n | The new name of the attribute table. |
Definition at line 247 of file AttrTable.cc.
AttrTable::Attr_iter libdap::AttrTable::simple_find | ( | const string & | target | ) |
Definition at line 677 of file AttrTable.cc.
|
protected |
A simple printer that does nothing fancy with aliases. Protected.
Definition at line 1178 of file AttrTable.cc.
|
protected |
A simple printer that does nothing fancy with aliases. Protected.
Definition at line 1247 of file AttrTable.cc.
|
friend |
Definition at line 275 of file AttrTable.h.