nlib
|
The class for using the member functions of std::string
without constructing std::string
. This class will be defined as the string_view of C++17 using typedef. For more information about free functions taking StringView as the argument, seehere..
More...
#include "nn/nlib/StringView.h"
Public Types | |
typedef char | charT |
Currently a char -type specific class. | |
typedef charT | value_type |
The type for a character. | |
typedef const charT * | pointer |
The same as const_pointer . | |
typedef const charT * | const_pointer |
Read-only pointer to an element. | |
typedef const charT & | reference |
The same as const_reference . | |
typedef const charT & | const_reference |
Read-only reference to an element. | |
typedef const_pointer | const_iterator |
Read-only random-access iterator. | |
typedef const_iterator | iterator |
The same as const_iterator . | |
typedef std::reverse_iterator< const_iterator > | const_reverse_iterator |
Read-only reverse iterator. | |
typedef const_reverse_iterator | reverse_iterator |
The same as const_reverse_iterator | |
typedef size_t | size_type |
A non-negative integer type, currently defined in size_t using typedef . | |
typedef ptrdiff_t | difference_type |
The type returned when you take the difference between iterators. | |
Public Member Functions | |
constexpr | StringView () noexcept |
Instantiates the object with default parameters (default constructor). Initialized as an empty string. | |
StringView (const charT *str) noexcept | |
Initialized to reference str. The string length is calculated internally. | |
StringView (const charT *str, size_type len) noexcept | |
Initializes using the specified calculated string length. | |
const_iterator | begin () const noexcept |
Gets the read-only iterator pointing to the first element. | |
const_iterator | end () const noexcept |
Gets the read-only iterator pointing beyond the last element. | |
const_iterator | cbegin () const noexcept |
Gets the read-only iterator pointing to the first element. | |
const_iterator | cend () const noexcept |
Gets the read-only iterator pointing beyond the last element. | |
const_reverse_iterator | rbegin () const noexcept |
Gets the read-only reverse iterator pointing to the last element. | |
const_reverse_iterator | rend () const noexcept |
Gets the read-only reverse iterator pointing ahead of the first element. | |
const_reverse_iterator | crbegin () const noexcept |
Gets the read-only reverse iterator pointing to the last element. | |
const_reverse_iterator | crend () const noexcept |
Gets the read-only reverse iterator pointing ahead of the first element. | |
size_type | size () const noexcept |
Returns the length of the string. | |
size_type | length () const noexcept |
Returns the length of the string. | |
size_type | max_size () const noexcept |
Returns the maximum value for the string length. | |
bool | empty () const noexcept |
Returns true if it is an empty string, otherwise returns false . | |
const charT & | operator[] (size_type pos) const |
Gets the nth character, where n is specified by pos. More... | |
const charT & | at (size_type pos) const |
Gets the nth character, where n is specified by pos. More... | |
const charT & | front () const |
Gets a reference to the first element. | |
const charT & | back () const |
Gets a reference to the last element. | |
const charT * | data () const noexcept |
Returns the pointer to the first character. | |
void | clear () noexcept |
Sets an empty string. | |
void | remove_prefix (size_type n) noexcept |
Removes the first n characters. More... | |
void | remove_suffix (size_type n) noexcept |
Removes the last n characters. More... | |
StringView | substr (size_type pos, size_type n=npos) const noexcept |
Returns a substring [pos, pos + n). More... | |
int | compare (const StringView &s) const noexcept |
Compares strings. More... | |
int | compare (const charT *s) const noexcept |
Compares strings. More... | |
Static Public Attributes | |
static const size_type | npos = size_type(-1) |
Used the same way as npos of std::string . | |
The class for using the member functions of std::string
without constructing std::string
. This class will be defined as the string_view of C++17 using typedef. For more information about free functions taking StringView as the argument, seehere..
Definition at line 46 of file StringView.h.
|
inline |
Gets the nth character, where n is specified by pos.
[in] | pos | An index of a character. |
Definition at line 104 of file StringView.h.
|
noexcept |
Compares strings.
[in] | s | The string to compare with. |
std::strcmp
function.
|
inlinenoexcept |
Compares strings.
[in] | s | The string to compare with. |
std::strcmp
function. Definition at line 144 of file StringView.h.
|
inline |
Gets the nth character, where n is specified by pos.
[in] | pos | An index of a character. |
Definition at line 100 of file StringView.h.
|
inlinenoexcept |
Removes the first n characters.
[in] | n | The number of characters to remove. |
Definition at line 117 of file StringView.h.
|
inlinenoexcept |
Removes the last n characters.
[in] | n | The number of characters to remove. |
Definition at line 126 of file StringView.h.
Returns a substring [pos, pos + n).
[in] | pos | The first position of the substring. |
[in] | n | Length of the substring. |
Definition at line 135 of file StringView.h.
© Nintendo Co., Ltd. All rights reserved.