Laxkit
0.0.7.1
|
class to help implement simple tagging and tag querying system. More...
Public Member Functions | |
virtual int | HasTag (const char *tag, int casematters) |
Return whether the tag exists. | |
virtual int | NumberOfTags () |
Return the number of tags, strangely enough. | |
virtual const char * | GetTag (int i) |
Return const pointer to the tag text for tag number i, where i==0 is the first tag. | |
virtual char * | GetAllTags () |
Return a new char[] with a space separated list of all the tags. | |
virtual int | InsertTags (const char *tags, int casematters) |
Insert tags from a string such as 'tag1 tag2 tag3 "tag with spaces" tag4'. | |
virtual int | InsertTag (const char *tag, int casematters) |
Insert tag if it doesn't exist already. | |
virtual int | RemoveTag (const char *tag) |
The tag must be an exact match. | |
virtual int | RemoveTag (int i) |
Remove tag number i. i must be in range [0..NumberOfTags()-1]. | |
virtual void | FlushTags () |
Public Attributes | |
int | sorttags |
Protected Attributes | |
PtrStack< char > | list_of_tags |
class to help implement simple tagging and tag querying system.
Store a list of tags in char[] strings.
|
virtual |
Return a new char[] with a space separated list of all the tags.
If any tag has whitespace in it, it is put in quotes and the white space is escaped, if necessary.
References appendstr(), GetTag(), Laxkit::PtrStack< T >::n, and NumberOfTags().
Return const pointer to the tag text for tag number i, where i==0 is the first tag.
i must be in range [0..NumberOfTags()-1]. If i is out of bounds, then return NULL.
References Laxkit::PtrStack< T >::e, and Laxkit::PtrStack< T >::n.
Referenced by Laxkit::TagCloud::AddObject(), and GetAllTags().
Return whether the tag exists.
casematters== -1 for might not care, 0=it does not matter, 1=it does matter.
If the tag is not found, then return 0.
If casematters==1, then return the index+1 of the tag when the tag matches exactly, otherwise 0. If casematters==0, then return the index+1 of the tag when the tag matches ignoring case, otherwise 0. If casematters==-1, then if there is an exact match, return the index+1 of the tag. If there is a match only ignoring case, then return the index+1 of the tag times -1, otherwise 0.
References Laxkit::PtrStack< T >::e, and Laxkit::PtrStack< T >::n.
Referenced by Laxkit::TagCloud::AddObject(), InsertTag(), Laxkit::TagCloud::RemoveObject(), and RemoveTag().
Insert tag if it doesn't exist already.
Will insert ONLY if the tag does not exist there .......
Returns the index of the tag.
If tag didn't exist, it is added, and its index is returned.
References Laxkit::PtrStack< T >::e, HasTag(), Laxkit::PtrStack< T >::n, newstr(), and Laxkit::PtrStack< T >::push().
Referenced by Laxkit::TagCloud::AddObject(), and InsertTags().
Insert tags from a string such as 'tag1 tag2 tag3 "tag with spaces" tag4'.
Returns the number of tags inserted.
References InsertTag(), isblank(), and LaxFiles::QuotedAttribute().
The tag must be an exact match.
Return 0 for tag removed. -1 for tag not found, 1 for other error and tag not removed.
References HasTag(), and Laxkit::PtrStack< T >::remove().
Referenced by Laxkit::TagCloud::RemoveTag().
Remove tag number i. i must be in range [0..NumberOfTags()-1].
Return 0 for tag removed. -1 for tag not found, 1 for other error and tag not removed.
Reimplemented in Laxkit::TagCloud.
References NumberOfTags(), and Laxkit::PtrStack< T >::remove().