-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiString.cpp
More file actions
66 lines (51 loc) · 1.34 KB
/
MultiString.cpp
File metadata and controls
66 lines (51 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <codecvt>
#include "MultiString.h"
using libreg::MultiString;
MultiString::MultiString(const char* input) : _value(Convert(input))
{
}
MultiString::MultiString(const std::string& input) : _value(Convert(input))
{
}
MultiString::MultiString(const wchar_t* input) : _value(input)
{
}
MultiString::MultiString(const std::wstring& input) : _value(input)
{
}
const std::wstring& MultiString:: Value() const
{
return _value;
}
const wchar_t* MultiString::Raw() const
{
return _value.c_str();
}
std::string libreg::MultiString::AsMultiByte() const
{
return Convert(_value);
}
std::wstring MultiString::Convert(const std::string& input)
{
typedef std::codecvt_utf8<wchar_t> convert_type;
std::wstring_convert<convert_type, wchar_t> converter;
return converter.from_bytes(input);
}
std::string MultiString::Convert(const std::wstring& input)
{
typedef std::codecvt_utf8<wchar_t> convert_type;
std::wstring_convert<convert_type, wchar_t> converter;
return converter.to_bytes(input);
}
bool libreg::MultiString::operator==(const MultiString& other) const
{
return Value() == other.Value();
}
bool libreg::MultiString::operator!=(const MultiString& other) const
{
return !(*this == other);
}
std::ostream& libreg::operator<<(std::ostream& stream, const MultiString& string)
{
return stream << MultiString::Convert(string.Value());
}