libyui
|
00001 /************************************************************************** 00002 Copyright (C) 2000 - 2010 Novell, Inc. 00003 All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License along 00016 with this program; if not, write to the Free Software Foundation, Inc., 00017 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 00019 **************************************************************************/ 00020 00021 00022 /*---------------------------------------------------------------------\ 00023 | | 00024 | __ __ ____ _____ ____ | 00025 | \ \ / /_ _/ ___|_ _|___ \ | 00026 | \ V / _` \___ \ | | __) | | 00027 | | | (_| |___) || | / __/ | 00028 | |_|\__,_|____/ |_| |_____| | 00029 | | 00030 | core system | 00031 | (C) SuSE GmbH | 00032 \----------------------------------------------------------------------/ 00033 00034 File: YStringTree.h 00035 00036 Author: Stefan Hundhammer <sh@suse.de> 00037 00038 /-*/ 00039 00040 #ifndef YStringTree_h 00041 #define YStringTree_h 00042 00043 #include <string> 00044 #include "YTransText.h" 00045 #include "TreeItem.h" 00046 00047 00048 typedef SortedTreeItem<YTransText> YStringTreeItem; 00049 00050 using std::string; 00051 00052 00057 class YStringTree 00058 { 00059 public: 00060 00072 YStringTree( const char * textdomain ); 00073 00077 virtual ~YStringTree(); 00078 00103 YStringTreeItem * addBranch( const string & content, 00104 char delimiter = 0, 00105 YStringTreeItem * parent = 0 ); 00106 00107 00113 string origPath( const YStringTreeItem * item, 00114 char delimiter, 00115 bool startWithDelimiter = true ) 00116 { return completePath( item, false, delimiter, startWithDelimiter ); } 00117 00118 00124 string translatedPath( const YStringTreeItem * item, 00125 char delimiter, 00126 bool startWithDelimiter = true ) 00127 { return completePath( item, true, delimiter, startWithDelimiter ); } 00128 00129 00138 YTransText path( const YStringTreeItem *item, 00139 char delimiter, 00140 bool startWithDelimiter = true ); 00141 00142 00146 void logTree(); 00147 00148 00155 YStringTreeItem * root() const { return _root; } 00156 00157 00162 const char * textdomain() const { return _textdomain.c_str(); } 00163 00164 00173 void setTextdomain( const char * domain ) { _textdomain = domain; } 00174 00179 string translate( const string & orig ); 00180 00181 00182 protected: 00183 00189 string completePath( const YStringTreeItem * item, 00190 bool translated, 00191 char delimiter, 00192 bool startWithDelimiter ); 00193 00197 void logBranch( YStringTreeItem * branch, string indentation ); 00198 00199 00200 // Data members 00201 00202 YStringTreeItem * _root; 00203 string _textdomain; 00204 }; 00205 00206 00207 00208 00209 #endif // YStringTree_h