libyui
Public Member Functions | Protected Member Functions | Protected Attributes

YStringTree Class Reference

#include <YStringTree.h>

Inheritance diagram for YStringTree:
YRpmGroupsTree

List of all members.

Public Member Functions

 YStringTree (const char *textdomain)
virtual ~YStringTree ()
YStringTreeItemaddBranch (const string &content, char delimiter=0, YStringTreeItem *parent=0)
string origPath (const YStringTreeItem *item, char delimiter, bool startWithDelimiter=true)
string translatedPath (const YStringTreeItem *item, char delimiter, bool startWithDelimiter=true)
YTransText path (const YStringTreeItem *item, char delimiter, bool startWithDelimiter=true)
void logTree ()
YStringTreeItemroot () const
const char * textdomain () const
void setTextdomain (const char *domain)
string translate (const string &orig)

Protected Member Functions

string completePath (const YStringTreeItem *item, bool translated, char delimiter, bool startWithDelimiter)
void logBranch (YStringTreeItem *branch, string indentation)

Protected Attributes

YStringTreeItem_root
string _textdomain

Detailed Description

Abstract base class for filter views with hierarchical filter criteria - e.g., RPM group tags, MIME types.


Constructor & Destructor Documentation

YStringTree::YStringTree ( const char *  textdomain)

Constructor.

'textdomain' specifies the gettext textdomain to use to translate pathname components as new branches are added.

NOTE: This will NOT change the gettext environment in any way - the tree uses dgettext() internally. The caller is responsible to bind that textdomain to a message catalog (bindtextdomain() etc.).

YStringTree::~YStringTree ( ) [virtual]

Destructor.


Member Function Documentation

YStringTreeItem * YStringTree::addBranch ( const string &  content,
char  delimiter = 0,
YStringTreeItem parent = 0 
)

Add a unique new branch with text content 'content' to the tree, beginning at 'parent' (root if parent == 0). This content can be a path specification delimited with character 'delimiter' (if not 0), i.e. this method will split 'content' up into path components and insert tree items for each level as appropriate. Leading delimiters will be ignored. If 'delimiter' is 0, 'content' is not split but used 'as is'. Items are automatically sorted alphabetically. Pathname components are automatically translated using the textdomain specified in the constructor.

Returns the tree node for this branch - either newly created or the existing one.

Example: addBranch( "/usr/local/bin", '/' ) addBranch( "/usr/lib", '/' )

"usr" "lib" "local" "bin"

string YStringTree::completePath ( const YStringTreeItem item,
bool  translated,
char  delimiter,
bool  startWithDelimiter 
) [protected]

Construct a complete original or translated path for the specified tree item. 'startWithDelimiter' specifies whether or not the complete path should start with the delimiter character.

void YStringTree::logBranch ( YStringTreeItem branch,
string  indentation 
) [protected]

Debugging - dump one branch of the tree into the log file.

void YStringTree::logTree ( )

Debugging - dump the tree into the log file.

string YStringTree::origPath ( const YStringTreeItem item,
char  delimiter,
bool  startWithDelimiter = true 
) [inline]

Construct a complete original path for the specified tree item. 'startWithDelimiter' specifies whether or not the complete path should start with the delimiter character.

YTransText YStringTree::path ( const YStringTreeItem item,
char  delimiter,
bool  startWithDelimiter = true 
)

Construct a complete path (both original and translated) for the specified tree item. 'startWithDelimiter' specifies whether or not the complete path should start with the delimiter character.

Note: origPath() or translatedPath() are much cheaper if only one version (original or translated) is required.

YStringTreeItem* YStringTree::root ( ) const [inline]

Returns the root of the filter view tree. Note: In most cases, the root item itself will not contain any useful information. Consider it the handle for the entire tree, not an actual data element.

void YStringTree::setTextdomain ( const char *  domain) [inline]

Set the textdomain used internally for translation of pathname components.

NOTE: This will NOT change the gettext environment in any way - the tree uses dgettext() internally. The caller is responsible to bind that textdomain to a message catalog (bindtextdomain() etc.).

const char* YStringTree::textdomain ( ) const [inline]

Returns the textdomain used internally for translation of pathname components.

string YStringTree::translate ( const string &  orig)

Translate message 'orig' using the internal textdomain. Returns the translated text or the original if there is no translation.

string YStringTree::translatedPath ( const YStringTreeItem item,
char  delimiter,
bool  startWithDelimiter = true 
) [inline]

Construct a complete original path for the specified tree item. 'startWithDelimiter' specifies whether or not the complete path should start with the delimiter character.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations Friends