📄 string_.gml
字号:
:LIBF fmt='fun'.operator >>
:SNPL.
:SNPFLF .#include <string.hpp>
:SNPFLF .public:
:SNPR index='operator >>'.friend istream &.operator >>( istream &.strm, String &.str );
:eSNPL.
:SMTICS.
The &fn. is used to read a sequence of characters from the
:ARG.strm
:MONO.istream
object into the
:ARG.str
&obj.:PERIOD.
Like C strings, the gathering of characters for a
:ARG.str
&obj. ends at the first whitespace encountered, so that the last
character placed in
:ARG.str
is the character before the whitespace.
:RSLTS.
The &fn. returns a reference to the
:ARG.strm
parameter.
:SALSO.
:SAL typ='cls'.istream
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public'.operator []
:SNPL.
:SNPFLF .#include <string.hpp>
:SNPFLF .public:
:SNPF index='operator []'.char const &.String::operator []( size_t pos ) const;
:SNPF index='operator []'.char &.String::operator []( size_t pos );
:eSNPL.
:SMTICS.
The &fn. creates either a const or a non-const reference to the character
at offset
:ARG.pos
within the &obj.:PERIOD.
The non-const reference may be used to modify that character.
The first character of a &obj. is at position zero.
:P.
If
:ARG.pos
is greater than or equal to the length of the &obj.,
and the resulting reference is used, the behavior is undefined.
:P.
If the non-const reference is used to modify other characters within the
&obj., the behavior is undefined.
:P.
The reference is associated with the &obj., and therefore has meaning only
as long as the &obj. is not modified (or destroyed).
If the &obj. has been modified and an old reference is used, the
behavior is undefined.
:RSLTS.
The &fn. returns either a const or a non-const reference to a character.
:SALSO.
:SAL typ='mfun'.operator~b()
:SAL typ='mfun'.operator~bchar
:SAL typ='mfun'.operator~bchar~bconst~b*
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public'.operator char
:SNPL.
:SNPFLF .#include <string.hpp>
:SNPFLF .public:
:SNPF index='operator char'.String::operator char();
:eSNPL.
:SMTICS.
The &fn. converts a &obj. into the first character it contains.
If the &obj. is empty, the result is the null character.
:RSLTS.
The &fn. returns the first character contained in the &obj.:PERIOD.
If the
&obj. is empty, the null character is returned.
:SALSO.
:SAL typ='mfun'.operator~b()
:SAL typ='mfun'.operator~b[]
:SAL typ='mfun'.operator~bchar~bconst~b*
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public'.operator char const *
:SNPL.
:SNPFLF .#include <string.hpp>
:SNPFLF .public:
:SNPF index='operator char const *'.String::operator char const *();
:eSNPL.
:SMTICS.
The &fn. converts a &obj. into a C string containing the same length and
sequence of characters, terminated by a null character. If the &obj.
contains a null character the resulting C string is terminated by that
null character.
:P.
The returned pointer is associated with the &obj., and therefore has meaning
only as long as the &obj. is not modified. If the intention is
to be able to refer to the C string after the &obj. has been modified, a
copy of the string should be made, perhaps by using the C library
:MONO.strdup
function.
:P.
The returned pointer is a pointer to a constant C string. If the pointer is
used in some way to modify the C string, the behavior is undefined.
:RSLTS.
The &fn. returns a pointer to a null-terminated constant C string
that contains the same characters as the &obj.:PERIOD.
:SALSO.
:SAL typ='mfun'.operator~b()
:SAL typ='mfun'.operator~b[]
:SAL typ='mfun'.operator~bchar
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public'.put_at
:SNPL.
:SNPFLF .#include <string.hpp>
:SNPFLF .public:
:SNPF index='put_at'.void String::put_at( size_t pos, char chr );
:eSNPL.
:SMTICS.
The &fn. modifies the character at offset
:ARG.pos
within the &obj.:PERIOD.
The character at the specified offset is set to the value of
:ARG.chr
:PERIOD.
If
:ARG.pos
is greater than the number of characters within the &obj.,
:ARG.chr
is appended to the &obj.:PERIOD.
:P.
:RSLTS.
The &fn. has no return value.
:SALSO.
:SAL typ='mfun'.get_at
:SAL typ='mfun'.operator~b[]
:SAL typ='mfun'.operator~b()
:SAL typ='mfun'.operator~b+=
:SAL typ='mfun'.operator~b+
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='ctor' prot='public'.String
:SNPL.
:SNPFLF .#include <string.hpp>
:SNPFLF .public:
:SNPCD cd_idx='c'.String::String();
:eSNPL.
:SMTICS.
This form of the &fn. creates a default &obj. containing no characters.
The created &obj. has length zero.
:RSLTS.
This form of the &fn. produces a &obj.:PERIOD.
:SALSO.
:SAL typ='mfun'.operator~b=
:SAL typ='mfun'.operator~b+=
:SAL typ='dtor'.
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='ctor' prot='public'.String
:SNPL.
:SNPFLF .#include <string.hpp>
:SNPFLF .public:
:SNPCD cd_idx='c'.String::String( size_t size, String::capacity cap );
:eSNPL.
:SMTICS.
This form of the &fn. creates a &obj.
:PERIOD.
The function constructs a &obj. of length
:ARG.size
if
:ARG.cap
is equal to the enumerated
:ITALICS.default_size
:PERIOD.
The function reserves
:ARG.size
bytes of memory and sets the length of the &obj. to be zero if
:ARG.cap
is equal to the enumerated
:ITALICS.reserve
:PERIOD.
:RSLTS.
This form of the &fn. produces a &obj. of size
:ARG.size
:PERIOD.
:SALSO.
:SAL typ='mfun'.operator~b=
:SAL typ='dtor'.
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='ctor' prot='public'.String
:SNPL.
:SNPFLF .#include <string.hpp>
:SNPFLF .public:
:SNPCD cd_idx='c'.String::String( String const &.str,
:SNPFLF . size_t pos = 0,
:SNPFLF . size_t num = NPOS );
:eSNPL.
:SMTICS.
This form of the &fn. creates a &obj. which contains a sub-string of the
:ARG.str
parameter.
The sub-string starts at position
:ARG.pos
within
:ARG.str
and continues for
:ARG.num
characters or until the end of the
:ARG.str
parameter, whichever comes first.
:RSLTS.
This form of the &fn. produces a sub-string or duplicate of the
:ARG.str
parameter.
:SALSO.
:SAL typ='mfun'.operator~b=
:SAL typ='mfun'.operator~b()
:SAL typ='mfun'.operator~b[]
:SAL typ='dtor'.
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='ctor' prot='public'.String
:SNPL.
:SNPFLF .#include <string.hpp>
:SNPFLF .public:
:SNPCD cd_idx='c'.String::String( char const *pch, size_t num = NPOS );
:eSNPL.
:SMTICS.
This form of the &fn. creates a &obj. from a C string.
The &obj. contains the sequence of characters located at the
:ARG.pch
parameter.
Characters are included up to
:ARG.num
or the end of the C string pointed at by
:ARG.pch
:PERIOD.
Note that C strings are terminated by a null character and that
the value of the created &obj. does not contain that character, nor any
following it.
:RSLTS.
This form of the &fn. produces a &obj. of at most length
:ARG.n
containing the characters in the C string starting at the
:ARG.pch
parameter.
:SALSO.
:SAL typ='mfun'.operator~b=
:SAL typ='mfun'.operator~bchar~bconst~b*
:SAL typ='mfun'.operator~b()
:SAL typ='mfun'.operator~b[]
:SAL typ='dtor'.
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='ctor' prot='public'.String
:SNPL.
:SNPFLF .#include <string.hpp>
:SNPFLF .public:
:SNPCD cd_idx='c'.String::String( char ch, size_t rep = 1 );
:eSNPL.
:SMTICS.
This form of the &fn. creates a &obj. containing
:ARG.rep
copies of the
:ARG.ch
parameter.
:RSLTS.
This form of the &fn. produces a &obj. of length
:ARG.rep
containing only the character specified by the
:ARG.ch
parameter.
:SALSO.
:SAL typ='mfun'.operator~b=
:SAL typ='mfun'.operator~bchar
:SAL typ='dtor'.
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='dtor' prot='public'.~~String
:SNPL.
:SNPFLF .#include <string.hpp>
:SNPFLF .public:
:SNPCD cd_idx='d'.String::~~String();
:eSNPL.
:SMTICS.
The &fn. destroys the &obj.:PERIOD.
The call to the &fn. is inserted implicitly by the compiler
at the point where the &obj. goes out of scope.
:RSLTS.
The &obj. is destroyed.
:SALSO.
:SAL typ='ctor'.
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public'.upper
:SNPL.
:SNPFLF .#include <string.hpp>
:SNPFLF .public:
:SNPF index='upper'.String String::upper() const;
:eSNPL.
:SMTICS.
The &fn. creates a new &obj. whose value is the same as the original &obj.,
except that all lower-case letters have been converted to upper-case.
:RSLTS.
The &fn. returns a new upper-case &obj.:PERIOD.
:SALSO.
:SAL typ='mfun'.lower
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='fun'.valid
:SNPL.
:SNPFLF .#include <string.hpp>
:SNPFLF .public:
:SNPR index='valid'.friend int valid( String const &.str );
:eSNPL.
:SMTICS.
The &fn. tests the validity of the
:ARG.str
&obj.:PERIOD.
:RSLTS.
The &fn. returns a non-zero value if the
:ARG.str
&obj. is valid, otherwise zero is returned.
:SALSO.
:SAL typ='mfun'.operator~b!
:SAL typ='mfun'.valid
:eSALSO.
:eLIBF.
:CMT.========================================================================
:LIBF fmt='mfun' prot='public'.valid
:SNPL.
:SNPFLF .#include <string.hpp>
:SNPFLF .public:
:SNPF index='valid'.int String::valid() const;
:eSNPL.
:SMTICS.
The &fn. tests the validity of the &obj.:PERIOD.
:RSLTS.
The &fn. returns a non-zero value if the &obj. is valid,
otherwise zero is returned.
:SALSO.
:SAL typ='mfun'.operator~b!
:SAL typ='fun'.valid
:eSALSO.
:eLIBF.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -