Iteratorsを含むSTD :: Stringの機能を模倣する文字列クラスのシンプルなカスタマイズ可能な実装。
using size_type = size_t; // size_type for positions of char in cstring
using const_pointer = const_iterator;
using pointer = iterator;
using const_reverse_pointer = const_reverse_iterator;
using reverse_pointer = reverse_iterator;
String(); // default constructor
String(const String &); // copy constructor
String(const String& other, size_type pos, size_t len = npos); // substring constructor
String(String &&); // move constructor
String(const char *); // from c-string
String(const char* s, size_t n); // from buffer
String(size_t n, char c);// fill constructor
String(const const_iterator first, const const_iterator second); // range constructor
String & operator= (const String &); // copy assignment
String & operator = (String &&); // move assignment
~String();
Iterator/const_iteratorを最初の文字に返します
iterator begin();
const_iterator begin() const;
文字列の過去の文字を指すIterator/const_iteratorを返します
iterator end();
const_iterator end() const;
文字列の最初の文字 /過去の文字を指すconst_iteratorを返す
const_iterator cbegin() const;
const_iterator cend() const;
reverse_iterator/const_reverse_iteratorを最後の文字に返します
reverse_iterator rbegin();
const_reverse_iterator rbegin() const;
REVERSEF_ITERATOR/const_Reverse_iteratorを返して、文字列の過去の文字を逆転させる
reverse_iterator rend();
const_reverse_iterator rend() const;
const_reverse_iteratorを返す最後の文字を指して / stringの過去の文字を逆にします
const_reverse_iterator crbegin() const;
const_reverse_iterator crend() const;
文字列の文字を取得します
const char & operator [] (size_type) const;
char & operator [] (size_type);
文字列で文字を取得します
const char & at(size_type) const;
char & at(size_type);
最初の文字にアクセスします
const char & front() const;
char & front();
最後の文字にアクセスします
const char & back() const;
char & back();
文字列に追加します
String & operator += (const String &); // string (1)
String & operator += (const char *); // c - string (2)
String & operator += (char); // char (3)
文字列に追加します
String& append(const String& str); // string (1)
String& append(const String& str, size_type subpos, size_t sublen = npos); // substring (2)
String& append(const char* s); // c - string (3)
String& append(const char* s, size_t n); // buffer(4)
String& append(size_type n, char c); // fill(5)
String& append(const const_iterator first, const const_iterator second); // range(6)
String & push_back(char);
文字列に挿入します
String& insert(size_type pos, const String& other); // string(1)
String& insert(size_type pos, const String& other, size_type subpos, size_t sublen = npos); // substring(2)
String& insert(size_type pos, const char* other); // c - string(3)
String& insert(size_type pos, const char* s, size_t n); // buffer(4)
String& insert(size_type pos, size_t n, char c); // fill(5)
void insert(iterator p, size_t n, char c); // fill(6)
iterator insert(iterator p, char c); // single character(7)
void insert(iterator p, const const_iterator first, const const_iterator last); // range(8)
文字列から文字を消去します
String& erase(size_type pos = 0, size_t len = npos); // sequence(1)
iterator erase(const_iterator p); // character(2)
iterator erase(const_iterator first, const_iterator last); // range(3)
文字列の部分を交換します
String& replace(size_type pos, size_t len, const String& other); // string(1)
String& replace(const_iterator i1, const_iterator i2, const String& other); // string(2)
String& replace(size_type pos, size_t len, const String& other, size_type subpos, size_t sublen = npos); // substring(3)
String& replace(size_type pos, size_t len, const char* s); // c - string(4)
String& replace(const_iterator i1, const_iterator i2, const char* other); // c - string(5)
String& replace(size_type pos, size_t len, const char* other, size_t n); // buffer(6)
String& replace(const_iterator i1, const_iterator i2, const char* other, size_t n); // buffer(7)
String& replace(size_type pos, size_t len, size_t n, char c); // fill(8)
String& replace(const_iterator i1, const_iterator i2, size_type n, char c); // fill(9)
String& replace(const_iterator i1, const_iterator i2, const_iterator first, const_iterator second); // range(10)
文字列値を交換します
void swap(String &);
最後の文字を削除します
String & pop_back();
C Stringが同等のものを取得します
const char * c_str() const;
文字列から文字のシーケンスをコピーします
size_t copy(char* s, size_t len, size_type pos = 0) const;
文字列でコンテンツを見つけます
size_type find(const String& other, size_type pos = 0) const; //string(1)
size_type find(const char* s, size_type pos = 0) const; // c - string(2)
size_type find(const char* s, size_type pos, size_type n) const; // buffer(3)
size_type find(char c, size_type pos = 0) const; // character(4)
文字列でコンテンツの最後の発生を見つけます
size_type rfind(const String& other, size_type pos = npos) const; // string(1)
size_type rfind(const char* s, size_type pos = npos) const; // c - string(2)
size_type rfind(const char* s, size_type pos, size_t n) const; // buffer(3)
size_type rfind(char c, size_type pos = npos) const; // character(4)
文字列で文字を見つけます
size_type find_first_of(const String& other, size_type pos = 0) const; // string(1)
size_type find_first_of(const char* other, size_type pos = 0) const; // c - string(2)
size_type find_first_of(const char* other, size_type pos, size_t n) const; // buffer(3)
size_type find_first_of(char c, size_type pos = 0) const; // character(4)
最後から文字列で文字を見つけます
size_type find_last_of(const String& other, size_type pos = String::npos) const; // string(1)
size_type find_last_of(const char* other, size_type pos = String::npos) const; // c - string(2)
size_type find_last_of(const char* other, size_type pos, size_t n) const; // buffer(3)
size_type find_last_of(char c, size_type pos = String::npos) const; // character(4)
文字列に文字がないことを見つけます
size_type find_first_not_of(const String& other, size_type pos = 0) const; // string(1)
size_type find_first_not_of(const char* other, size_type pos = 0) const; // c - string(2)
size_type find_first_not_of(const char* other, size_type pos, size_t n) const; // buffer(3)
size_type find_first_not_of(char c, size_type pos = 0) const; // character(4)
最後から文字列で一致しない文字を見つけます
size_type find_last_not_of(const String& other, size_type pos = String::npos) const; // string(1)
size_type find_last_not_of(const char* other, size_type pos = String::npos) const; // c - string(2)
size_type find_last_not_of(const char* other, size_type pos, size_t n) const; // buffer(3)
size_type find_last_not_of(char c, size_type pos = String::npos) const; // character(4)
サブストリングを生成します
String substr(size_type pos = 0, size_t len = npos) const;
文字列の長さを返します
size_t length() const;
size_t size() const;
文字列の最大サイズを返します
size_t max_size() const;
文字列のサイズ
void resize(size_t n);
void resize(size_type n, char c);
割り当てられたストレージの返品サイズ
size_t capacity() const;
容量の変更を要求します
void reserve(size_t n = 0);
クリア文字列
void clear();
return true is string is veatt
bool empty() const;
収まるように縮みます
void shrink_to_fit();
static const size_t npos = -1; // Maximum value for size_t
比較
// Size is compared and if equal then comapred lexicographically
friend bool operator == (const String &, const String &);
friend bool operator != (const String &, const String &);
friend bool operator < (const String &, const String &);
friend bool operator > (const String &, const String &);
friend bool operator <= (const String &, const String &);
friend bool operator >= (const String &, const String &);
2つの文字列の値を交換します
void swap(String& x, String& y);
連結された文字列を返します
String operator+ (const String& lhs, const String& rhs);
String operator+ (const String& lhs, const char* rhs);
String operator+ (const char* lhs, const String& rhs);
String operator+ (const String& lhs, char rhs);
String operator+ (char lhs, const String& rhs);
ストリームに文字列を挿入します
std::ostream& operator<< (std::ostream& os, const _JD String& str);
ストリームから文字列を抽出します
std::istream& operator>> (std::istream& is, _JD String& str);
ストリームから文字列にラインを取得します
std::istream& getline(std::istream& is, _JD String& str, char delim);
std::istream& getline(std::istream& is, _JD String& str);