aboutsummaryrefslogtreecommitdiff
path: root/include/cru/common/String.hpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-09-13 15:51:02 +0800
committercrupest <crupest@outlook.com>2021-09-13 15:51:02 +0800
commit9bc202a2e1664df3e3c148abfe90a90501bc1650 (patch)
treeedb3f908ab30b0a6df498d47a38d9e1cefd7a7b1 /include/cru/common/String.hpp
parentfe45ee2dde28c995f1aa16a9cdc3119e00a26a8a (diff)
downloadcru-9bc202a2e1664df3e3c148abfe90a90501bc1650.tar.gz
cru-9bc202a2e1664df3e3c148abfe90a90501bc1650.tar.bz2
cru-9bc202a2e1664df3e3c148abfe90a90501bc1650.zip
...
Diffstat (limited to 'include/cru/common/String.hpp')
-rw-r--r--include/cru/common/String.hpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/include/cru/common/String.hpp b/include/cru/common/String.hpp
index 8197c402..42143c9d 100644
--- a/include/cru/common/String.hpp
+++ b/include/cru/common/String.hpp
@@ -1,8 +1,8 @@
#pragma once
#include "Base.hpp"
-#include "StringUtil.hpp"
#include "Range.hpp"
+#include "StringUtil.hpp"
#include <cstdint>
#include <iterator>
@@ -119,15 +119,28 @@ class CRU_BASE_API String {
iterator insert(const_iterator pos, std::uint16_t value) {
return this->insert(pos, &value, 1);
}
- iterator insert(const_iterator pos, std::uint16_t* str, Index size);
+ iterator insert(const_iterator pos, const std::uint16_t* str, Index size);
iterator erase(const_iterator pos) { return this->erase(pos, pos + 1); }
iterator erase(const_iterator start, const_iterator end);
void push_back(std::uint16_t value) { this->append(value); }
void pop_back() { this->erase(cend() - 1); }
void append(std::uint16_t value) { this->insert(cend(), value); }
- void append(std::uint16_t* str, Index size) {
+ void append(const std::uint16_t* str, Index size) {
this->insert(cend(), str, size);
}
+ void append(const String& other) { append(other.data(), other.size()); }
+
+ public:
+ String& operator+=(const String& other) {
+ append(other);
+ return *this;
+ }
+
+ String operator+(const String& other) const {
+ String result(*this);
+ result += other;
+ return result;
+ }
public:
Utf16CodePointIterator CodePointIterator() const {