136 const std::string &name()
const;
172 Tag *add_child(
int id);
173 Tag *add_child(
const std::string &name);
174 void delete_child(
Tag *tag);
176 Tag *find_child(
int id,
Tag *after = NULL)
const;
177 Tag *find_child(
const std::string &name,
Tag *after = NULL)
const;
178 Tag *find_child(
int id,
int attId,
Tag *after = NULL)
const;
179 Tag *find_child(
const std::string &name,
const std::string &attName,
Tag *after = NULL)
const;
180 Tag *find_child(
int id,
int attId,
const std::string &
value,
Tag *after = NULL)
const;
181 Tag *find_child(
const std::string &name,
const std::string &attName,
const std::string &value,
Tag *after = NULL)
const;
188 const std::string &
text()
const {
return _text;}
209 void attribute(
int att_id);
210 void attribute(
int att_id,
const std::string &value);
211 void delete_attribute(
int attId);
213 void attribute(
const std::string &name);
214 void attribute(
const std::string &name,
const std::string &value);
215 void delete_attribute(
const std::string &name);
218 TagAttribute *find_attribute(
const std::string &name)
const;
220 std::string attribute_value(
int att_id)
const;
221 std::string attribute_value(
const std::string &name)
const;
250 int tag_id(
const std::string &name);
251 const std::string &tag_name(
int id)
const;
252 int tag_id_if_exists(
const std::string &name)
const;
254 int attribute_id(
const std::string &name);
255 int attribute_id_if_exists(
const std::string &name)
const;
256 const std::string &attribute_name(
int id)
const;
258 void write_tag(std::ostream &os,
Tag *tag,
int indent = 0);
259 void read_tag(std::istream &is);
263 void write_string(std::ostream &os,
const std::string &text);
264 char read_string(std::istream &is, std::string &text);
265 char read_name(std::istream &is, std::string &name);
288 enum Cause {None, EmptyFile, ErrorReading, EndTagNotMatch,
289 InvalidTagStartChar, InvalidTagEndChar,
290 InvalidNameEnd, MissingTagName,
291 InvalidStringStart, InvalidStringEnd, InvalidEntityEnd, InvalidEntity
305 const std::string &
item()
const {
return _item;}
308 static std::string error_text(
Cause cause, std::string item);
318 std::ostream &operator<<(std::ostream &os,
tbx::TagDoc &doc);
Tag * parent() const
Get the parent for this tag.
Definition: tag.h:144
TagData * _data
user data or 0 if none
Definition: tag.h:232
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:34
Exception thrown when reading a saved tag fails.
Definition: tag.h:282
Document that stores Tags with optional attributes in a hierarchy.
Definition: tag.h:244
const std::string & text() const
Get the text from the tag.
Definition: tag.h:188
void data(TagData *data)
Set the data for this tag.
Definition: tag.h:207
Helper classes to create a document based application.
void text(const std::string &text)
Set the text for this tag.
Definition: tag.h:194
bool _has_value
true if attribute has a value
Definition: tag.h:96
Cause cause() const
Return enumeration value specifying the cause of the exception.
Definition: tag.h:300
const std::string & item() const
Return the item or character the exception happened on.
Definition: tag.h:305
std::string _text
text for this type of tag or "" if not set
Definition: tag.h:231
TagAttribute * next()
Get the next attribute for the same tag.
Definition: tag.h:91
int integer() const
Return the current value as an integer.
Definition: tag.h:65
Base class used for adding data to a tag.
Definition: tag.h:106
TagAttribute(int id)
Construct an attribute without a value.
Definition: tag.cc:62
Tag * next() const
Get the next sibling tag.
Definition: tag.h:163
TagAttribute * _next
Next attribute for the same tag.
Definition: tag.h:97
Tag * _parent
parent tag or 0 for no parent
Definition: tag.h:224
int id() const
Return the tag id.
Definition: tag.h:135
int _id
ID for this type of tag.
Definition: tag.h:230
const std::string & value()
Get the current string value for the attribute.
Definition: tag.h:59
Tag * last_child() const
Get the last child tag.
Definition: tag.h:157
Cause
Enumeration describing the reason for a tag exception.
Definition: tag.h:288
Tag * _first_child
first child tag or 0 for no children
Definition: tag.h:225
TagData * data() const
Get the user data for this tag.
Definition: tag.h:201
TagAttribute * _first_attribute
first attribute or 0 if no attributes
Definition: tag.h:228
Tag * first_child() const
Get the first child tag.
Definition: tag.h:151
bool has_value() const
Check if the attribute has a value.
Definition: tag.h:84
Class to represent a some data tagged with an id.
Definition: tag.h:123
Tag * _last_child
last child tag or 0 for no children
Definition: tag.h:226
int _id
Id of attribute.
Definition: tag.h:94
int id() const
Attribute Id.
Definition: tag.h:54
std::vector< std::string > _attribute_names
List of all attribute names known to this document.
Definition: tag.h:275
std::vector< std::string > _tag_names
List of all tag names known to this document.
Definition: tag.h:271
void has_value(bool has)
Set if the attribute has a value associated with it.
Definition: tag.h:78
TagAttribute * first_attribute() const
Get the first attribute of this tag.
Definition: tag.h:170
void value(const std::string &value)
Set the value of the attribute.
Definition: tag.h:71
Class to represent a single attribute.
Definition: tag.h:43
Tag * _next
next sibling tag or 0 if no more siblings
Definition: tag.h:227
std::string _value
Value of attribute (if any)
Definition: tag.h:95