WebCFace 2.5.2
Web-based Communication Framework & Dashboard-like UI
Loading...
Searching...
No Matches
ValAdaptor Class Reference

数値、文字列などの値を相互変換するクラス More...

#include <webcface/common/val_adaptor.h>

Public Member Functions

 ValAdaptor ()
 
 ValAdaptor (const SharedString &str)
 
ValAdaptoroperator= (const SharedString &str)
 
 ValAdaptor (std::string_view str)
 
ValAdaptoroperator= (std::string_view str)
 
 ValAdaptor (const char *str)
 
ValAdaptoroperator= (const char *str)
 
 ValAdaptor (std::wstring_view str)
 
ValAdaptoroperator= (std::wstring_view str)
 
 ValAdaptor (const wchar_t *str)
 
ValAdaptoroperator= (const wchar_t *str)
 
 ValAdaptor (bool value)
 
ValAdaptoroperator= (bool v)
 
 ValAdaptor (std::int64_t value)
 
ValAdaptoroperator= (std::int64_t v)
 
 ValAdaptor (double value)
 
ValAdaptoroperator= (double v)
 
template<typename T , typename std::enable_if_t< std::is_integral_v< T >, std::nullptr_t > = nullptr>
 ValAdaptor (T value)
 
template<typename T , typename std::enable_if_t< std::is_integral_v< T >, std::nullptr_t > = nullptr>
ValAdaptoroperator= (T v)
 
template<typename T , typename std::enable_if_t< std::is_floating_point_v< T >, std::nullptr_t > = nullptr>
 ValAdaptor (T value)
 
template<typename T , typename std::enable_if_t< std::is_floating_point_v< T >, std::nullptr_t > = nullptr>
ValAdaptoroperator= (T v)
 
ValType valType () const
 
bool empty () const
 値が空かどうか調べる
 
const std::string & asStringRef () const
 文字列として返す
 
const std::wstring & asWStringRef () const
 文字列として返す (wstring)
 
const std::string & asU8StringRef () const
 
std::string asString () const
 文字列として返す(コピー)
 
std::wstring asWString () const
 文字列として返す(コピー) (wstring)
 
 operator const std::string & () const
 
 operator const std::wstring & () const
 
 operator const char * () const
 
 operator const wchar_t * () const
 
double asDouble () const
 実数として返す
 
int asInt () const
 int型の整数として返す
 
long long asLLong () const
 long long型の整数として返す
 
template<typename T >
double as () const
 数値として返す
 
template<typename T , typename std::enable_if_t< std::is_convertible_v< double, T > &&!std::is_same_v< T, bool >, std::nullptr_t > = nullptr>
 operator T () const
 数値型への変換
 
bool asBool () const
 bool値を返す
 
 operator bool () const
 
bool operator== (const ValAdaptor &other) const
 
bool operator!= (const ValAdaptor &other) const
 
template<typename T , typename std::enable_if_t< std::is_constructible_v< ValAdaptor, T > &&!std::is_same_v< ValAdaptor, T >, std::nullptr_t > = nullptr>
bool operator== (const T &other) const
 
template<typename T , typename std::enable_if_t< std::is_constructible_v< ValAdaptor, T > &&!std::is_same_v< ValAdaptor, T >, std::nullptr_t > = nullptr>
bool operator!= (const T &other) const
 

Static Public Member Functions

static const ValAdaptoremptyVal ()
 

Detailed Description

数値、文字列などの値を相互変換するクラス

数値の場合doubleまたはint64_tで保持する

数値型であっても文字列のインスタンスを内部に保持し、 ValAdaptorが破棄されるまでの間char*やstring_viewから参照できる

空の状態=空文字列

Constructor & Destructor Documentation

◆ ValAdaptor() [1/11]

◆ ValAdaptor() [2/11]

ValAdaptor ( const SharedString str)
explicit
Since
ver2.0

◆ ValAdaptor() [3/11]

ValAdaptor ( std::string_view  str)
explicit

◆ ValAdaptor() [4/11]

ValAdaptor ( const char *  str)
inlineexplicit

◆ ValAdaptor() [5/11]

ValAdaptor ( std::wstring_view  str)
explicit
Since
ver2.0

◆ ValAdaptor() [6/11]

ValAdaptor ( const wchar_t *  str)
inlineexplicit
Since
ver2.0

◆ ValAdaptor() [7/11]

ValAdaptor ( bool  value)
explicit

◆ ValAdaptor() [8/11]

ValAdaptor ( std::int64_t  value)
explicit

◆ ValAdaptor() [9/11]

ValAdaptor ( double  value)
explicit

◆ ValAdaptor() [10/11]

template<typename T , typename std::enable_if_t< std::is_integral_v< T >, std::nullptr_t > = nullptr>
ValAdaptor ( value)
inlineexplicit

◆ ValAdaptor() [11/11]

template<typename T , typename std::enable_if_t< std::is_floating_point_v< T >, std::nullptr_t > = nullptr>
ValAdaptor ( value)
inlineexplicit

Member Function Documentation

◆ as()

template<typename T >
double as ( ) const
inline

数値として返す

Since
ver1.10

as<T>(), Tはdoubleなどの実数型、intなどの整数型

Deprecated:
ver2.0〜 asDouble(), asInt(), asLLong() を追加 さらにas<T>にはTになにを指定してもdoubleで返るというバグがある

◆ asBool()

bool asBool ( ) const

bool値を返す

Since
ver1.10
  • 文字列型が入っていた場合、空文字列でなければtrueを返す
  • 数値型が入っていた場合、0でなければtrueを返す

◆ asDouble()

double asDouble ( ) const

実数として返す

Since
ver2.0

◆ asInt()

int asInt ( ) const

int型の整数として返す

Since
ver2.0

◆ asLLong()

long long asLLong ( ) const

long long型の整数として返す

Since
ver2.0

◆ asString()

std::string asString ( ) const
inline

文字列として返す(コピー)

Since
ver1.10

◆ asStringRef()

const std::string & asStringRef ( ) const

文字列として返す

Since
ver1.10

std::stringのconst参照を返す。 参照はこのValAdaptorが破棄されるまで有効

as_strにstringが格納されていた場合はそれをそのまま返す。 そうでない場合(u8string, wstring, double, int64が格納されている場合) はそれをstringに変換したうえでその参照を返す。

◆ asU8StringRef()

const std::string & asU8StringRef ( ) const
Since
ver2.0

◆ asWString()

std::wstring asWString ( ) const
inline

文字列として返す(コピー) (wstring)

Since
ver2.0

◆ asWStringRef()

const std::wstring & asWStringRef ( ) const

文字列として返す (wstring)

Since
ver2.0
See also
asStringRef()

◆ empty()

bool empty ( ) const

値が空かどうか調べる

Since
ver1.11

◆ emptyVal()

const ValAdaptor & emptyVal ( )
static

◆ operator bool()

operator bool ( ) const
inline

boolへ変換

◆ operator const char *()

operator const char * ( ) const
inline
Since
ver2.0

◆ operator const std::string &()

operator const std::string & ( ) const
inline

ver1.10〜: const参照

◆ operator const std::wstring &()

operator const std::wstring & ( ) const
inline
Since
ver2.0

◆ operator const wchar_t *()

operator const wchar_t * ( ) const
inline
Since
ver2.0

◆ operator T()

template<typename T , typename std::enable_if_t< std::is_convertible_v< double, T > &&!std::is_same_v< T, bool >, std::nullptr_t > = nullptr>
operator T ( ) const
inline

数値型への変換

◆ operator!=() [1/2]

template<typename T , typename std::enable_if_t< std::is_constructible_v< ValAdaptor, T > &&!std::is_same_v< ValAdaptor, T >, std::nullptr_t > = nullptr>
bool operator!= ( const T &  other) const
inline

◆ operator!=() [2/2]

bool operator!= ( const ValAdaptor other) const
inline

◆ operator=() [1/10]

ValAdaptor & operator= ( bool  v)

◆ operator=() [2/10]

ValAdaptor & operator= ( const char *  str)
inline

◆ operator=() [3/10]

ValAdaptor & operator= ( const SharedString str)
Since
ver2.0

◆ operator=() [4/10]

ValAdaptor & operator= ( const wchar_t *  str)
inline
Since
ver2.0

◆ operator=() [5/10]

ValAdaptor & operator= ( double  v)

◆ operator=() [6/10]

ValAdaptor & operator= ( std::int64_t  v)

◆ operator=() [7/10]

ValAdaptor & operator= ( std::string_view  str)

◆ operator=() [8/10]

ValAdaptor & operator= ( std::wstring_view  str)
Since
ver2.0

◆ operator=() [9/10]

template<typename T , typename std::enable_if_t< std::is_integral_v< T >, std::nullptr_t > = nullptr>
ValAdaptor & operator= ( v)
inline

◆ operator=() [10/10]

template<typename T , typename std::enable_if_t< std::is_floating_point_v< T >, std::nullptr_t > = nullptr>
ValAdaptor & operator= ( v)
inline

◆ operator==() [1/2]

template<typename T , typename std::enable_if_t< std::is_constructible_v< ValAdaptor, T > &&!std::is_same_v< ValAdaptor, T >, std::nullptr_t > = nullptr>
bool operator== ( const T &  other) const
inline

◆ operator==() [2/2]

bool operator== ( const ValAdaptor other) const

◆ valType()

ValType valType ( ) const
inline

The documentation for this class was generated from the following files: