|
@@ -123,45 +123,6 @@ namespace Core {
|
|
|
check_return Error formatBuffer(CharString& s, int index);
|
|
|
};
|
|
|
|
|
|
- template<int N>
|
|
|
- class ArrayCharString final : public CharString {
|
|
|
- static_assert(N > 0, "size of array string must be positive");
|
|
|
- char data[static_cast<unsigned int>(N)];
|
|
|
-
|
|
|
- public:
|
|
|
- ArrayCharString() : CharString(data, N) {
|
|
|
- }
|
|
|
-
|
|
|
- ArrayCharString(const ArrayCharString& other) : CharString(data, N) {
|
|
|
- Core::memoryCopy(data, other.data, N);
|
|
|
- length = other.length;
|
|
|
- hash = other.hash;
|
|
|
- }
|
|
|
-
|
|
|
- ArrayCharString& operator=(const ArrayCharString& other) {
|
|
|
- if(this != &other) {
|
|
|
- Core::memoryCopy(data, other.data, N);
|
|
|
- length = other.length;
|
|
|
- hash = other.hash;
|
|
|
- }
|
|
|
- return *this;
|
|
|
- }
|
|
|
-
|
|
|
- template<typename... Args>
|
|
|
- check_return Error format(Args&&... args) {
|
|
|
- ArrayCharString s;
|
|
|
- return CharString::format(s, Core::forward<Args>(args)...);
|
|
|
- }
|
|
|
-
|
|
|
- check_return Error replace(const CharString& search,
|
|
|
- const CharString& replace) {
|
|
|
- ArrayCharString s;
|
|
|
- return CharString::replace(s, search, replace);
|
|
|
- }
|
|
|
-
|
|
|
- using CharString::replace;
|
|
|
- };
|
|
|
-
|
|
|
template<int N>
|
|
|
class Char32String final {
|
|
|
int length;
|
|
@@ -563,6 +524,44 @@ namespace Core {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ template<int N, typename C, typename B>
|
|
|
+ class ArrayString final : public B {
|
|
|
+ static_assert(N > 0, "size of array string must be positive");
|
|
|
+ C data[static_cast<unsigned int>(N)];
|
|
|
+
|
|
|
+ public:
|
|
|
+ ArrayString() : B(data, N) {
|
|
|
+ }
|
|
|
+
|
|
|
+ ArrayString(const ArrayString& other) : B(data, N) {
|
|
|
+ Core::memoryCopy(data, other.data, sizeof(data));
|
|
|
+ B::length = other.length;
|
|
|
+ B::hash = other.hash;
|
|
|
+ }
|
|
|
+
|
|
|
+ ArrayString& operator=(const ArrayString& other) {
|
|
|
+ if(this != &other) {
|
|
|
+ Core::memoryCopy(data, other.data, sizeof(data));
|
|
|
+ B::length = other.length;
|
|
|
+ B::hash = other.hash;
|
|
|
+ }
|
|
|
+ return *this;
|
|
|
+ }
|
|
|
+
|
|
|
+ template<typename... Args>
|
|
|
+ check_return Error format(Args&&... args) {
|
|
|
+ ArrayString s;
|
|
|
+ return B::format(s, Core::forward<Args>(args)...);
|
|
|
+ }
|
|
|
+
|
|
|
+ check_return Error replace(const B& search, const B& replace) {
|
|
|
+ ArrayString s;
|
|
|
+ return B::replace(s, search, replace);
|
|
|
+ }
|
|
|
+
|
|
|
+ using B::replace;
|
|
|
+ };
|
|
|
+
|
|
|
template<typename String, typename Iterable>
|
|
|
check_return Error toString(String& s, const Iterable& i) {
|
|
|
CORE_RETURN_ERROR(s.append("["));
|
|
@@ -579,7 +578,7 @@ namespace Core {
|
|
|
}
|
|
|
|
|
|
template<int N>
|
|
|
- using String8 = ArrayCharString<N>;
|
|
|
+ using String8 = ArrayString<N, char, CharString>;
|
|
|
|
|
|
template<int N>
|
|
|
using String32 = Char32String<N>;
|