libyui
YStringTree.h
1 /*
2  Copyright (C) 2000-2012 Novell, Inc
3  This library is free software; you can redistribute it and/or modify
4  it under the terms of the GNU Lesser General Public License as
5  published by the Free Software Foundation; either version 2.1 of the
6  License, or (at your option) version 3.0 of the License. This library
7  is distributed in the hope that it will be useful, but WITHOUT ANY
8  WARRANTY; without even the implied warranty of MERCHANTABILITY or
9  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
10  License for more details. You should have received a copy of the GNU
11  Lesser General Public License along with this library; if not, write
12  to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
13  Floor, Boston, MA 02110-1301 USA
14 */
15 
16 
17 /*-/
18 
19  File: YStringTree.h
20 
21  Author: Stefan Hundhammer <shundhammer@suse.de>
22 
23 /-*/
24 
25 #ifndef YStringTree_h
26 #define YStringTree_h
27 
28 #include <string>
29 #include "YTransText.h"
30 #include "TreeItem.h"
31 
32 
34 
35 
36 
42 {
43 public:
44 
56  YStringTree( const char * textdomain );
57 
61  virtual ~YStringTree();
62 
87  YStringTreeItem * addBranch( const std::string & content,
88  char delimiter = 0,
89  YStringTreeItem * parent = 0 );
90 
91 
97  std::string origPath( const YStringTreeItem * item,
98  char delimiter,
99  bool startWithDelimiter = true )
100  { return completePath( item, false, delimiter, startWithDelimiter ); }
101 
102 
108  std::string translatedPath( const YStringTreeItem * item,
109  char delimiter,
110  bool startWithDelimiter = true )
111  { return completePath( item, true, delimiter, startWithDelimiter ); }
112 
113 
122  YTransText path( const YStringTreeItem *item,
123  char delimiter,
124  bool startWithDelimiter = true );
125 
126 
130  void logTree();
131 
132 
139  YStringTreeItem * root() const { return _root; }
140 
141 
146  const char * textdomain() const { return _textdomain.c_str(); }
147 
148 
157  void setTextdomain( const char * domain ) { _textdomain = domain; }
158 
163  std::string translate( const std::string & orig );
164 
165 
166 protected:
167 
173  std::string completePath( const YStringTreeItem * item,
174  bool translated,
175  char delimiter,
176  bool startWithDelimiter );
177 
181  void logBranch( YStringTreeItem * branch, std::string indentation );
182 
183 
184  // Data members
185 
186  YStringTreeItem * _root;
187  std::string _textdomain;
188 };
189 
190 
191 
192 
193 #endif // YStringTree_h
void setTextdomain(const char *domain)
Definition: YStringTree.h:157
void logTree()
Definition: YStringTree.cc:187
const char * textdomain() const
Definition: YStringTree.h:146
YStringTreeItem * root() const
Definition: YStringTree.h:139
Definition: TreeItem.h:191
YStringTree(const char *textdomain)
Definition: YStringTree.cc:33
YTransText path(const YStringTreeItem *item, char delimiter, bool startWithDelimiter=true)
Definition: YStringTree.cc:159
YStringTreeItem * addBranch(const std::string &content, char delimiter=0, YStringTreeItem *parent=0)
Definition: YStringTree.cc:49
std::string translate(const std::string &orig)
Definition: YStringTree.cc:119
Definition: YStringTree.h:41
std::string translatedPath(const YStringTreeItem *item, char delimiter, bool startWithDelimiter=true)
Definition: YStringTree.h:108
std::string origPath(const YStringTreeItem *item, char delimiter, bool startWithDelimiter=true)
Definition: YStringTree.h:97
Definition: YTransText.h:36
void logBranch(YStringTreeItem *branch, std::string indentation)
Definition: YStringTree.cc:196
virtual ~YStringTree()
Definition: YStringTree.cc:41
std::string completePath(const YStringTreeItem *item, bool translated, char delimiter, bool startWithDelimiter)
Definition: YStringTree.cc:128