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-2026 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  {
46  {
47  wchar_t unicode;
48  wchar_t vt100;
49  wchar_t pc;
50  wchar_t ascii;
51  };
52 
53  union
54  {
55  TermEncodings encoding{};
56  std::array<wchar_t, std::size_t(Encoding::NUM_OF_ENCODINGS)> array;
57  };
58  };
59 
60  // vt100 <-> utf-8
62  {
63  VT100Key key;
64  UniChar unicode;
65  };
66 
67  // Using-declaration
68  using CharEncodeType = std::array<CharEncodeMap, 115>;
69  using DECGraphicsType = std::array<DECSpecialGraphics, 39>;
70  using Cp437UcsType = std::array<std::array<wchar_t, 2>, 256>;
71  using HalfFullWidthType = std::array<std::array<wchar_t, 2>, 227>;
72 
73  // Constructors
74  FCharMap() = default;
75 
76  // Accessors
77  auto getClassName() const -> FString;
78  static auto getInstance() -> FCharMap&;
79  static auto getCharacter ( const CharEncodeMap& char_enc
80  , const Encoding& enc ) -> const wchar_t&;
81  static auto getCharEncodeMap() -> CharEncodeType&;
82  static auto getDECSpecialGraphics() -> const DECGraphicsType&;
83  static auto getCP437UCSMap() -> const Cp437UcsType&;
84  static auto getHalfFullWidthMap() -> const HalfFullWidthType&;
85 
86  // Mutators
87  static auto setCharacter ( CharEncodeMap& char_enc
88  , const Encoding& enc ) -> wchar_t&;
89 
90  private:
91  // Data members
92  static CharEncodeType character;
93  static const DECGraphicsType dec_special_graphics;
94  static const Cp437UcsType cp437_ucs;
95  static const HalfFullWidthType halfwidth_fullwidth;
96 };
97 
98 // FCharMap inline functions
99 //----------------------------------------------------------------------
100 inline auto FCharMap::getClassName() const -> FString
101 { return "FCharMap"; }
102 
103 } // namespace finalcut
104 
105 #endif // FCHARMAP_H
Definition: fcharmap.h:43
Definition: class_template.cpp:25
Definition: fstring.h:82
Definition: fcharmap.h:39