diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-11-14 00:12:15 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-11-14 00:12:15 +0000 |
| commit | 04ae48c346d0c2c6d6bcd4bbb7f6ff0ab88c1bd8 (patch) | |
| tree | 31609f0e6d9159f0e0c1c416e392f380c51a67e0 /src/string.hh | |
| parent | 9679b17b16fb971de2e048a1abf2d63fe83ad3ee (diff) | |
indent cleanup, correct erroneous 3 spaces indent
Diffstat (limited to 'src/string.hh')
| -rw-r--r-- | src/string.hh | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/src/string.hh b/src/string.hh index 68317901..176c7269 100644 --- a/src/string.hh +++ b/src/string.hh @@ -16,47 +16,47 @@ typedef boost::regex Regex; class String : public std::string { public: - String() {} - String(const char* content) : std::string(content) {} - String(std::string content) : std::string(std::move(content)) {} - explicit String(char content, CharCount count = 1) : std::string((size_t)(int)count, content) {} - explicit String(Codepoint cp, CharCount count = 1) - { - while (count-- > 0) - utf8::dump(back_inserter(*this), cp); - } - template<typename Iterator> - String(Iterator begin, Iterator end) : std::string(begin, end) {} - - std::string& stdstr() { return *this; } - const std::string& stdstr() const { return *this; } - - char operator[](ByteCount pos) const { return std::string::operator[]((int)pos); } - char& operator[](ByteCount pos) { return std::string::operator[]((int)pos); } - ByteCount length() const { return ByteCount{(int)std::string::length()}; } - CharCount char_length() const { return utf8::distance(begin(), end()); } - ByteCount byte_count_to(CharCount count) const { return utf8::advance(begin(), end(), (int)count) - begin(); } - CharCount char_count_to(ByteCount count) const { return utf8::distance(begin(), begin() + (int)count); } - - String operator+(const String& other) const { return String{stdstr() + other.stdstr()}; } - String& operator+=(const String& other) { std::string::operator+=(other); return *this; } - String operator+(const char* other) const { return String{stdstr() + other}; } - String& operator+=(const char* other) { std::string::operator+=(other); return *this; } - String operator+(char other) const { return String{stdstr() + other}; } - String& operator+=(char other) { std::string::operator+=(other); return *this; } - String operator+(Codepoint cp) const { String res = *this; utf8::dump(back_inserter(res), cp); return res; } - String& operator+=(Codepoint cp) { utf8::dump(back_inserter(*this), cp); return *this; } - - memoryview<char> data() const { return memoryview<char>(std::string::data(), size()); } - - String substr(ByteCount pos, ByteCount length = -1) const { return String{std::string::substr((int)pos, (int)length)}; } - String substr(CharCount pos, CharCount length = INT_MAX) const - { - auto b = utf8::advance(begin(), end(), (int)pos); - auto e = utf8::advance(b, end(), (int)length); - return String(b,e); - } - String replace(const Regex& expression, const String& replacement) const; + String() {} + String(const char* content) : std::string(content) {} + String(std::string content) : std::string(std::move(content)) {} + explicit String(char content, CharCount count = 1) : std::string((size_t)(int)count, content) {} + explicit String(Codepoint cp, CharCount count = 1) + { + while (count-- > 0) + utf8::dump(back_inserter(*this), cp); + } + template<typename Iterator> + String(Iterator begin, Iterator end) : std::string(begin, end) {} + + std::string& stdstr() { return *this; } + const std::string& stdstr() const { return *this; } + + char operator[](ByteCount pos) const { return std::string::operator[]((int)pos); } + char& operator[](ByteCount pos) { return std::string::operator[]((int)pos); } + ByteCount length() const { return ByteCount{(int)std::string::length()}; } + CharCount char_length() const { return utf8::distance(begin(), end()); } + ByteCount byte_count_to(CharCount count) const { return utf8::advance(begin(), end(), (int)count) - begin(); } + CharCount char_count_to(ByteCount count) const { return utf8::distance(begin(), begin() + (int)count); } + + String operator+(const String& other) const { return String{stdstr() + other.stdstr()}; } + String& operator+=(const String& other) { std::string::operator+=(other); return *this; } + String operator+(const char* other) const { return String{stdstr() + other}; } + String& operator+=(const char* other) { std::string::operator+=(other); return *this; } + String operator+(char other) const { return String{stdstr() + other}; } + String& operator+=(char other) { std::string::operator+=(other); return *this; } + String operator+(Codepoint cp) const { String res = *this; utf8::dump(back_inserter(res), cp); return res; } + String& operator+=(Codepoint cp) { utf8::dump(back_inserter(*this), cp); return *this; } + + memoryview<char> data() const { return memoryview<char>(std::string::data(), size()); } + + String substr(ByteCount pos, ByteCount length = -1) const { return String{std::string::substr((int)pos, (int)length)}; } + String substr(CharCount pos, CharCount length = INT_MAX) const + { + auto b = utf8::advance(begin(), end(), (int)pos); + auto e = utf8::advance(b, end(), (int)length); + return String(b,e); + } + String replace(const Regex& expression, const String& replacement) const; }; inline String operator+(const char* lhs, const String& rhs) |
