libyui
 
Loading...
Searching...
No Matches
YStringTree Class Reference

#include <YStringTree.h>

Inheritance diagram for YStringTree:
Collaboration diagram for YStringTree:

Public Member Functions

 YStringTree (const char *textdomain)
 
virtual ~YStringTree ()
 
YStringTreeItemaddBranch (const std::string &content, char delimiter=0, YStringTreeItem *parent=0)
 
std::string origPath (const YStringTreeItem *item, char delimiter, bool startWithDelimiter=true)
 
std::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)
 
std::string translate (const std::string &orig)
 

Protected Member Functions

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

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.

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

◆ ~YStringTree()

YStringTree::~YStringTree ( )
virtual

Destructor.

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"

◆ completePath()

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.

◆ logBranch()

void YStringTree::logBranch ( YStringTreeItem * branch,
std::string indentation )
protected

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

◆ logTree()

void YStringTree::logTree ( )

Debugging - dump the tree into the log file.

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

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

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

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

◆ textdomain()

const char * YStringTree::textdomain ( ) const
inline

Returns the textdomain used internally for translation of pathname components.

◆ translate()

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.

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


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