-
Notifications
You must be signed in to change notification settings - Fork 0
/
dunicodestring.hpp
94 lines (74 loc) · 2.2 KB
/
dunicodestring.hpp
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#ifndef DESTRUCT_DUNICODESTRING_HPP_
#define DESTRUCT_DUNICODESTRING_HPP_
#include <string>
#include <iostream>
#include <sstream>
#include <stdint.h>
#include "destruct.hpp"
namespace Destruct
{
class DUnicodeString
{
public:
EXPORT DUnicodeString();
EXPORT DUnicodeString(const DUnicodeString& dunicodeString);
EXPORT DUnicodeString(const std::string& string);
EXPORT DUnicodeString(const char *);
EXPORT DUnicodeString(const char);
/**
* Unicode conversion method using ICU
* See ICU for valid codepage
*/
EXPORT DUnicodeString(const char* str, int32_t size, const char* codepage);
EXPORT ~DUnicodeString();
EXPORT std::string string(void) const;
EXPORT const char* c_str() const;
EXPORT size_t size(void) const;
EXPORT size_t find(const std::string& str) const;
EXPORT DUnicodeString substr(size_t pos, size_t len = std::string::npos) const;
EXPORT DUnicodeString& operator=(const DUnicodeString& rhs);
EXPORT DUnicodeString& operator=(std::string rhs);
EXPORT DUnicodeString& operator+=(const DUnicodeString& rhs);
EXPORT DUnicodeString operator+(const DUnicodeString& rhs);
EXPORT operator std::string() const
{
return (this->string());
}
EXPORT friend DUnicodeString operator+(const char* left, const DUnicodeString& rhs)
{
std::string tmp = left + rhs.string();
return (DUnicodeString(tmp));
}
EXPORT friend std::ostream& operator<<(std::ostream& out, const DUnicodeString &dunicodeString)
{
out << dunicodeString.string();
return (out);
}
EXPORT friend std::istream& operator>>(std::istream& in, DUnicodeString &dunicodeString)
{
std::string tmp;
in >> tmp;
dunicodeString += tmp; //+= or = ?
return (in);
}
EXPORT friend bool operator<(const DUnicodeString &left, const DUnicodeString &right)
{
return (left.string() < right.string());
}
EXPORT friend bool operator>(const DUnicodeString &left, const DUnicodeString &right)
{
return (left.string() > right.string());
}
EXPORT friend bool operator==(const DUnicodeString &left, const DUnicodeString &right)
{
return (left.string() == right.string());
}
EXPORT friend bool operator!=(const DUnicodeString &left, const DUnicodeString &right)
{
return (left.string() != right.string());
}
private:
std::string __string;
};
}
#endif