In file AttrTable.h:

class AttrTable

Holds a table of Attributes.

Public Methods

AttrTable& operator=(const AttrTable &rhs)
Assignment for attribute tables
unsigned int get_size()
Returns the number of entries in this attribute table
Pix first_attr()
Returns a pointer to the first element of this attribute table
void next_attr(Pix &p)
Advance the pointer to the next element of this attribute table
string get_name(Pix p)
Returns the name of the attribute
bool is_container(Pix p)
Returns true if the attribute is a container
AttrTable* append_container(const string &name)
Create a new container attribute.
void del_attr(const string &name, int i = -1)
Deletes an attribute.
void print(ostream &os, string pad = " ")
Prints the attribute table.

Public

get\_attr\_table()
Returns an attribute sub-table.
AttrTable* get_attr_table(Pix p)
AttrTable* get_attr_table(const string &name)
AttrTable* get_attr_table(const char *name)
get\_type()
Returns the type of an attribute in a string
string get_type(Pix p)
string get_type(const string &name)
string get_type(const char *name)
get\_attr\_type()
Returns the type of an attribute using AttrType
AttrType get_attr_type(Pix p)
AttrType get_attr_type(const string &name)
AttrType get_attr_type(const char *name)
get\_attr\_num()
Returns the number of values for the referenced attribute.
unsigned int get_attr_num(Pix p)
unsigned int get_attr_num(const string &name)
unsigned int get_attr_num(const char *name)
get\_attr()
Returns the value of an attribute
string get_attr(Pix p, unsigned int i = 0)
string get_attr(const string &name, unsigned int i = 0)
string get_attr(const char *name, unsigned int i = 0)
get\_attr\_vector()
Returns a vector attribute.
vector * get_attr_vector(Pix p)
vector * get_attr_vector(const string &name)
vector * get_attr_vector(const char *name)
append\_attr()
Adds an attribute to the table
unsigned int append_attr(const string &name, const string &type, const string &value)
unsigned int append_attr(const char *name, const char *type, const char *value)
attr\_alias()
Adds an alias to the set of attributes
bool attr_alias(const string &alias, AttrTable *at, const string &name)
bool attr_alias(const string &alias, const string &name)

Protected Methods

void clone(const AttrTable &at)
Clone the given attribtue table in #this#

Documentation

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: \begin{verbatim} 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; \end{verbatim} Here, #long_name#, #units#, and #missing_value# are simple attributes, and #actual_range# and #conversion_data# are container attributes containing other attribute tables.
void clone(const AttrTable &at)
Clone the given attribtue table in #this#

AttrTable& operator=(const AttrTable &rhs)
Assignment for attribute tables

unsigned int get_size()
Returns the number of entries in this attribute table. Attributes that are containers count one attribute, as do attributes with both scalar and vector values.

Pix first_attr()
Returns a pointer to the first element of this attribute table

void next_attr(Pix &p)
Advance the pointer to the next element of this attribute table

string get_name(Pix p)
Returns the name of the attribute

bool is_container(Pix p)
Returns true if the attribute is a container

get\_attr\_table()
Returns a pointer to the attribute table for the attribute referenced by {\it p} or named {\it name} only if the attribute is a container attribute. If there is no such attribute table, or if the table is not a container, the function returns null.

AttrTable* get_attr_table(Pix p)

AttrTable* get_attr_table(const string &name)

AttrTable* get_attr_table(const char *name)

get\_type()
Returns the type of an attribute in a string.

string get_type(Pix p)

string get_type(const string &name)

string get_type(const char *name)

get\_attr\_type()
Returns the type of an attribute using AttrType.
See Also:
AttrType

AttrType get_attr_type(Pix p)

AttrType get_attr_type(const string &name)

AttrType get_attr_type(const char *name)

get\_attr\_num()
If the indicated attribute is a container attribute, this function returns the number of attributes in {\it 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).

unsigned int get_attr_num(Pix p)

unsigned int get_attr_num(const string &name)

unsigned int get_attr_num(const char *name)

get\_attr()
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, {\it 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 {\it i} is greater than the number of elements in the attribute, an error is produced. 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.
Returns:
If the indicated attribute is a container, this function returns the string ``None''. If using a name to refer to the attribute and the named attribute does not exist, return the empty string.

string get_attr(Pix p, unsigned int i = 0)

string get_attr(const string &name, unsigned int i = 0)

string get_attr(const char *name, unsigned int i = 0)

get\_attr\_vector()
Returns a pointer to the vector of values associated with the attribute referenced by Pix {\it p} or named {\it 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.
Returns:
If the indicated attribute is a container, this function returns the null pointer. Otherwise returns a pointer to the the attribute vector value.

vector * get_attr_vector(Pix p)

vector * get_attr_vector(const string &name)

vector * get_attr_vector(const char *name)

append\_attr()
Adds an attribute to the table. If the given name already refers to an attribute, and the attribute has a vector value, the given value is appended to the attribute vector. Calling this function repeatedly is the way to create an attribute vector. The function returns an error condition 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.
Returns:
Returns the length of the added attribute value, or zero for failure.
Parameters:
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.

unsigned int append_attr(const string &name, const string &type, const string &value)

unsigned int append_attr(const char *name, const char *type, const char *value)

AttrTable* append_container(const string &name)
Create and append an attribute container to the AttrTable object. A container is an attribute that contains other attributes. That is, it is another attribute table.
Returns:
A pointer to the new AttrTable object.

attr\_alias()
Adds an alias to the set of attributes. Once an alias is inserted into an attribute table, reading the attributes for {\it alias} will return those stored for {\it name}. Two forms for this function exist: one searches for {\it name} in the AttrTable referenced by {\it at} while the other uses #this#. You can use #DAS::get_attr_table()# to get the attribute table for an arbitrary name.
See Also:
get_attr_table

bool attr_alias(const string &alias, AttrTable *at, const string &name)
Parameters:
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.

bool attr_alias(const string &alias, const string &name)
Parameters:
alias - The alias to insert into the attribute table.
name - The name of the already-existing attribute to which the alias will refer.

void del_attr(const string &name, int i = -1)
Delete the attribute named {\it name}. If {\it 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 {\it i} parameter has no meaning for that operation.
Parameters:
name - The name of the attribute to delete. This can be an attribute of any type, including containers.
i - If the named attribute is a vector, and {\it i} is non-negative, the i-th entry in the vector is deleted, and the array is repacked. If {\it i} equals -1 (the default), the entire attribute is deleted.

void print(ostream &os, string pad = " ")
Prints an ASCII representation of the attribute table to the indicated output stream. The {\it pad} argument is prefixed to each line of the output to provide control of indentation.


This class has no child classes.
See Also:
DAS
AttrType

alphabetic index hierarchy of classes


generated by doc++