tbx
0.7.3
|
Class to represent a some data tagged with an id. More...
#include <tag.h>
Public Member Functions | |
int | id () const |
Return the tag id. More... | |
const std::string & | name () const |
Return the name of this type of tag. | |
TagDoc * | doc () const |
Return the document this tag belongs to. | |
Tag * | parent () const |
Get the parent for this tag. More... | |
Tag * | first_child () const |
Get the first child tag. More... | |
Tag * | last_child () const |
Get the last child tag. More... | |
Tag * | next () const |
Get the next sibling tag. More... | |
TagAttribute * | first_attribute () const |
Get the first attribute of this tag. More... | |
Tag * | add_child (int id) |
Add a new tag as a child of this tag. More... | |
Tag * | add_child (const std::string &name) |
Add a new tag with the given name as a child of this tag. More... | |
void | delete_child (Tag *tag) |
Deletes at child tag. More... | |
Tag * | find_child (int id, Tag *after=NULL) const |
Find the a child tag with the given id. More... | |
Tag * | find_child (const std::string &name, Tag *after=NULL) const |
Find the a child tag with the given name. More... | |
Tag * | find_child (int id, int attId, Tag *after=NULL) const |
Find a child tag with the given attribute. More... | |
Tag * | find_child (const std::string &name, const std::string &attName, Tag *after=NULL) const |
Find a child tag with the given attribute. More... | |
Tag * | find_child (int id, int attId, const std::string &value, Tag *after=NULL) const |
Find a child tag with the given attribute value. More... | |
Tag * | find_child (const std::string &name, const std::string &attName, const std::string &value, Tag *after=NULL) const |
Find a child tag with the given attribute value. More... | |
const std::string & | text () const |
Get the text from the tag. More... | |
void | text (const std::string &text) |
Set the text for this tag. More... | |
TagData * | data () const |
Get the user data for this tag. More... | |
void | data (TagData *data) |
Set the data for this tag. More... | |
void | attribute (int att_id) |
Sets attribute with given id on the tag with no value. More... | |
void | attribute (int att_id, const std::string &value) |
Sets attribute with given id on the tag with the given value. More... | |
void | delete_attribute (int attId) |
Delete the attribute with the given id. More... | |
void | attribute (const std::string &name) |
Sets attribute with given name on the tag with no value. More... | |
void | attribute (const std::string &name, const std::string &value) |
Sets attribute with given name on the tag with the given value. More... | |
void | delete_attribute (const std::string &name) |
Delete the named attribute. More... | |
TagAttribute * | find_attribute (int att_id) const |
Find the attribute with the given id. More... | |
TagAttribute * | find_attribute (const std::string &name) const |
Find the attribute with the given id. More... | |
std::string | attribute_value (int att_id) const |
Get the value of an attribute. More... | |
std::string | attribute_value (const std::string &name) const |
Get the value of an attribute. More... | |
Protected Member Functions | |
Tag (Tag *parent, int id) | |
Construct a tag with the given parent and id. More... | |
~Tag () | |
Destructor for tag deletes assosiated tag data. | |
Protected Attributes | |
Tag * | _parent |
parent tag or 0 for no parent | |
Tag * | _first_child |
first child tag or 0 for no children | |
Tag * | _last_child |
last child tag or 0 for no children | |
Tag * | _next |
next sibling tag or 0 if no more siblings | |
TagAttribute * | _first_attribute |
first attribute or 0 if no attributes | |
int | _id |
ID for this type of tag. | |
std::string | _text |
text for this type of tag or "" if not set | |
TagData * | _data |
user data or 0 if none | |
Class to represent a some data tagged with an id.
The tag can optionally have: text a pointer to some data derived from TagData one or more attributes.
Tags are created by adding them to their parent. Initially this will be a TagDoc.
|
protected |
Construct a tag with the given parent and id.
parent | parent of the tag |
id | ID of name of this type of tag |
Tag * Tag::add_child | ( | int | id | ) |
Add a new tag as a child of this tag.
id | - tag id - must have been returned from TagDoc::tag_id |
Tag * Tag::add_child | ( | const std::string & | name | ) |
Add a new tag with the given name as a child of this tag.
name | - name for the tag. If it the name does not exists in the document it is added to it. |
void Tag::attribute | ( | int | att_id | ) |
Sets attribute with given id on the tag with no value.
i.e. TagAttribute::has_value() == false Creates the attribute if it doesn't already exists
att_id | attribute id, must have been allocated with TagDoc::attribute_id |
void Tag::attribute | ( | int | att_id, |
const std::string & | value | ||
) |
Sets attribute with given id on the tag with the given value.
Creates the attribute if it doesn't already exists
att_id | attribute id, must have been allocated with TagDoc::attribute_id |
value | string value for the attribute |
void Tag::attribute | ( | const std::string & | name | ) |
Sets attribute with given name on the tag with no value.
i.e. TagAttribute::has_value() == false
Adds the attribute name to the list of attribute names if it doesn't already exists Creates the attribute if it doesn't already exists
name | attribute name |
void Tag::attribute | ( | const std::string & | name, |
const std::string & | value | ||
) |
Sets attribute with given name on the tag with the given value.
Adds the attribute name to the list of attribute names if it doesn't already exists Creates the attribute if it doesn't already exists
name | attribute name |
value | string value for attribute |
std::string Tag::attribute_value | ( | int | att_id | ) | const |
Get the value of an attribute.
att_id | id of the attribute |
std::string Tag::attribute_value | ( | const std::string & | name | ) | const |
Get the value of an attribute.
name | name of the attribute |
|
inline |
Get the user data for this tag.
|
inline |
Set the data for this tag.
data | new data for the tag |
void Tag::delete_attribute | ( | int | att_id | ) |
Delete the attribute with the given id.
att_id | attribute id, must have been allocated with TagDoc::attribute_id |
void Tag::delete_attribute | ( | const std::string & | name | ) |
Delete the named attribute.
name | attribute name |
void Tag::delete_child | ( | Tag * | tag | ) |
Deletes at child tag.
tag | tag to delete. |
TagAttribute * Tag::find_attribute | ( | int | att_id | ) | const |
Find the attribute with the given id.
att_id | attribute id, must have been allocated with TagDoc::attribute_id |
TagAttribute * Tag::find_attribute | ( | const std::string & | name | ) | const |
Find the attribute with the given id.
name | attribute name |
Find the a child tag with the given id.
id | tag id to search for |
after | tag to start search after or 0 to start from the beginning |
Find the a child tag with the given name.
name | tag name to search for |
after | tag to start search after or 0 to start from the beginning |
Find a child tag with the given attribute.
id | tag id to search for |
att_id | attribute id for attribute tag must have |
after | tag to start search after or 0 to start from the beginning |
Tag * Tag::find_child | ( | const std::string & | name, |
const std::string & | att_name, | ||
Tag * | after = NULL |
||
) | const |
Find a child tag with the given attribute.
name | tag name to search for |
att_name | attribute name for attribute tag must have |
after | tag to start search after or 0 to start from the beginning |
Find a child tag with the given attribute value.
id | tag id to search for |
att_id | attribute id for attribute tag must have |
value | value to search for |
after | tag to start search after or 0 to start from the beginning |
Tag * Tag::find_child | ( | const std::string & | name, |
const std::string & | att_name, | ||
const std::string & | value, | ||
Tag * | after = NULL |
||
) | const |
Find a child tag with the given attribute value.
name | tag name to search for |
att_name | attribute name for attribute tag must have |
value | value to search for |
after | tag to start search after or 0 to start from the beginning |
|
inline |
Get the first attribute of this tag.
|
inline |
Get the first child tag.
|
inline |
Return the tag id.
|
inline |
Get the last child tag.
|
inline |
Get the next sibling tag.
|
inline |
Get the parent for this tag.
|
inline |
Get the text from the tag.
|
inline |
Set the text for this tag.
text | new text for the tag |