source: mainline/uspace/lib/cpp/include/__bits/locale/codecvt.hpp@ b57ba05

Last change on this file since b57ba05 was b57ba05, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 3 years ago

Update headers in C++ files

  • Property mode set to 100644
File size: 4.5 KB
Line 
1/*
2 * SPDX-FileCopyrightText: 2018 Jaroslav Jindrak
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef LIBCPP_BITS_LOCALE_CODECVT
8#define LIBCPP_BITS_LOCALE_CODECVT
9
10#include <__bits/locale/locale.hpp>
11#include <string>
12
13namespace std
14{
15 /**
16 * 22.4.1.4, class template codecvt:
17 */
18
19 class codecvt_base
20 {
21 public:
22 enum result
23 {
24 ok, partial, error, noconv
25 };
26 };
27
28 template<class Intern, class Extern, class State>
29 class codecvt: public codecvt_base
30 {
31 public:
32 using intern_type = Intern;
33 using extern_type = Extern;
34 using state_type = State;
35
36 explicit codecvt(size_t = 0)
37 { /* DUMMY BODY */ }
38
39 result out(state_type& state, const intern_type* from, const intern_type* from_end,
40 const intern_type*& from_next, extern_type* to, extern_type* to_end,
41 extern_type*& to_next) const
42 {
43 return do_out(state, from, from_end, from_next, to, to_end, to_next);
44 }
45
46 result unshift(state_type& state, extern_type* to, extern_type* to_end,
47 extern_type*& to_next) const
48 {
49 return do_unshift(state, to, to_end, to_next);
50 }
51
52 result in(state_type& state, const extern_type* from, const extern_type* from_end,
53 const extern_type*& from_next, intern_type* to, intern_type* to_end,
54 intern_type*& to_next) const
55 {
56 return do_in(state, from, from_end, from_next, to, to_end, to_next);
57 }
58
59 int encoding() const noexcept
60 {
61 return do_encoding();
62 }
63
64 bool always_noconv() const noexcept
65 {
66 return do_always_noconv();
67 }
68
69 int length(state_type& state, const extern_type* from, const extern_type* end,
70 size_t max) const
71 {
72 return do_length(state, from, end, max);
73 }
74
75 int max_length() const noexcept
76 {
77 return do_max_length();
78 }
79
80 static locale::id id;
81
82 ~codecvt() = default;
83
84 protected:
85 virtual result do_out(state_type& state, const intern_type* from, const intern_type* from_end,
86 const intern_type*& from_next, extern_type* to, extern_type* to_end,
87 extern_type*& to_next) const
88 {
89 // TODO: implement
90 return error;
91 }
92
93 virtual result do_unshift(state_type& state, extern_type* to, extern_type* to_end,
94 extern_type*& to_next) const
95 {
96 // TODO: implement
97 return error;
98 }
99
100 virtual result do_in(state_type& state, const extern_type* from, const extern_type* from_end,
101 const extern_type*& from_next, intern_type* to, intern_type* to_end,
102 intern_type*& to_next) const
103 {
104 // TODO: implement
105 return error;
106 }
107
108 virtual int do_encoding() const noexcept
109 {
110 // TODO: implement
111 return 0;
112 }
113
114 virtual bool do_always_noconv() const noexcept
115 {
116 // TODO: implement
117 return false;
118 }
119
120 virtual int do_length(state_type& state, const extern_type* from, const extern_type* end,
121 size_t max) const
122 {
123 // TODO: implement
124 return 0;
125 }
126
127 virtual int do_max_length() const noexcept
128 {
129 // TODO: implement
130 return 0;
131 }
132 };
133
134 template<class Intern, class Extern, class State>
135 locale::id codecvt<Intern, Extern, State>::id{};
136
137 /**
138 * 22.4.1.5, class template codecvt_byname:
139 * Note: Dummy, TODO: implement.
140 */
141
142 template<class Intern, class Extern, class State>
143 class codecvt_byname: public codecvt<Intern, Extern, State>
144 {
145 public:
146 explicit codecvt_byname(const char*, size_t = 0)
147 { /* DUMMY BODY */ }
148
149 explicit codecvt_byname(const string&, size_t = 0)
150 { /* DUMMY BODY */ }
151
152 ~codecvt_byname() = default;
153 };
154}
155
156#endif
Note: See TracBrowser for help on using the repository browser.