Further refinements to string/members

git-svn-id: https://cppannotations.svn.sourceforge.net/svnroot/cppannotations/trunk@118 f6dd340e-d3f9-0310-b409-bdd246841980
This commit is contained in:
fbbrokken 2007-07-27 14:43:54 +00:00
parent 14d1530b4f
commit 7aadbb6a38
3 changed files with 102 additions and 97 deletions

View file

@ -3,22 +3,18 @@ available:
itemization(
itt(string object):
quote(Initializes tt(object) to an empty string.)
itt(string object(string::size_type no, char c)):
quote(Initializes tt(object) with tt(no) characters tt(c).)
itt(string object(string::size_type n, char c)):
quote(Initializes tt(object) with tt(n) characters tt(c).)
itt(string object(string argument)):
quote(Initializes tt(object) with tt(argument).)
itt(string object = argument):
quote(Initializes tt(object) with tt(argument). This is an
alternative form of the previous initialization.)
alternative form of the previous initialization.)
itt(string object(string argument, string::size_type apos,
string::size_type an = string::npos)):
quote(Initializes tt(object) with tt(argument),
using tt(an) characters of tt(argument), starting at index
tt(apos). If tt(an) is not specified, all characters of
tt(argument) starting at offset tt(apos) are used.)
string::size_type an)):
quote(Initializes tt(object) with tt(argument).)
itt(string object(InputIterator begin, InputIterator end)):
quote(Initializes tt(object) with the range of characters implied
by the provided tt(InputIterators). Iterators are covered in
detail in section ref(ITERATORS), but can (for the time being) be
interpreted as pointers to characters. See also the next section.)
quote(Initializes tt(object) with the characters implied
by the range of characters defined by the two
tt(InputIterators).)
)

View file

@ -1,4 +1,4 @@
The string member functions are listed in alphabetic order. The member name,
Below string member functions are listed in alphabetic order. The member name,
prefixed by the tt(string)-class is given first. Then the full prototype and a
description are given. Values of the type ti(string::size_type) represent
index positions within a tt(string). For all practical purposes, these values
@ -14,36 +14,36 @@ blanks. The final 0-byte that is used in bf(C) to indicate the end of a
tt(ASCII-Z) string is em(not) considered part of a bf(C++) string, and so the
member function will return tt(npos), rather than tt(length()).
In the following overview, `tt(size_type)' should always be read as
`ti(string::size_type)'.
In the following overview, `tt(size_type)' should always be read as
`ti(string::size_type)'.
itemization(
it() hi(string::at()) tt(char &string::at(size_type opos)):
quote(The character (reference) at the indicated position is
quote(the character (reference) at the indicated position is
returned (it may be reassigned). The member function performs range-checking,
raising an exception (by default aborting the program) if an invalid index is
passed. No default value for tt(opos).)
it() hi(string::append())
tt(string &string::append(InputIterator begin, InputIterator end)):
quote( Using this member function the characters, in the range
quote(using this member function the characters, in the range
implied by the tt(begin) and tt(end InputIterators) are appended to the
tt(string) object.)
itt(string &string::append(string argument, size_type apos, size_type
an)):
quote(
tt(argument) (or a substring) it appended to the tt(string)
tt(argument) (or a substring) is appended to the tt(string)
object.
)
itt(string &string::append(char const *argument, size_type an)):
quote(The first tt(an) characters of tt(argument) are appended to
quote(the first tt(an) characters of tt(argument) are appended to
the tt(string) object.
)
itt(string &string::append(size_type n, char c)):
quote(Using this member function, tt(n) characters tt(c) can be
quote(using this member function, tt(n) characters tt(c) are
appended to the tt(string) object.
)
@ -54,24 +54,24 @@ size_type an)):
itemization(
it() tt(argument) (or a substring) is assigned to the tt(string)
object.
it() If tt(argument) is of type tt(char const *) and one
it() if tt(argument) is of type tt(char const *) and one
additional argument the second argument is interpreted as a
value initializing tt(an), using tt(0) to initialize tt(apos).
))
itt(string &string::assign(size_type n, char c)):
quote(
Using this member function, tt(n) characters tt(c) can be assigned
using this member function, tt(n) characters tt(c) can be assigned
to the tt(string) object.)
it() hi(string::capacity())
tt(size_type string::capacity()):
quote(returns the number of characters that can currently be
stored inside the tt(string) object.)
stored in the tt(string) object.)
it() hi(string::compare())
tt(int string::compare(string argument)):
quote(This member function can be used to compare (according to
quote(this member function is used to compare (according to
the ASCII-character set) the text stored in the tt(string) object and in
tt(argument). The tt(argument) may also be a (non-0) tt(char const *). 0 is
returned if the characters in the tt(string) object and in tt(argument) are
@ -82,14 +82,14 @@ lexicographically em(beyond) the text in tt(argument).)
itt(int string::compare(size_type opos, size_type on, string
argument)):
quote(This member function can be used to compare a substring of the text
quote(this member function is used to compare a substring of the text
stored in the tt(string) object with the text stored in tt(argument). At most
tt(on) characters, starting at offset tt(opos), are compared with the text in
tt(argument). The tt(argument) may also be a (non-0) tt(char const *).)
itt(int string::compare+OPENPARsize_type opos, size_type on, string
argument,) linebreak() tt(size_type apos, size_type an+CLOSEPAR):
quote(This member function can be used to compare a substring of the text
quote(this member function is used to compare a substring of the text
stored in the tt(string) object with a substring of the text stored in
tt(argument). At most tt(on) characters of the tt(string) object, starting at
offset tt(opos), are compared with at most tt(an) characters of tt(argument),
@ -98,7 +98,7 @@ tt(string) object.)
itt(int string::compare+OPENPARsize_type opos, size_type on,
char const *argument,) linebreak() tt(size_type an+CLOSEPAR):
quote(This member function can be used to compare a substring of the text
quote(this member function is used to compare a substring of the text
stored in the tt(string) object with a substring of the text stored in
tt(argument). At most tt(on) characters of the tt(string) object, starting at
offset tt(opos), are compared with at most tt(an) characters of
@ -108,7 +108,7 @@ meaning.)
it() hi(string::copy())
tt(size_type string::copy(char *argument, size_type on, size_type opos)):
quote(The contents of the tt(string) object are (partially) copied
quote(the contents of the tt(string) object are (partially) copied
to tt(argument). The actual number of characters that were copied
is returned. Note that characters of the object calling this member will be
copied em(into) tt(argument). Also note that em(following the copying, no
@ -139,15 +139,15 @@ used to store and retrieve any kind of information, including, e.g., series of
it() hi(string::erase())
tt(string &string::erase(size_type opos, size_type on)):
quote(This member function can be used to erase (a sub)string of
quote(this member function is used to erase (a sub)string of
the tt(string) object.)
itt(iterator string::erase(iterator obegin, iterator oend)):
quote(
itemization(
it() If only tt(obegin) is provided, the tt(string) object's character
it() if only tt(obegin) is provided, the tt(string) object's character
at iterator position tt(obegin) is erased.
it() If tt(oend) is provided as well the characters of the tt(string)
it() if tt(oend) is provided as well the characters of the tt(string)
object, in the range implied by the tt(iterators obegin) and tt(oend), are
erased.
)
@ -156,28 +156,28 @@ immediately following the last erased character.)
it() hi(string::find())
tt(size_type string::find(string argument, size_type opos)):
quote(Returns the index in the tt(string) object where
quote(returns the index in the tt(string) object where
tt(argument) is found.)
itt(size_type string::find(char const *argument, size_type opos,
size_type an)):
quote(Returns the index in the tt(string) object where
quote(returns the index in the tt(string) object where
tt(argument) is found. Note: when three arguments are specified the first
argument em(cannot) be a tt(std::string const &).)
itt(size_type string::find(char c, size_type opos)):
quote( Returns the index in the tt(string) object where tt(c) is
quote( returns the index in the tt(string) object where tt(c) is
found.)
it() hi(string::find_first_of())
tt(size_type string::find_first_of(string argument,
size_type opos)):
quote(Returns the index in the tt(string) object where any
quote(returns the index in the tt(string) object where any
character in tt(argument) is found.)
itt(size_type string::find_first_of+OPENPARchar const *argument,
size_type opos,) linebreak() tt(size_type an+CLOSEPAR):
quote(Returns the index in the tt(string) object where a character
quote(returns the index in the tt(string) object where a character
of tt(argument) is found, no matter which character.
itemization(
it() If tt(opos) is provided it refers to the index in the tt(string)
@ -190,57 +190,57 @@ omitted, all of tt(argument)'s characters are used.
))
itt(size_type string::find_first_of(char c, size_type opos)):
quote(Returns the index in the tt(string) object where character
quote(returns the index in the tt(string) object where character
tt(c) is found.)
it() hi(string::find_first_not_of())
tt(size_type string::find_first_not_of(string argument,
size_type opos)):
quote(Returns the index in the tt(string) object where a character
quote(returns the index in the tt(string) object where a character
not appearing in tt(argument) is found.)
itt(size_type string::find_first_not_of(char const *argument,
size_type opos, size_type an)):
quote(Returns the index in the tt(string) object where any
quote(returns the index in the tt(string) object where any
character em(not) appearing in tt(argument) is found.)
itt(size_type string::find_first_not_of(char c, size_type opos)):
quote(Returns the index in the tt(string) object where another
quote(returns the index in the tt(string) object where another
character than tt(c) is found.)
it() hi(string::find_last_of())
tt(size_type string::find_last_of(string argument, size_type opos)):
quote(Returns the em(last) index in the tt(string) object where
quote(returns the em(last) index in the tt(string) object where
one of tt(argument)'s characters is found.)
itt(size_type string::find_last_of+OPENPARchar const* argument,
size_type opos,) linebreak() tt(size_type an+CLOSEPAR):
quote(Returns the last index in the tt(string) object where one of
quote(returns the last index in the tt(string) object where one of
tt(argument)'s characters is found.)
itt(size_type string::find_last_of(char c, size_type opos)):
quote(Returns the last index in the tt(string) object where
quote(returns the last index in the tt(string) object where
character tt(c) is found.)
it() hi(string::find_last_not_of())
tt(size_type string::find_last_not_of(string argument,
size_type opos)):
quote(Returns the last index in the tt(string) object where any
quote(returns the last index in the tt(string) object where any
character not appearing in tt(argument) is found.)
itt(size_type string::find_last_not_of+OPENPARchar const *argument,
size_type) linebreak() tt(opos, size_type an+CLOSEPAR):
quote(Returns the last index in the tt(string) object where any
quote(returns the last index in the tt(string) object where any
character not appearing in tt(argument) is found.)
itt(size_type string::find_last_not_of(char c, size_type opos)):
quote(Returns the last index in the tt(string) object where
quote(returns the last index in the tt(string) object where
another character than tt(c) is found.)
it() hi(string::getline())
tt(istream &getline(istream &istr, string object, char delimiter)):
quote(This function (note that it's not a em(member) function of
the class tt(string)) can be used to read a line of text from tt(istr). All
quote(this function (note that it's not a em(member) function of
the class tt(string)) is used to read a line of text from tt(istr). All
characters until tt(delimiter) (or the end of the stream, whichever comes
first) are read from tt(istr) and are stored in tt(object). The delimiter,
when present, is removed from the stream, but is not stored in tt(line). The
@ -253,31 +253,31 @@ was terminated by a delimiter, will always be assigned to tt(object).nl()
it() hi(string::insert())
tt(string &string::insert+OPENPARsize_type opos, string argument,
size_type) linebreak() tt(apos, size_type an+CLOSEPAR):
quote(This member function can be used to insert (a sub)string of
quote(this member function is used to insert (a sub)string of
tt(argument) into the tt(string) object, em(at) the tt(string) object's index
position tt(opos). Arguments for tt(apos) and tt(an) must either both be
specified or they must both be omitted.)
tt(string &string::insert(size_type opos, string argument,
itt(string &string::insert(size_type opos, char const *argument,
size_type an)):
quote(If tt(argument) is of type tt(char const *),
tt(apos) is not available.)
quote(if tt(argument) is of type tt(char const *), tt(apos) is not
available.)
itt(string &string::insert(size_type opos, size_type n, char c)):
quote(Using this member function, tt(n) characters tt(c) can be
quote(using this member function, tt(n) characters tt(c) can be
inserted to the tt(string) object.)
itt(iterator string::insert(iterator obegin, char c)):
quote(The character tt(c) is inserted at the (iterator) position
quote(the character tt(c) is inserted at the (iterator) position
tt(obegin) in the tt(string) object. The iterator tt(obegin) is returned.)
itt(iterator string::insert(iterator obegin, size_type n, char c)):
quote(At the (iterator) position tt(obegin) of tt(object), tt(n)
quote(at the (iterator) position tt(obegin) of tt(object), tt(n)
characters tt(c) are inserted. The iterator tt(obegin) is returned.)
itt(iterator string::insert+OPENPARiterator obegin,
InputIterator abegin,) linebreak()tt(InputIterator aend+CLOSEPAR):
quote(The characters in the range implied by the tt(InputIterators
quote(the characters in the range implied by the tt(InputIterators
abegin) and tt(aend) are inserted at the (iterator) position tt(obegin) in
tt(object). The iterator tt(obegin) is returned.)
@ -292,16 +292,18 @@ in the tt(string) object.)
it() hi(string::replace())
tt(string &string::replace+OPENPARsize_type opos, size_type on, string
argument,)linebreak() tt(size_type apos, size_type an+CLOSEPAR):
quote(If tt(on) is set to 0, the member function em(inserts)
quote(the specified substring of characters in tt(object) are
replaced bby the specified subset of characters of tt(argument).
If tt(on) is specified as 0, the member function em(inserts)
tt(argument) into tt(object) at offset tt(opos).)
tt(string &string::replace+OPENPARsize_type opos, size_type on, char
const *argument,)linebreak() tt(size_type an+CLOSEPAR):
quote(An em(initial subset) of tt(an) characters of the provided
tt(char const *) argument will replace the indicated range of characters in
tt(object).)
itt(string &string::replace+OPENPARsize_type opos, size_type
on,)linebreak() tt(char const *argument, size_type an+CLOSEPAR):
quote(the indicated range of characters in tt(object) will be
replaced by an em(initial subset) of tt(an) characters of the provided tt(char
const *) argument.)
tt(string &string::replace+OPENPARsize_type opos, size_type on,
itt(string &string::replace+OPENPARsize_type opos, size_type on,
size_type n,) linebreak() tt(char c+CLOSEPAR):
quote(tt(on) characters of the tt(string) object, starting at
index position tt(opos), are replaced by tt(n) characters having values
@ -309,45 +311,45 @@ tt(c).)
itt(string &string::replace (iterator obegin, iterator oend, string
argument)):
quote(Here, the string implied by the iterators tt(obegin) and
quote(here, the string implied by the iterators tt(obegin) and
tt(oend) is replaced by tt(argument). If tt(argument) is a tt(char const *),
an extra argument tt(an) may be used, specifying the number of characters of
tt(argument) that are used in the replacement.)
itt(string &string::replace(iterator obegin, iterator oend,
size_type n, char c)):
quote(The characters of the tt(string) object, in the range
quote(the characters of the tt(string) object, in the range
implied by the tt(iterators obegin) and tt(oend) are replaced by tt(n)
characters having values tt(c).)
itt(string string::replace(iterator obegin, iterator oend,
InputIterator abegin, InputIterator aend)):
quote(Here the characters in the range implied by the iterators
quote(here the characters in the range implied by the iterators
tt(obegin) and tt(oend) are replaced by the characters in the range implied by
the tt(InputIterators abegin) and tt(aend).)
it() hi(string::resize()) tt(void string::resize(size_type n, char c)):
quote(The string stored in the tt(string) object is resized to
quote(the string stored in the tt(string) object is resized to
tt(n) characters. The second argument is optional, in which case the value
tt(c = 0) is used. If provided and the string is enlarged, the extra
characters are initialized to tt(c).)
it() hi(string::rfind())
tt(size_type string::rfind(string argument, size_type opos)):
quote(Returns the index in the tt(string) object where
quote(returns the index in the tt(string) object where
tt(argument) is found. Searching proceeds either from the end of the
tt(string) object or from its offset tt(opos) back to the beginning.)
itt(size_type string::rfind(char const *argument, size_type opos,
size_type an)):
quote(Returns the index in the tt(string) object where
quote(returns the index in the tt(string) object where
tt(argument) is found. Searching proceeds either from the end of the
tt(string) object or from offset tt(opos) back to the beginning. The
parameter tt(an) specifies the number of characters of of tt(argument)
starting at its beginning.)
itt(size_type string::rfind(char c, size_type opos)):
quote( Returns the index in the tt(string) object where tt(c) is
quote( returns the index in the tt(string) object where tt(c) is
found. Searching proceeds either from the end of the tt(string) object (or
from offset tt(opos), if specified) back to the beginning.)
@ -357,7 +359,7 @@ object. This member is a synonym of tt(string::length()).)
it() hi(string::substr())
tt(string string::substr(size_type opos, size_type on)):
quote(Returns (using a em(value) return type) a substring of the
quote(returns (using a em(value) return type) a substring of the
tt(string) object. The string tt(object) itself is not modified by
tt(substr()).)

View file

@ -14,39 +14,46 @@ a new value. The entity referred to by tt(argument) always remains unchanged.
Furthermore, tt(opos) indicates an offset into the tt(object) string, tt(apos)
indicates an offset into the tt(argument) string. Analogously, tt(on)
indicates a number of characters in the tt(object) string, and tt(an)
indicates a number of characters in the tt(argument) string. Both tt(opos) and
tt(apos) must refer to existing offsets, or an exception will be generated. In
contrast to this, tt(an) and tt(on) may exceed the number of available
characters, in which case only the available characters will be considered.
indicates a number of characters in the tt(argument) string.
With many members, default values are available for tt(on, an, opos) and
tt(apos). By default, tt(apos) and tt(opos) are 0, while tt(on) and tt(an) can
by default be interpreted as `the required number of characters to reach the
end of the string'. In the overviuw of member functions presented below it can
be assumed that all these parameters accept default values unless indicated
otherwise. With members starting their operations at the end of the strting
object proceeding backwards, tt(opos) receives the index of the object's
em(last) character as its initial value, and tt(on) refers to the length of
the substring em(ending) at the character at tt(opos). Of course, no defaults
are accepted if a function requires additional arguments beyond the ones
normally offering default values.
Both tt(opos) and tt(apos) must refer to existing offsets, or an exception
will be generated. In contrast to this, tt(an) and tt(on) may exceed the
number of available characters, in which case only the available characters
will be considered.
With many members, default values are available for tt(on, an) and
tt(apos). Some members accept default values for tt(opos). By default,
tt(apos) and tt(opos) are 0, while tt(on) and tt(an) can by default be
interpreted as `the required number of characters to reach the end of the
string'; where needed this can be made explicit by providing the
generic value tt(string::npos).
With members starting their operations at the end of the string object
proceeding backwards, the default value of tt(opos) becomes the index of the
object's em(last) character, while tt(on) refers to the
length of the substring em(ending) at the character at tt(opos).
In the overviuw of member functions presented below it can be assumed that all
these parameters accept default values unless indicated otherwise.
Of course, no defaults are accepted if a function requires additional
arguments beyond the ones normally offering default values.
Some members have specific overloaded versions for an initial argument of type
tt(char const *). However, note that the first argument can always be
of type tt(char const *), using promotions to convert the tt(char const *) to
a tt(std::string const &) first.
tt(char const *). However, note that the first argument can em(always) be of
type tt(char const *), using em(promotions) to convert the tt(char const *) to
a tt(std::string const &).
When streams are involved, tt(istr) indicates a stream from which information
is extracted, tt(ostr) indicates a stream into which information is inserted.
With member functions the types of the parameters are given in a
function-prototypical way. With several member functions em(iterators) are
used. At this point in the Annotations it's a bit premature to discuss
iterators, but for referential purposes they have to be mentioned
nevertheless. So, a forward reference is used here: see section ref(ITERATORS)
for a more detailed discussion of em(iterators). Like tt(apos) and tt(opos),
iterators must also refer to an existing character, or to an available
iterator range of the string to which they refer.
Several member functions accept em(iterators). At this point in the
Annotations it's a bit premature to discuss iterators, but for referential
purposes they nevertheless have to be mentioned. So, a forward reference is
used here: see section ref(ITERATORS) for a more detailed discussion of
em(iterators). Like tt(apos) and tt(opos), iterators must refer to
existing characters, or to a defined range of characters within the string
to which they refer.
Finally, note that all tt(string)-member functions returning indices in
tt(object) return the predefined constant ti(string::npos) if no