Laxkit  0.0.7.1
Public Member Functions | Public Attributes | Protected Attributes
Laxkit::Tagged Class Reference

class to help implement simple tagging and tag querying system. More...

Inheritance diagram for Laxkit::Tagged:
Inheritance graph
[legend]

List of all members.

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 charGetTag (int i)
 Return const pointer to the tag text for tag number i, where i==0 is the first tag.
virtual charGetAllTags ()
 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< charlist_of_tags

Detailed Description

class to help implement simple tagging and tag querying system.

Store a list of tags in char[] strings.

Todo:
make some sort of tag manager, with special functions to build a tag cloud database, links to the tagged objects, be able to search by tag, and substitute tag aliases..

Member Function Documentation

char * Laxkit::Tagged::GetAllTags ( )
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().

const char * Laxkit::Tagged::GetTag ( int  i)
virtual

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().

int Laxkit::Tagged::HasTag ( const char tag,
int  casematters 
)
virtual

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().

int Laxkit::Tagged::InsertTag ( const char tag,
int  casematters 
)
virtual

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().

int Laxkit::Tagged::InsertTags ( const char tags,
int  casematters 
)
virtual

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().

int Laxkit::Tagged::RemoveTag ( const char tag)
virtual

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().

int Laxkit::Tagged::RemoveTag ( int  i)
virtual

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().


The documentation for this class was generated from the following files:

Mon Feb 17 2014 11:53:00, Laxkit