nlib
StringView.h ファイル

std::stringが持つ機能の一部をデータの複製なしに実現するためのクラスが定義されています。 [詳解]

#include <algorithm>
#include <iterator>
#include <utility>
#include "nn/nlib/Config.h"
#include "nn/nlib/UniquePtr.h"
#include "nn/nlib/Cstring.h"

[ソースコード]

クラス

class  nn::nlib::StringView
 std::stringが持つメソッドをstd::stringを構築せずに利用するためのクラスです。 C++17のstring_viewにtypedefされる予定です。 StringViewを引数に取るフリー関数についてはこちらを御覧ください。 [詳解]
 

名前空間

 nn::nlib
 共通して使われることの多いストリーム関連のクラス群や各種コンテナ、及びガシェットクラスが実装されています。nlib_nsはエイリアスです。
 

関数

bool nn::nlib::operator== (const StringView &lhs, const StringView &rhs) noexcept
 文字列が一致するかどうか比較します。
 
bool nn::nlib::operator< (const StringView &lhs, const StringView &rhs) noexcept
 文字列を辞書順で比較します。
 
bool nn::nlib::StartsWith (const StringView &str, const StringView &prefix) noexcept
 prefixstrのプレフィックスである場合trueを返します。
 
bool nn::nlib::StartsWith (const StringView &str, char c) noexcept
 cstrのプレフィックスである場合trueを返します。
 
bool nn::nlib::StartsWith (const StringView &str, const char *prefix) noexcept
 prefixstrのプレフィックスである場合trueを返します。
 
bool nn::nlib::EndsWith (const StringView &str, const StringView &suffix) noexcept
 suffixstrのサフィックスである場合trueを返します。
 
bool nn::nlib::EndsWith (const StringView &str, char c) noexcept
 cstrのサフィックスである場合trueを返します。
 
bool nn::nlib::EndsWith (const StringView &str, const char *suffix) noexcept
 suffixstrのサフィックスである場合trueを返します。
 
bool nn::nlib::ToCstring (char *buf, size_t buf_size, const StringView &str) noexcept
 ヌル終端文字列として文字列をコピーします。コピーできた場合はtrueを返します。
 
template<size_t N>
bool nn::nlib::ToCstring (char(&buf)[N], const StringView &str) noexcept
 ヌル終端文字列として文字列をコピーします。コピーできた場合はtrueを返します。
 
UniquePtr< char[]> nn::nlib::ToCstring (const StringView &str) noexcept
 メモリを割り当ててヌル終端文字列として文字列をコピーします。コピーできた場合はtrueを返します。
 
std::pair< errno_t, size_t > nn::nlib::ToInteger (int8_t *v, const StringView &str, int base) noexcept
 内部でnlib_int8_from_chars()を呼び出して、文字列を数値に変換します。戻り値はエラー値と読み込んだ文字数のペアです。
 
std::pair< errno_t, size_t > nn::nlib::ToInteger (int16_t *v, const StringView &str, int base) noexcept
 内部でnlib_int16_from_chars()を呼び出して、文字列を数値に変換します。戻り値はエラー値と読み込んだ文字数のペアです。
 
std::pair< errno_t, size_t > nn::nlib::ToInteger (int32_t *v, const StringView &str, int base) noexcept
 内部でnlib_int32_from_chars()を呼び出して、文字列を数値に変換します。戻り値はエラー値と読み込んだ文字数のペアです。
 
std::pair< errno_t, size_t > nn::nlib::ToInteger (int64_t *v, const StringView &str, int base) noexcept
 内部でnlib_int64_from_chars()を呼び出して、文字列を数値に変換します。戻り値はエラー値と読み込んだ文字数のペアです。
 
std::pair< errno_t, size_t > nn::nlib::ToInteger (uint8_t *v, const StringView &str, int base) noexcept
 内部でnlib_uint8_from_chars()を呼び出して、文字列を数値に変換します。戻り値はエラー値と読み込んだ文字数のペアです。
 
std::pair< errno_t, size_t > nn::nlib::ToInteger (uint16_t *v, const StringView &str, int base) noexcept
 内部でnlib_uint16_from_chars()を呼び出して、文字列を数値に変換します。戻り値はエラー値と読み込んだ文字数のペアです。
 
std::pair< errno_t, size_t > nn::nlib::ToInteger (uint32_t *v, const StringView &str, int base) noexcept
 内部でnlib_uint32_from_chars()を呼び出して、文字列を数値に変換します。戻り値はエラー値と読み込んだ文字数のペアです。
 
std::pair< errno_t, size_t > nn::nlib::ToInteger (uint64_t *v, const StringView &str, int base) noexcept
 内部でnlib_uint64_from_chars()を呼び出して、文字列を数値に変換します。戻り値はエラー値と読み込んだ文字数のペアです。
 
std::pair< errno_t, size_t > nn::nlib::ToFloat (float *v, const StringView &str) noexcept
 内部でnlib_float_from_chars()を呼び出して、文字列を数値に変換します。戻り値はエラー値と読み込んだ文字数のペアです。
 
std::pair< errno_t, size_t > nn::nlib::ToDouble (double *v, const StringView &str) noexcept
 内部でnlib_double_from_chars()を呼び出して、文字列を数値に変換します。戻り値はエラー値と読み込んだ文字数のペアです。
 
template<class T >
std::pair< errno_t, size_t > nn::nlib::ToInteger (T *v, const StringView &str) noexcept
 ToInteger(v, str, 10)を返します。つまり10進数として文字列を数値に変換します。
 
bool nn::nlib::TrimLeft (StringView &str) noexcept
 文字列の先頭の空白を切り詰めます。 [詳解]
 
bool nn::nlib::TrimRight (StringView &str) noexcept
 文字列の末尾の空白を切り詰めます。 [詳解]
 
void nn::nlib::Trim (StringView &str) noexcept
 文字列の先頭と末尾の空白を切り詰めます。
 
StringView nn::nlib::GetLine (StringView &str) noexcept
 先頭から行末までの文字列を取得します。自身のオブジェクト(str)は次の行の行頭に移動します。 [詳解]
 
bool nn::nlib::Proceed (StringView &str, const StringView &prefix) noexcept
 strprefixで始まっていればその文字列長だけ進めます。 [詳解]
 
bool nn::nlib::Proceed (StringView &str, const char *prefix) noexcept
 strprefixで始まっていればその文字列長だけ進めます。 [詳解]
 
bool nn::nlib::Proceed (StringView &str, char c) noexcept
 strcで始まっていればその文字列長だけ進めます。 [詳解]
 
StringView nn::nlib::GetName (StringView &str) noexcept
 一般に変数名とされるような文字列を取得します。自身のオブジェクト(str)は取得した文字列の次に移動します。 [詳解]
 

詳解

std::stringが持つ機能の一部をデータの複製なしに実現するためのクラスが定義されています。

StringView.h に定義があります。