libyui  3.3.2
YStringTree Class Reference

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

#include <YStringTree.h>

Inheritance diagram for YStringTree:
Collaboration diagram for YStringTree:

Public Member Functions

 YStringTree (const char *textdomain)
 Constructor. More...
 
virtual ~YStringTree ()
 Destructor.
 
YStringTreeItemaddBranch (const std::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). More...
 
std::string origPath (const YStringTreeItem *item, char delimiter, bool startWithDelimiter=true)
 Construct a complete original path for the specified tree item. More...
 
std::string translatedPath (const YStringTreeItem *item, char delimiter, bool startWithDelimiter=true)
 Construct a complete original path for the specified tree item. More...
 
YTransText path (const YStringTreeItem *item, char delimiter, bool startWithDelimiter=true)
 Construct a complete path (both original and translated) for the specified tree item. More...
 
void logTree ()
 Debugging - dump the tree into the log file.
 
YStringTreeItemroot () const
 Returns the root of the filter view tree. More...
 
const char * textdomain () const
 Returns the textdomain used internally for translation of pathname components.
 
void setTextdomain (const char *domain)
 Set the textdomain used internally for translation of pathname components. More...
 
std::string translate (const std::string &orig)
 Translate message 'orig' using the internal textdomain. More...
 

Protected Member Functions

std::string completePath (const YStringTreeItem *item, bool translated, char delimiter, bool startWithDelimiter)
 Construct a complete original or translated path for the specified tree item. More...
 
void logBranch (YStringTreeItem *branch, std::string indentation)
 Debugging - dump one branch of the tree into the log file.
 

Protected Attributes

YStringTreeItem_root
 
std::string _textdomain
 

Detailed Description

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

Definition at line 41 of file YStringTree.h.

Constructor & Destructor Documentation

◆ YStringTree()

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

Definition at line 32 of file YStringTree.cc.

Here is the call graph for this function:

Member Function Documentation

◆ addBranch()

YStringTreeItem * YStringTree::addBranch ( const std::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"

Definition at line 48 of file YStringTree.cc.

Here is the call graph for this function:

◆ completePath()

std::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.

Definition at line 127 of file YStringTree.cc.

Here is the call graph for this function:

◆ origPath()

std::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.

Definition at line 97 of file YStringTree.h.

Here is the call graph for this function:

◆ path()

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.

Definition at line 158 of file YStringTree.cc.

Here is the call graph for this function:

◆ root()

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.

Definition at line 139 of file YStringTree.h.

◆ setTextdomain()

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

Definition at line 157 of file YStringTree.h.

Here is the call graph for this function:

◆ translate()

std::string YStringTree::translate ( const std::string &  orig)

Translate message 'orig' using the internal textdomain.

Returns the translated text or the original if there is no translation.

Definition at line 118 of file YStringTree.cc.

◆ translatedPath()

std::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.

Definition at line 108 of file YStringTree.h.

Here is the call graph for this function:

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