libyui-ncurses  2.44.1
 All Classes Functions Variables
NCstring.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: NCstring.h
20 
21  Author: Michael Andres <ma@suse.de>
22 
23 /-*/
24 
25 #ifndef NCstring_h
26 #define NCstring_h
27 
28 #include <iosfwd>
29 #include <string>
30 
31 
32 class NCstring
33 {
34 private:
35 
36  friend std::ostream & operator<<( std::ostream & STREAM, const NCstring & OBJ );
37 
38 
39  mutable wchar_t hotk; // hotkey
40  mutable std::wstring::size_type hotp; // position of hotkey
41  mutable std::wstring wstr;
42 
43  static std::string termEncoding; // the encoding of the terminal
44 
45 public:
46 
47  NCstring();
48 
49  NCstring( const NCstring & nstr );
50 
51  NCstring( const std::wstring & wstr );
52 
53  NCstring( const std::string & str );
54 
55  NCstring( const char * cstr );
56 
57  ~NCstring() {}
58 
59  std::string Str() const;
60 
61 public:
62 
63  NCstring & operator=( const NCstring & nstr );
64 
65  NCstring & operator+=( const NCstring & nstr );
66 
67  const std::wstring & str() const { return wstr; }
68 
69 private:
70 
71  friend class NClabel;
72  wchar_t hotkey() const { return hotk; }
73 
74  std::wstring::size_type hotpos() const { return hotp; }
75 
76 public:
77 
78  static bool RecodeToWchar( const std::string& in, const std::string & from_encoding, std::wstring* out );
79  static bool RecodeFromWchar( const std::wstring & in, const std::string & to_encoding, std::string* out );
80 
81  static const std::string & terminalEncoding()
82  {
83  return termEncoding;
84  }
85 
86  static bool setTerminalEncoding( const std::string & encoding = "" );
87 
88  void getHotkey() const;
89 };
90 
91 
92 #endif // NCstring_h
Definition: NCtext.h:81