FINAL CUT
fcharmap.h
1 /***********************************************************************
2 * fcharmap.h - Character mapping and encoding *
3 * *
4 * This file is part of the FINAL CUT widget toolkit *
5 * *
6 * Copyright 2015-2022 Markus Gans *
7 * *
8 * FINAL CUT is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as *
10 * published by the Free Software Foundation; either version 3 of *
11 * the License, or (at your option) any later version. *
12 * *
13 * FINAL CUT is distributed in the hope that it will be useful, but *
14 * WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this program. If not, see *
20 * <http://www.gnu.org/licenses/>. *
21 ***********************************************************************/
22 
23 #ifndef FCHARMAP_H
24 #define FCHARMAP_H
25 
26 #if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
27  #error "Only <final/final.h> can be included directly."
28 #endif
29 
30 #include <array>
31 
32 #include "final/fc.h"
33 #include "final/ftypes.h"
34 #include "final/util/fstring.h"
35 
36 namespace finalcut
37 {
38 
39 class FCharMap final
40 {
41  public:
42  // Unicode fallback table for VT100, PC, and ASCII
44  {
45  wchar_t unicode;
46  wchar_t vt100;
47  wchar_t pc;
48  wchar_t ascii;
49  };
50 
51  // vt100 <-> utf-8
53  {
54  VT100Key key;
55  UniChar unicode;
56  };
57 
58  // Using-declaration
59  using CharEncodeType = std::array<CharEncodeMap, 115>;
60  using DECGraphicsType = std::array<DECSpecialGraphics, 39>;
61  using Cp437UcsType = std::array<std::array<wchar_t, 2>, 256>;
62  using HalfFullWidthType = std::array<std::array<wchar_t, 2>, 227>;
63 
64  // Constructors
65  FCharMap() = default;
66 
67  // Accessors
68  auto getClassName() const -> FString;
69  static auto getInstance() -> FCharMap&;
70  static auto getCharacter ( const CharEncodeMap& char_enc
71  , const Encoding& enc ) -> const wchar_t&;
72  static auto getCharEncodeMap() -> CharEncodeType&;
73  static auto getDECSpecialGraphics() -> const DECGraphicsType&;
74  static auto getCP437UCSMap() -> const Cp437UcsType&;
75  static auto getHalfFullWidthMap() -> const HalfFullWidthType&;
76 
77  // Mutators
78  static auto setCharacter ( CharEncodeMap& char_enc
79  , const Encoding& enc ) -> wchar_t&;
80 
81  private:
82  // Data members
83  static CharEncodeType character;
84  static const DECGraphicsType dec_special_graphics;
85  static const Cp437UcsType cp437_ucs;
86  static const HalfFullWidthType halfwidth_fullwidth;
87 };
88 
89 // FCharMap inline functions
90 //----------------------------------------------------------------------
91 inline auto FCharMap::getClassName() const -> FString
92 { return "FCharMap"; }
93 
94 } // namespace finalcut
95 
96 #endif // FCHARMAP_H
Definition: fcharmap.h:43
Definition: class_template.cpp:25
Definition: fstring.h:79
Definition: fcharmap.h:39