CLI  2.9
encoding.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2006-2018, Alexis Royer, http://alexis.royer.free.fr/CLI
3 
4  All rights reserved.
5 
6  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation
10  and/or other materials provided with the distribution.
11  * Neither the name of the CLI library project nor the names of its contributors may be used to endorse or promote products derived from this software
12  without specific prior written permission.
13 
14  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
22  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 
27 
31 
32 #ifndef _CLI_ENCODING_H_
33 #define _CLI_ENCODING_H_
34 
35 #include "cli/namespace.h"
36 #include "cli/object.h"
37 #include "cli/tk.h"
38 #include "cli/io_device.h"
39 
40 
42 
43 
44 
45  class StringEncoder : public Object
48  {
49  public:
51  explicit StringEncoder(void);
52 
53  private:
55  explicit StringEncoder(const StringEncoder&);
56 
57  public:
59  virtual ~StringEncoder(void);
60 
61  public:
64  const char* const Encode(
65  const KEY E_Key
66  ) const;
67 
68  private:
70  mutable tk::String m_tkString;
71  };
72 
77  class StringDecoder : public Object
78  {
79  public:
81  explicit StringDecoder(void);
82 
84  explicit StringDecoder(
85  const char* const STR_String
86  );
87 
88  private:
90  explicit StringDecoder(const StringDecoder&);
91 
92  public:
94  virtual ~StringDecoder(void);
95 
96  public:
101  const KEY Decode(
102  const int I_Char
103  );
104 
109  const KEY GetKey(void);
110 
111  private:
113  tk::String m_tkString;
115  int m_iCurrentSequence;
116  };
117 
119 
120 #endif // _CLI_ENCODING_H_
Generic object.
Definition: object.h:42
Main namespace of the CLI library.
#define CLI_NS_END(__ns)
End a namespace definition.
Definition: namespace.h:45
Namespace management.
StringDecoder(void)
Default constructor.
StringEncoder(void)
Default constructor.
virtual ~StringDecoder(void)
Destructor.
virtual ~StringEncoder(void)
Destructor.
enum _KEY KEY
Input keys.
#define CLI_NS_BEGIN(__ns)
Begin a namespace definition.
Definition: namespace.h:38
OutputDevice, IODevice and IOEndl classes defintion.
CLI toolkit definition.
Object class definition.
Key to chararcters encoder.
Definition: encoding.h:47
const char *const Encode(const KEY E_Key) const
Key to string encoding.
Regular characters to key decoder.
Definition: encoding.h:77
const KEY Decode(const int I_Char)
Push characters one by one and get the corresponding keys.
const KEY GetKey(void)
Retrieve characters from the input string.