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

NCstring.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:       NCstring.h
00014 
00015    Author:     Michael Andres <ma@suse.de>
00016    Maintainer: Michael Andres <ma@suse.de>
00017 
00018 /-*/
00019 #ifndef NCstring_h
00020 #define NCstring_h
00021 
00022 #include <iosfwd>
00023 
00024 #include <string>
00025 
00026 using std::string;
00027 using std::wstring;
00028 
00029 using namespace std;
00030 
00031 class YCPString;
00032 
00033 
00035 //
00036 //      CLASS NAME : NCstring
00037 //
00038 //      DESCRIPTION :
00039 //
00040 class NCstring {
00041 
00042   friend std::ostream & operator<<( std::ostream & STREAM, const NCstring & OBJ );
00043 
00044   private:
00045 
00046     mutable wchar_t hotk;               // hotkey
00047     mutable wstring::size_type hotp;    // position of hotkey
00048     mutable wstring   wstr;
00049 
00050     static string       termEncoding;   // the encoding of the terminal
00051     
00052 public:
00053 
00054     NCstring();
00055 
00056     NCstring( const NCstring & nstr );
00057 
00058     NCstring( const wstring & wstr );
00059 
00060     NCstring( const string & str );
00061 
00062     NCstring( const char * cstr );
00063     
00064     ~NCstring() {}
00065 
00066   public: // filter from/to YCPString(utf8)
00067 
00068     NCstring( const YCPString & ystr );
00069 
00070     NCstring & operator=( const YCPString & ystr );
00071     
00072     YCPString YCPstr() const;
00073 
00074     string Str() const;
00075 
00076  public:
00077 
00078     NCstring & operator=( const NCstring & nstr );
00079 
00080     NCstring & operator+=( const NCstring & nstr );
00081 
00082     const wstring & str()      const { return wstr; }
00083 
00084   private:
00085 
00086     friend class NClabel;
00087     wchar_t            hotkey() const { return hotk; }
00088     wstring::size_type hotpos() const { return hotp; }
00089 
00090   public:
00091 
00092     static bool RecodeToWchar( const string& in, const string & from_encoding, wstring* out );
00093     static bool RecodeFromWchar( const wstring & in, const string & to_encoding, string* out);
00094 
00095     static const string & terminalEncoding () {
00096         return termEncoding;
00097     }
00098     
00099     static bool setTerminalEncoding( const string & encoding = "" );
00100 
00101     void getHotkey() const;
00102 };
00103 
00105 
00106 #endif // NCstring_h

Generated on Wed Sep 5 17:18:55 2007 for yast2-ncurses by doxygen 1.3.6