Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

YStringTree.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                                        (C) SuSE GmbH |
00011 \----------------------------------------------------------------------/
00012 
00013   File:       YStringTree.h
00014 
00015   Author:     Stefan Hundhammer <sh@suse.de>
00016 
00017 /-*/
00018 
00019 #ifndef YStringTree_h
00020 #define YStringTree_h
00021 
00022 #include <string>
00023 #include <y2util/YTransText.h>
00024 #include <y2util/TreeItem.h>
00025 
00026 
00027 typedef SortedTreeItem<YTransText>      YStringTreeItem;
00028 
00029 using std::string;
00030 
00031 
00036 class YStringTree
00037 {
00038 public:
00039 
00051     YStringTree( const char * textdomain );
00052 
00056     virtual ~YStringTree();
00057 
00082     YStringTreeItem * addBranch( const string &         content,
00083                                  char                   delimiter = 0,
00084                                  YStringTreeItem *      parent    = 0 );
00085 
00086 
00092     string origPath( const YStringTreeItem *    item,
00093                      char                       delimiter,
00094                      bool                       startWithDelimiter = true )
00095         { return completePath( item, false, delimiter, startWithDelimiter ); }
00096 
00097 
00103     string translatedPath( const YStringTreeItem * item,
00104                            char delimiter,
00105                            bool startWithDelimiter = true )
00106         { return completePath( item, true, delimiter, startWithDelimiter ); }
00107 
00108 
00117     YTransText path( const YStringTreeItem *item,
00118                      char delimiter,
00119                      bool startWithDelimiter = true );
00120 
00121 
00125     void logTree();
00126 
00127 
00134     YStringTreeItem * root() const { return _root; }
00135 
00136 
00141     const char * textdomain() const { return _textdomain.c_str(); }
00142 
00143     
00152     void setTextdomain( const char * domain )   { _textdomain = domain; }
00153 
00158     string translate( const string & orig );
00159     
00160     
00161 protected:
00162 
00168     string completePath( const YStringTreeItem * item,
00169                          bool translated,
00170                          char delimiter,
00171                          bool startWithDelimiter );
00172 
00176     void logBranch( YStringTreeItem * branch, string indentation );
00177 
00178 
00179     // Data members
00180 
00181     YStringTreeItem *   _root;
00182     string              _textdomain;
00183 };
00184 
00185 
00186 
00187 
00188 #endif // YStringTree_h

Generated on Thu Feb 23 23:56:10 2006 for liby2util by doxygen 1.3.6