Skip to content

Commit 4de427f

Browse files
committed
character converter skeleton class
1 parent 0c77468 commit 4de427f

File tree

5 files changed

+60
-0
lines changed

5 files changed

+60
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
add_header_library(
2+
mbstate
3+
HDRS
4+
mbstate.h
5+
DEPENDS
6+
libc.hdr.types.wchar_t
7+
)
8+
9+
add_header_library(
10+
character_converter
11+
HDRS
12+
character_converter.h
13+
DEPENDS
14+
libc.hdr.types.wchar_t
15+
.mbstate
16+
.utf_ret
17+
)
18+
19+
add_header_library(
20+
utf_ret
21+
HDRS
22+
utf_ret.h
23+
DEPENDS
24+
)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
#include "src/__support/wchar/mbstate.h"
3+
#include "src/__support/wchar/utf_ret.h"
4+
#include "hdr/types/wchar_t.h"
5+
6+
class CharacterConverter {
7+
private:
8+
mbstate_t* state;
9+
10+
public:
11+
CharacterConverter();
12+
13+
bool isComplete();
14+
15+
int push(char utf8_byte);
16+
int push(wchar_t utf32);
17+
18+
utf_ret<char> pop_utf8();
19+
utf_ret<wchar_t> pop_utf32();
20+
};

libc/src/__support/wchar/mbstate.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
#include "hdr/types/wchar_t.h"
3+
4+
struct mbstate_t {
5+
wchar_t partial;
6+
unsigned char bits_processed;
7+
unsigned char total_bytes;
8+
};

libc/src/__support/wchar/utf_ret.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
template <typename T>
3+
struct utf_ret {
4+
T out;
5+
int error;
6+
};

0 commit comments

Comments
 (0)