UdonLibrary 1.0.0
機械システム研究部 C++ ライブラリ
読み取り中…
検索中…
一致する文字列を見つけられません
Udon::BasicStringView< CharType, Traits > クラステンプレート

文字列参照クラス [詳解]

#include <Udon/Types/StringView.hpp>

公開型

using size_type = size_t
 
using traits_type = Traits
 
using char_type = typename traits_type::char_type
 
using int_type = typename traits_type::int_type
 
using off_type = typename traits_type::off_type
 
using pos_type = typename traits_type::pos_type
 
using state_type = typename traits_type::state_type
 
using const_reference = const char_type&
 
using const_pointer = const char_type*
 
using const_iterator = const char_type*
 
using const_receive_iterator = std::reverse_iterator<const_iterator>
 

公開メンバ関数

constexpr BasicStringView ()
 デフォルトコンストラクタ
 
 BasicStringView (const_pointer string)
 文字列の先頭を指すポインタをもとにビューを構築
 
constexpr BasicStringView (const_pointer string, const size_type length)
 文字列の先頭を指すポインタ、サイズをもとにビューを構築
 
template<typename InputIterator , typename = typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIterator>::iterator_category, std::input_iterator_tag>::value>::type>
constexpr BasicStringView (InputIterator begin, InputIterator end)
 要素を指すイテレータをもとにビューを構築
 
 BasicStringView (const std::basic_string< CharType > &string)
 std::string からの変換
 
 BasicStringView (const BasicStringView &)=default
 デフォルトコピーコンストラクタ
 
BasicStringViewoperator= (const BasicStringView &)=default
 デフォルト代入演算子
 
constexpr operator bool () const noexcept
 ビューが要素を持つか
 
constexpr const_pointer data () const noexcept
 ビューへのポインタを取得する
 
constexpr size_type size () const noexcept
 ビューのサイズを取得する
 
constexpr bool empty () const noexcept
 ビュー終端にヌル終端文字を含むことは保証されないので c_str() は提供しない
 
constexpr const_reference operator[] (const size_type index) const noexcept
 指定されたインデックスの文字を取得する
 
const_reference at (const size_type index) const noexcept
 指定されたインデックスの文字を取得する
 
constexpr const_reference front () const noexcept
 ビューの先頭文字を取得する
 
constexpr const_reference back () const noexcept
 ビューの終端の文字を取得する
 
BasicStringView substring (const size_type beginIndex, const size_type endIndex=npos) const
 指定された範囲のビューを作成する
 
BasicStringView substringUntil (const char_type terminate) const
 指定された終端文字までのビューを作成する
 
BasicStringView removePrefix (const size_type n) const
 先頭のN文字を削除したビューを作成する
 
BasicStringView removeSuffix (const size_type n) const
 末尾のN文字を削除したビューを作成する
 
bool startsWith (const BasicStringView &string) const noexcept
 ビューが指定したビューから始まっているか判定する
 
bool endsWith (const BasicStringView &string) const noexcept
 ビューが指定したビューで終わっているか判定する
 
std::vector< BasicStringViewsplit (const char_type delimiter) const
 指定された区切り文字で区切り、ビューのリストを作成する
 
template<typename T = int>
Udon::Optional< T > toNumber (const int radix=10) const
 ビューを数値に変換する
 
std::basic_string< char_typetoString () const
 STL の文字列に変換する
 
void swap (BasicStringView &other) noexcept
 ビューを入れ替える
 
const_iterator begin () const noexcept
 
const_iterator end () const noexcept
 
const_iterator cbegin () const noexcept
 
const_iterator cend () const noexcept
 
const_receive_iterator rbegin () const noexcept
 
const_receive_iterator rend () const noexcept
 
const_receive_iterator crbegin () const noexcept
 
const_receive_iterator crend () const noexcept
 

静的公開変数類

static constexpr size_type npos = static_cast<size_type>(-1)
 

フレンド

bool operator== (const BasicStringView &lhs, const BasicStringView &rhs) noexcept
 ビューが一致するか比較する
 
bool operator!= (const BasicStringView &lhs, const BasicStringView &rhs) noexcept
 ビューが不一致であるか比較する
 
std::basic_ostream< char_type > & operator<< (std::basic_ostream< char_type > &os, const BasicStringView &string)
 std::ostream への出力
 

詳解

template<typename CharType, typename Traits = std::char_traits<CharType>>
class Udon::BasicStringView< CharType, Traits >

文字列参照クラス

覚え書き
メモリ所有権を持たず、std::string の様なヒープへのメモリアロケーションが発生しません
テンプレート引数
CharType文字列の各要素の型
Traits

型定義メンバ詳解

◆ char_type

template<typename CharType , typename Traits = std::char_traits<CharType>>
using Udon::BasicStringView< CharType, Traits >::char_type = typename traits_type::char_type

◆ const_iterator

template<typename CharType , typename Traits = std::char_traits<CharType>>
using Udon::BasicStringView< CharType, Traits >::const_iterator = const char_type*

◆ const_pointer

template<typename CharType , typename Traits = std::char_traits<CharType>>
using Udon::BasicStringView< CharType, Traits >::const_pointer = const char_type*

◆ const_receive_iterator

template<typename CharType , typename Traits = std::char_traits<CharType>>
using Udon::BasicStringView< CharType, Traits >::const_receive_iterator = std::reverse_iterator<const_iterator>

◆ const_reference

template<typename CharType , typename Traits = std::char_traits<CharType>>
using Udon::BasicStringView< CharType, Traits >::const_reference = const char_type&

◆ int_type

template<typename CharType , typename Traits = std::char_traits<CharType>>
using Udon::BasicStringView< CharType, Traits >::int_type = typename traits_type::int_type

◆ off_type

template<typename CharType , typename Traits = std::char_traits<CharType>>
using Udon::BasicStringView< CharType, Traits >::off_type = typename traits_type::off_type

◆ pos_type

template<typename CharType , typename Traits = std::char_traits<CharType>>
using Udon::BasicStringView< CharType, Traits >::pos_type = typename traits_type::pos_type

◆ size_type

template<typename CharType , typename Traits = std::char_traits<CharType>>
using Udon::BasicStringView< CharType, Traits >::size_type = size_t

◆ state_type

template<typename CharType , typename Traits = std::char_traits<CharType>>
using Udon::BasicStringView< CharType, Traits >::state_type = typename traits_type::state_type

◆ traits_type

template<typename CharType , typename Traits = std::char_traits<CharType>>
using Udon::BasicStringView< CharType, Traits >::traits_type = Traits

構築子と解体子

◆ BasicStringView() [1/6]

template<typename CharType , typename Traits = std::char_traits<CharType>>
Udon::BasicStringView< CharType, Traits >::BasicStringView ( )
inlineconstexpr

デフォルトコンストラクタ

◆ BasicStringView() [2/6]

template<typename CharType , typename Traits = std::char_traits<CharType>>
Udon::BasicStringView< CharType, Traits >::BasicStringView ( const_pointer string)
inline

文字列の先頭を指すポインタをもとにビューを構築

覚え書き
null終端文字が必須です
引数
string

◆ BasicStringView() [3/6]

template<typename CharType , typename Traits = std::char_traits<CharType>>
Udon::BasicStringView< CharType, Traits >::BasicStringView ( const_pointer string,
const size_type length )
inlineconstexpr

文字列の先頭を指すポインタ、サイズをもとにビューを構築

引数
string先頭を指すポインタ
size要素数

◆ BasicStringView() [4/6]

template<typename CharType , typename Traits = std::char_traits<CharType>>
template<typename InputIterator , typename = typename std::enable_if<std::is_convertible<typename std::iterator_traits<InputIterator>::iterator_category, std::input_iterator_tag>::value>::type>
Udon::BasicStringView< CharType, Traits >::BasicStringView ( InputIterator begin,
InputIterator end )
inlineconstexpr

要素を指すイテレータをもとにビューを構築

テンプレート引数
InputIteratorSTLの入力イテレータ要件に則す必要ある
引数
begin
end

◆ BasicStringView() [5/6]

template<typename CharType , typename Traits = std::char_traits<CharType>>
Udon::BasicStringView< CharType, Traits >::BasicStringView ( const std::basic_string< CharType > & string)
inline

std::string からの変換

覚え書き
一時オブジェクトからの変換は禁止(ダングリングポインタになる)
引数
string

◆ BasicStringView() [6/6]

template<typename CharType , typename Traits = std::char_traits<CharType>>
Udon::BasicStringView< CharType, Traits >::BasicStringView ( const BasicStringView< CharType, Traits > & )
default

デフォルトコピーコンストラクタ

関数詳解

◆ at()

template<typename CharType , typename Traits = std::char_traits<CharType>>
const_reference Udon::BasicStringView< CharType, Traits >::at ( const size_type index) const
inlinenoexcept

指定されたインデックスの文字を取得する

◆ back()

template<typename CharType , typename Traits = std::char_traits<CharType>>
const_reference Udon::BasicStringView< CharType, Traits >::back ( ) const
inlineconstexprnoexcept

ビューの終端の文字を取得する

戻り値

◆ begin()

template<typename CharType , typename Traits = std::char_traits<CharType>>
const_iterator Udon::BasicStringView< CharType, Traits >::begin ( ) const
inlinenoexcept

◆ cbegin()

template<typename CharType , typename Traits = std::char_traits<CharType>>
const_iterator Udon::BasicStringView< CharType, Traits >::cbegin ( ) const
inlinenoexcept

◆ cend()

template<typename CharType , typename Traits = std::char_traits<CharType>>
const_iterator Udon::BasicStringView< CharType, Traits >::cend ( ) const
inlinenoexcept

◆ crbegin()

template<typename CharType , typename Traits = std::char_traits<CharType>>
const_receive_iterator Udon::BasicStringView< CharType, Traits >::crbegin ( ) const
inlinenoexcept

◆ crend()

template<typename CharType , typename Traits = std::char_traits<CharType>>
const_receive_iterator Udon::BasicStringView< CharType, Traits >::crend ( ) const
inlinenoexcept

◆ data()

template<typename CharType , typename Traits = std::char_traits<CharType>>
const_pointer Udon::BasicStringView< CharType, Traits >::data ( ) const
inlineconstexprnoexcept

ビューへのポインタを取得する

戻り値

◆ empty()

template<typename CharType , typename Traits = std::char_traits<CharType>>
bool Udon::BasicStringView< CharType, Traits >::empty ( ) const
inlineconstexprnoexcept

ビュー終端にヌル終端文字を含むことは保証されないので c_str() は提供しない

ビューのサイズが0か判定

戻り値

◆ end()

template<typename CharType , typename Traits = std::char_traits<CharType>>
const_iterator Udon::BasicStringView< CharType, Traits >::end ( ) const
inlinenoexcept

◆ endsWith()

template<typename CharType , typename Traits = std::char_traits<CharType>>
bool Udon::BasicStringView< CharType, Traits >::endsWith ( const BasicStringView< CharType, Traits > & string) const
inlinenoexcept

ビューが指定したビューで終わっているか判定する

引数
string判定するビュー
戻り値

◆ front()

template<typename CharType , typename Traits = std::char_traits<CharType>>
const_reference Udon::BasicStringView< CharType, Traits >::front ( ) const
inlineconstexprnoexcept

ビューの先頭文字を取得する

戻り値

◆ operator bool()

template<typename CharType , typename Traits = std::char_traits<CharType>>
Udon::BasicStringView< CharType, Traits >::operator bool ( ) const
inlineexplicitconstexprnoexcept

ビューが要素を持つか

◆ operator=()

template<typename CharType , typename Traits = std::char_traits<CharType>>
BasicStringView & Udon::BasicStringView< CharType, Traits >::operator= ( const BasicStringView< CharType, Traits > & )
default

デフォルト代入演算子

◆ operator[]()

template<typename CharType , typename Traits = std::char_traits<CharType>>
const_reference Udon::BasicStringView< CharType, Traits >::operator[] ( const size_type index) const
inlineconstexprnoexcept

指定されたインデックスの文字を取得する

引数
index
戻り値

◆ rbegin()

template<typename CharType , typename Traits = std::char_traits<CharType>>
const_receive_iterator Udon::BasicStringView< CharType, Traits >::rbegin ( ) const
inlinenoexcept

◆ removePrefix()

template<typename CharType , typename Traits = std::char_traits<CharType>>
BasicStringView Udon::BasicStringView< CharType, Traits >::removePrefix ( const size_type n) const
inline

先頭のN文字を削除したビューを作成する

引数
n削除する文字数
戻り値
作成されたビュー

◆ removeSuffix()

template<typename CharType , typename Traits = std::char_traits<CharType>>
BasicStringView Udon::BasicStringView< CharType, Traits >::removeSuffix ( const size_type n) const
inline

末尾のN文字を削除したビューを作成する

引数
n削除する文字数
戻り値
作成されたビュー

◆ rend()

template<typename CharType , typename Traits = std::char_traits<CharType>>
const_receive_iterator Udon::BasicStringView< CharType, Traits >::rend ( ) const
inlinenoexcept

◆ size()

template<typename CharType , typename Traits = std::char_traits<CharType>>
size_type Udon::BasicStringView< CharType, Traits >::size ( ) const
inlineconstexprnoexcept

ビューのサイズを取得する

戻り値

◆ split()

template<typename CharType , typename Traits = std::char_traits<CharType>>
std::vector< BasicStringView > Udon::BasicStringView< CharType, Traits >::split ( const char_type delimiter) const
inline

指定された区切り文字で区切り、ビューのリストを作成する

引数
delimiter区切り文字
戻り値
ビューのリスト

◆ startsWith()

template<typename CharType , typename Traits = std::char_traits<CharType>>
bool Udon::BasicStringView< CharType, Traits >::startsWith ( const BasicStringView< CharType, Traits > & string) const
inlinenoexcept

ビューが指定したビューから始まっているか判定する

引数
string判定するビュー
戻り値
true: 始まっている false: 始まっていない

◆ substring()

template<typename CharType , typename Traits = std::char_traits<CharType>>
BasicStringView Udon::BasicStringView< CharType, Traits >::substring ( const size_type beginIndex,
const size_type endIndex = npos ) const
inline

指定された範囲のビューを作成する

引数
beginIndex開始位置
endIndex終端位置(ビューに含まれない)
戻り値
作成されたビュー

◆ substringUntil()

template<typename CharType , typename Traits = std::char_traits<CharType>>
BasicStringView Udon::BasicStringView< CharType, Traits >::substringUntil ( const char_type terminate) const
inline

指定された終端文字までのビューを作成する

引数
terminate終端文字(ビューに含まれない)
覚え書き
開始位置は現在のビューの開始位置
戻り値
作成されたビュー

◆ swap()

template<typename CharType , typename Traits = std::char_traits<CharType>>
void Udon::BasicStringView< CharType, Traits >::swap ( BasicStringView< CharType, Traits > & other)
inlinenoexcept

ビューを入れ替える

引数
other入れ変え先

◆ toNumber()

template<typename CharType , typename Traits = std::char_traits<CharType>>
template<typename T = int>
Udon::Optional< T > Udon::BasicStringView< CharType, Traits >::toNumber ( const int radix = 10) const
inline

ビューを数値に変換する

テンプレート引数
T変換する数値の型
引数
radix基数(整数のみ)
戻り値
変換された数値 (変換できない場合はnullopt)

◆ toString()

template<typename CharType , typename Traits = std::char_traits<CharType>>
std::basic_string< char_type > Udon::BasicStringView< CharType, Traits >::toString ( ) const
inline

STL の文字列に変換する

覚え書き
メモリアロケーションが発生します。
戻り値
文字列

フレンドと関連関数の詳解

◆ operator!=

template<typename CharType , typename Traits = std::char_traits<CharType>>
bool operator!= ( const BasicStringView< CharType, Traits > & lhs,
const BasicStringView< CharType, Traits > & rhs )
friend

ビューが不一致であるか比較する

引数
lhs被演算子
rhs被演算子
戻り値
不一致かどうか

◆ operator<<

template<typename CharType , typename Traits = std::char_traits<CharType>>
std::basic_ostream< char_type > & operator<< ( std::basic_ostream< char_type > & os,
const BasicStringView< CharType, Traits > & string )
friend

std::ostream への出力

◆ operator==

template<typename CharType , typename Traits = std::char_traits<CharType>>
bool operator== ( const BasicStringView< CharType, Traits > & lhs,
const BasicStringView< CharType, Traits > & rhs )
friend

ビューが一致するか比較する

引数
lhs被演算子
rhs被演算子
戻り値
一致するかどうか

メンバ詳解

◆ npos

template<typename CharType , typename Traits = std::char_traits<CharType>>
size_type Udon::BasicStringView< CharType, Traits >::npos = static_cast<size_type>(-1)
staticconstexpr

このクラス詳解は次のファイルから抽出されました: