27 #include "YStringTree.h"
69 string::size_type start = 0;
70 string::size_type end = 0;
72 while ( start < content.length() )
76 while ( start < content.length() &&
77 content[ start ] == delimiter )
87 while ( end < content.length() &&
88 content[ end ] != delimiter )
98 string path_component = content.substr( start, end - start );
102 node = findDirectChild( parent, path_component_trans);
121 string trans( dgettext( _textdomain.c_str(), orig.c_str() ) );
131 bool startWithDelimiter )
141 string parentPath = translated ?
142 item->
parent()->value().translation() :
143 item->
parent()->value().orig();
145 path = parentPath + delimiter +
path;
151 if ( startWithDelimiter )
161 bool startWithDelimiter )
176 if ( startWithDelimiter )
200 printf(
"%s%s (%s)\n", indentation.c_str(),
201 branch->
value().translation().c_str(),
202 branch->
value().orig().c_str() );
210 child = child->
next();
215 printf(
"%s<NULL>\n", indentation.c_str() );
Template class for tree items that maintain sort order.
SortedTreeItem< PAYLOAD > * firstChild() const
Returns this item's first child or 0 if there is none.
SortedTreeItem< PAYLOAD > * parent() const
Returns this item's parent or 0 if there is none.
SortedTreeItem< PAYLOAD > * next() const
Returns this item's next sibling or 0 if there is none.
const PAYLOAD & value() const
Returns this item's value, the "payload".
YStringTree(const char *textdomain)
Constructor.
void logBranch(YStringTreeItem *branch, std::string indentation)
Debugging - dump one branch of the tree into the log file.
YStringTreeItem * 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 paren...
std::string translate(const std::string &orig)
Translate message 'orig' using the internal textdomain.
void logTree()
Debugging - dump the tree into the log file.
YTransText path(const YStringTreeItem *item, char delimiter, bool startWithDelimiter=true)
Construct a complete path (both original and translated) for the specified tree item.
void setTextdomain(const char *domain)
Set the textdomain used internally for translation of pathname components.
std::string completePath(const YStringTreeItem *item, bool translated, char delimiter, bool startWithDelimiter)
Construct a complete original or translated path for the specified tree item.
virtual ~YStringTree()
Destructor.
Helper class for translated strings: Stores a message in the original (untranslated) version along wi...
const std::string & orig() const
Return the original message.
void setTranslation(const std::string &newTrans)
Set the translation.
void setOrig(const std::string &newOrig)
Set the original message.
const std::string & translation() const
Return the translation.
const std::string & trans() const
Return the translation.