String Class Reference

A dynamic character string whose interface conforms to STL's std::string. More...

#include "String.hpp"

Classes

class  Iterator
 A random access iterator class for String. More...
 

Public Types

using iterator = Iterator< false, true >
 
using const_iterator = Iterator< true, true >
 
using reverse_iterator = Iterator< false, false >
 
using const_reverse_iterator = Iterator< true, false >
 
using value_type = char
 
using pointer = char *
 
using reference = char &
 
using const_reference = char const &
 
using size_type = std::size_t
 
using difference_type = std::ptrdiff_t
 

Public Member Functions

construction / destruction
 String ()
 
 String (const String &other, size_type pos=0, size_type n=npos())
 
 String (const char *s)
 
 String (const char *s, size_type n)
 
 String (size_type n, char c)
 
 String (iterator beg, iterator end)
 
 String (const_iterator beg, const_iterator end)
 
 String (reverse_iterator beg, reverse_iterator end)
 
 String (const_reverse_iterator beg, const_reverse_iterator end)
 
 ~String ()
 
assignment, swapping
Stringoperator= (const String &other)
 
Stringoperator= (const char *other)
 
Stringoperator= (char c)
 
Stringassign (const String &)
 
Stringassign (const String &s, size_type pos, size_type n)
 
Stringassign (const char *s, size_type n)
 
Stringassign (const char *s)
 
Stringassign (size_type n, char c)
 
Stringassign (iterator beg, iterator end)
 
Stringassign (const_iterator beg, const_iterator end)
 
Stringassign (reverse_iterator beg, reverse_iterator end)
 
Stringassign (const_reverse_iterator beg, const_reverse_iterator end)
 
void swap (String &other)
 
iterator traversal

forward/reverse, const/non-const

iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
iterator end ()
 
const_iterator end () const
 
const_iterator cend () const
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator crbegin () const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
const_reverse_iterator crend () const
 
element access
reference at (size_type n)
 
const_reference at (size_type n) const
 
reference operator[] (size_type n)
 
const_reference operator[] (size_type n) const
 
reference front ()
 
const_reference front () const
 
reference back ()
 
const_reference back () const
 
const char * c_str () const
 
const char * data () const
 
size
size_type size () const
 
size_type length () const
 
size_type max_size () const
 
size_type capacity () const
 
bool empty () const
 
void clear ()
 
void resize (size_type n, char c=char())
 
append
Stringappend (const String &s)
 
Stringappend (const String &s, size_type pos, size_type n)
 
Stringappend (const char *s)
 
Stringappend (const char *s, size_type n)
 
Stringappend (size_type n, char c)
 
Stringappend (iterator beg, iterator end)
 
Stringappend (const_iterator beg, const_iterator end)
 
Stringappend (reverse_iterator beg, reverse_iterator end)
 
Stringappend (const_reverse_iterator beg, const_reverse_iterator end)
 
void push_back (char c)
 
Stringoperator+= (const String &s)
 
Stringoperator+= (const char *s)
 
Stringoperator+= (char c)
 
insert
iterator insert (iterator pos, const char &s)
 
void insert (iterator pos, size_type n, const char &s)
 
Stringinsert (size_type n, const String &s)
 
Stringinsert (size_type pos, const String &s, size_type pos1, size_type n)
 
Stringinsert (size_type pos, const char *s)
 
Stringinsert (size_type pos, const char *s, size_type n)
 
Stringinsert (size_type pos, size_type n, char c)
 
void insert (iterator pos, iterator beg, iterator end)
 
void insert (iterator pos, const_iterator beg, const_iterator end)
 
void insert (iterator pos, reverse_iterator beg, reverse_iterator end)
 
void insert (iterator pos, const_reverse_iterator beg, const_reverse_iterator end)
 
erase
iterator erase (iterator p)
 
iterator erase (iterator first, iterator last)
 
Stringerase (size_type pos=0, size_type n=npos())
 
replace
Stringreplace (size_type pos, size_type n, const String &s)
 
Stringreplace (size_type pos, size_type n, const String &s, size_type pos1, size_type n1)
 
Stringreplace (size_type pos, size_type n, const char *s, size_type n1)
 
Stringreplace (size_type pos, size_type n, const char *s)
 
Stringreplace (size_type pos, size_type n, size_type n1, char c)
 
Stringreplace (iterator first, iterator last, const String &s)
 
Stringreplace (iterator first, iterator last, const char *s, size_type n)
 
Stringreplace (iterator first, iterator last, const char *s)
 
Stringreplace (iterator first, iterator last, size_type n, char c)
 
Stringreplace (iterator beg1, iterator end1, iterator beg2, iterator end2)
 
Stringreplace (iterator beg1, iterator end1, const_iterator beg2, const_iterator end2)
 
Stringreplace (iterator beg1, iterator end1, reverse_iterator beg2, reverse_iterator end2)
 
Stringreplace (iterator beg1, iterator end1, const_reverse_iterator beg2, const_reverse_iterator end2)
 
find

forward/reverse

size_type find (const String &s, size_type pos=0) const
 
size_type find (const char *s, size_type pos, size_type n) const
 
size_type find (const char *s, size_type pos=0) const
 
size_type find (char c, size_type pos=0) const
 
size_type rfind (const String &s, size_type pos=npos()) const
 
size_type rfind (const char *s, size_type pos, size_type n) const
 
size_type rfind (const char *s, size_type pos=npos()) const
 
size_type rfind (char c, size_type pos=npos()) const
 
size_type find_first_of (const String &s, size_type pos=0) const
 
size_type find_first_of (const char *s, size_type pos, size_type n) const
 
size_type find_first_of (const char *s, size_type pos=0) const
 
size_type find_first_of (char c, size_type pos=0) const
 
size_type find_first_not_of (const String &s, size_type pos=0) const
 
size_type find_first_not_of (const char *s, size_type pos, size_type n) const
 
size_type find_first_not_of (const char *s, size_type pos=0) const
 
size_type find_first_not_of (char c, size_type pos=0) const
 
size_type find_last_of (const String &s, size_type pos=npos()) const
 
size_type find_last_of (const char *s, size_type pos, size_type n) const
 
size_type find_last_of (const char *s, size_type pos=npos()) const
 
size_type find_last_of (char c, size_type pos=npos()) const
 
size_type find_last_not_of (const String &s, size_type pos=npos()) const
 
size_type find_last_not_of (const char *s, size_type pos, size_type n) const
 
size_type find_last_not_of (const char *s, size_type pos=npos()) const
 
size_type find_last_not_of (char c, size_type pos=npos()) const
 
substring
String substr (size_type pos=0, size_type n=npos()) const
 
copy to buffer
size_type copy (char *buf, size_type n, size_type pos=0) const
 
3-way comparison
int compare (const String &s) const
 
int compare (size_type pos, size_type n, const String &s) const
 
int compare (size_type pos, size_type n, const String &s, size_type pos1, size_type n1) const
 
int compare (const char *s) const
 
int compare (size_type pos, size_type n, const char *s, size_type len=npos()) const
 

Static Public Member Functions

static const size_type & npos ()
 

Related Functions

(Note that these are not member functions.)

String operator+ (const String &s1, const String &s2)
 
String operator+ (const char *s1, const String &s2)
 
String operator+ (const String &s1, const char *s2)
 
String operator+ (char c, const String &s2)
 
String operator+ (const String &s1, char c)
 
bool operator== (const String &s1, const String &s2)
 
bool operator== (const char *s1, const String &s2)
 
bool operator== (const String &s1, const char *s2)
 
bool operator!= (const String &s1, const String &s2)
 
bool operator!= (const char *s1, const String &s2)
 
bool operator!= (const String &s1, const char *s2)
 
bool operator< (const String &s1, const String &s2)
 
bool operator< (const char *s1, const String &s2)
 
bool operator< (const String &s1, const char *s2)
 
void swap (String &s1, String &s2)
 

Detailed Description

A dynamic character string whose interface conforms to STL's std::string.

Author
wk
Date
02.02.2011