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