Data Class Reference Data Types

#include <datatypebase.h>

详细描述

一般 数据 class. An object of this class can store every type of data as long as that type has been registered (see DataType ).

另请参阅
$ref datatype_data

公共成员函数

  数据 ()=default
Result < void >  Init (const DataType &type)
  ~Data ()
Bool   IsEmpty () const
Bool   IsPopulated () const
const DataType GetType () const
void  重置 ()
template<typename T >
  数据 (T &&data, typename std::enable_if< ! STD_IS_REPLACEMENT (same, typename std::decay< T >::type, 数据 ), DummyParamType * >::type=(DummyParamType *) nullptr)
  数据 ( 数据 && src )
数据 operator= ( 数据 && src )
Result < 数据 GetCopy () const
Result < void >  CopyFrom (const 数据 & src )
Result < void >  CopyFrom (const ConstDataPtr & src )
Result < void >  MoveFrom ( MoveDataPtr && src )
Result < void >  CopyFrom ( ForwardingDataPtr && src )
template<typename T >
Result < void >  Set (T &&data)
template<typename T >
Result < typename std::conditional< GetCollectionKind < T >::value== COLLECTION_KIND::ARRAY , T, typename ByValueParam < T >::type >::type >  Get () const
template<typename T >
Result < typename std::conditional< STD_IS_REPLACEMENT (void, T)||( GetCollectionKind < T >::value== COLLECTION_KIND::ARRAY ), T, T & >::type >  Get ()
template<typename T >
ByValueParam < T >::type  GetOrNull () const
template<typename T >
Get (const T &defaultValue) const
template<typename T >
Result < T >  转换 () const
template<typename T >
ConvertOrNull () const
template<typename T >
转换 (const T &defaultValue) const
Result < 数据 ConvertData (const DataType &destType) const
template<typename T >
T *  GetPtr ()
template<typename T >
const T *  GetPtr () const
Generic *  GetPtr (const DataType &type)
const Generic *  GetPtr (const DataType &type) const
const Generic *  PrivateGetPtr () const
const Generic *  PrivateGetPtr (const DataType &type) const
TupleValue GetTuple ()
const TupleValue GetTuple () const
String   ToString (const FormatStatement *formatStatement=nullptr) const
COMPARERESULT   比较 (const 数据 &c) const
HashInt   GetHashCode () const
Bool   IsEqual (const 数据 &other, EQUALITY equality= EQUALITY::DEEP ) const
Bool   operator== (const 数据 &other) const
Bool   operator!= (const 数据 &other) const
Bool   operator< (const 数据 &other) const
Bool   operator<= (const 数据 &other) const
Bool   operator> (const 数据 &other) const
Bool   operator>= (const 数据 &other) const
ConstDataPtr   ToConstDataPtr (const DataType &expectedType) const
template<>
void  InitSet ( 数据 &&data)
template<>
数据 GetPtr ()
template<>
Result < void >  Get () const
template<>
Result < void >  Set (const 数据 &value)
template<>
Result < void >  Set ( 数据 &value)
template<>
Result < void >  Set ( 数据 &&value)
template<>
void  InitSet ( HTTPREQUESTTYPE &&d)

静态公共成员函数

template<typename T >
static Result < 数据 创建 ()

私有成员函数

  MAXON_DISALLOW_COPY_AND_ASSIGN ( 数据 )
template<typename DEST , typename SRC >
Result < void >  SetImpl (SRC &&data, OverloadRank0 )
template<typename DEST >
Result < void >  SetImpl (const 数据 &data, OverloadRank1 )
template<typename DEST >
Result < void >  SetImpl ( 数据 &data, OverloadRank1 )
template<typename DEST >
Result < void >  SetImpl ( 数据 &&data, OverloadRank1 )
template<typename DEST , typename SRC >
std::enable_if< GetCollectionKind < SRC >::value== COLLECTION_KIND::ARRAY , Result < void > >::type  SetImpl (SRC &&data, OverloadRank1 )
template<typename T >
Result < typename ByValueParam < T >::type >  GetImpl ( OverloadRank0 ) const
template<typename T >
std::enable_if< GetCollectionKind < T >::value== COLLECTION_KIND::ARRAY , Result < T > >::type  GetImpl ( OverloadRank1 ) const
template<typename T >
Result < typename std::conditional< STD_IS_REPLACEMENT (void, T), void, T & >::type >  GetImpl ( OverloadRank0 )
template<typename T >
std::enable_if< GetCollectionKind < T >::value== COLLECTION_KIND::ARRAY , Result < T > >::type  GetImpl ( OverloadRank1 )
template<typename T >
SFINAEHelper < Result < T >, typename T::IsBlock >::type  GetImpl ( OverloadRank2 )
template<typename T >
SFINAEHelper < Result < T >, typename T::IsBlock >::type  GetImpl ( OverloadRank2 ) const
template<typename T >
void  InitSet (T &&data)

Static Private Member Functions

static const ObjectInterface CheckInstanceOf (const ObjectInterface *obj, const DataType &type)
static const ObjectRef *  CheckInstanceOf (const ObjectRef *obj, const DataType &type)

Private Attributes

DataType   _typeInfo
DataMemBlock   _memBlock

Friends

class  DataDictionaryInterface
class  DataDictionaryObjectInterface
class  ConstDataPtr

构造函数 & 析构函数文档编制

◆  Data() [1/3]

数据 ( )
default

constructor initializes the data with an nullptr type.

◆  ~Data()

~ 数据 ( )

◆  Data() [2/3]

数据 ( T &&  data ,
typename std::enable_if< ! STD_IS_REPLACEMENT (same, typename std::decay< T >::type, 数据 ), DummyParamType * >::type  = (DummyParamType*)nullptr  
)
explicit

Template class to construct a 数据 object from a value. The value has to fit in DataMemBlock , i.e., this constructor can only be used when SIZEOF(T) <= SIZEOF(DataMemBlock) . Otherwise, you have to use Set which might return an error.

Template Parameters
T Type of data. This constructor only works if SIZEOF(T) <= SIZEOF(DataMemBlock) .
参数
[in] data 数据 to copy into the 数据 .

◆  Data() [3/3]

数据 ( 数据 &&  src )

Template class to move 数据 from every specialized data type. e.g. Int32, Url etc.

参数
[in,out] src 数据 to move to this.

成员函数文档编制

◆  MAXON_DISALLOW_COPY_AND_ASSIGN()

MAXON_DISALLOW_COPY_AND_ASSIGN ( 数据   )
private

◆  Init()

Result <void> Init ( const DataType type )

Initializes this data to the given type. If this data already has the given type, nothing happens, i.e., the value is not reset. Otherwise, the current value is freed, and the data is initialized with a new default value of the given type.

参数
[in] type Type to which this data shall be set.
返回
False if the initialization failed.

◆  IsEmpty()

Bool IsEmpty ( ) const

Checks if a 数据 is empty.

返回
True if it doesn't contain any data.

◆  IsPopulated()

Bool IsPopulated ( ) const

Checks if a 数据 contains anything.

返回
True if it contains data.

◆  GetType()

const DataType & GetType ( ) const

Returns the DataType 数据 . you can compare this value to GetDataType<Int32>() or GetDataType<String>() .

返回
DataType pointer of this.

◆  Reset()

void Reset ( )

Frees the wrapped data and resetd the 数据 object to its initial state.

◆  operator=()

数据 & operator= ( 数据 &&  src )

Assignment move operator to move 数据 , (e.g. Swap uses this)

参数
[in] src 数据 to move to this.

◆  CopyFrom() [1/3]

Result <void> CopyFrom ( const 数据 src )

Makes this @CLASS a copy of src by copying the contents of src into this @CLASS.

参数
[in] src Another @CLASS to be used as source for the copy operation.
返回
OK on success.

◆  CopyFrom() [2/3]

Result <void> CopyFrom ( const ConstDataPtr src )

Copies data described by a ConstDataPtr .

参数
[in] src ConstDataPtr to copy data from.
返回
OK on success.

◆  MoveFrom()

Result <void> MoveFrom ( MoveDataPtr &&  src )

Moves data described by a MoveDataPtr .

参数
[in] src MoveDataPtr to move data from.
返回
OK on success.

◆  CopyFrom() [3/3]

Result <void> CopyFrom ( ForwardingDataPtr &&  src )

Copies or moves data described by a ForwardingDataPtr .

参数
[in] src ForwardingDataPtr to copy or move data from.
返回
OK on success.

◆  Set()

Result <void> Set ( T &&  data )

Set or move a value into a 数据 .

参数
[in] data New value for this 数据 对象。

◆  Get() [1/3]

Result <typename std::conditional< GetCollectionKind <T>::value == COLLECTION_KIND::ARRAY , T, typename ByValueParam <T>::type>::type> Get ( ) const

Returns the value of type T of this 数据 .

Template Parameters
T The expected type of the value.
返回
The value stored in this 数据 , or an error if this 数据 doesn't store a value of type T.

◆  Get() [2/3]

Result <typename std::conditional< STD_IS_REPLACEMENT (void, T) || ( GetCollectionKind <T>::value == COLLECTION_KIND::ARRAY ), T, T&>::type> Get ( )

◆  GetOrNull()

ByValueParam <T>::type GetOrNull ( ) const

Returns the value of type T of this 数据 .

Template Parameters
T The expected type of the value.
返回
The value stored in this 数据 , or a null value if this 数据 doesn't store a value of type T.

◆  Get() [3/3]

T Get ( const T &  defaultValue ) const

Returns the value of type T of this 数据 .

参数
[in] defaultValue If this 数据 doesn't store a value of type T, the default value will be returned.
Template Parameters
T The expected type of the value.
返回
The value stored in this 数据 , or defaultValue if this 数据 doesn't store a value of type T.

◆  Convert() [1/2]

Result <T> Convert ( ) const

Returns the value of this 数据 , converted to T.

Template Parameters
T The type to convert to.
返回
The value stored in this 数据 , converted to T, or an error if this 数据 doesn't store a value or the value cannot be converted to T.
另请参阅
DataType::Convert

◆  ConvertOrNull()

T ConvertOrNull ( ) const

Returns the value of this 数据 , converted to T.

Template Parameters
T The type to convert to.
返回
The value stored in this 数据 , converted to T, or T() if this 数据 doesn't store a value or the value cannot be converted to T.
另请参阅
DataType::Convert

◆  Convert() [2/2]

T Convert ( const T &  defaultValue ) const

Returns the value of this 数据 , converted to T.

参数
[in] defaultValue If this 数据 doesn't store a value or the value cannot converted to T, the default value will be returned.
Template Parameters
T The type to convert to.
返回
The value stored in this 数据 , converted to T, or defaultValue if this 数据 doesn't store a value or the value cannot be converted to T.
另请参阅
DataType::Convert

◆  ConvertData()

Result < 数据 > ConvertData ( const DataType destType ) const

Returns the value of this 数据 , converted to destType.

参数
[in] destType The type to convert to.
返回
The value stored in this 数据 , converted to destType, or an error if this 数据 doesn't store a value or the value cannot be converted to dataType.
另请参阅
DataType::Convert

◆  GetPtr() [1/3]

const T* GetPtr ( ) const

Returns the pointer of the native data if its type matches the given type T, otherwise nullptr.

Template Parameters
T The desired type.
返回
Pointer to the data in native format.

◆  GetPtr() [2/3]

Generic* GetPtr ( const DataType type )

Returns the pointer of the native data if its type matches the given #type, otherwise nullptr.

参数
[in] type The desired type.
返回
Pointer to the data in native format.

◆  GetPtr() [3/3]

const Generic* GetPtr ( const DataType type ) const

◆  PrivateGetPtr() [1/2]

const Generic* PrivateGetPtr ( ) const

Returns the pointer to the native data.

返回
Pointer to the data in native format.

◆  PrivateGetPtr() [2/2]

const Generic* PrivateGetPtr ( const DataType type ) const

Returns the pointer to the native data. It is not checked if its type matches the given #type, the only purpose of the parameter is to enable a special behavior when #type is the type 数据 : Then a pointer to this 数据 object itself is returned.

参数
[in] type The desired type.
返回
Pointer to the data in native format.

◆  GetTuple() [1/2]

TupleValue * GetTuple ( )

Returns the value of this 数据 object as a TupleValue . If this object doesn't hold a tuple value, nullptr is returned.

返回
Pointer to the TupleValue stored in this object, or nullptr if no tuple value is stored.

◆  GetTuple() [2/2]

const TupleValue * GetTuple ( ) const

Returns the value of this 数据 object as a TupleValue . If this object doesn't hold a tuple value, nullptr is returned.

返回
Pointer to the TupleValue stored in this object, or nullptr if no tuple value is stored.

◆  ToString()

String ToString ( const FormatStatement formatStatement = nullptr ) const

Returns a readable string of the content.

参数
[in] formatStatement Nullptr or additional formatting instruction. See also Formatting Mixed types .
返回
The converted result.

◆  Compare()

COMPARERESULT 比较 ( const 数据 c ) const

Returns a readable string of the content.

返回
String that represents the content of 数据 .

◆  GetHashCode()

HashInt GetHashCode ( ) const

Returns the hash code of the wrapped object. If the object's type doesn't provide a hash code function, this function returns 0.

返回
Hash code of this 数据 .

◆  IsEqual()

Bool IsEqual ( const 数据 other ,
EQUALITY   equality = EQUALITY::DEEP  
) const

Returns true if the wrapped object of this 数据 equals that of the #other 数据 .

参数
[in] other Another 数据 object to compare.
[in] equality The equality mode, by default EQUALITY::DEEP .
返回
True if both 数据 objects are equal, false otherwise.

◆  operator==()

Bool operator== ( const 数据 other ) const

==

==

◆  operator!=()

Bool operator!= ( const 数据 other ) const

!=

!=

◆  operator<()

Bool operator< ( const 数据 other ) const

<

<

◆  operator<=()

Bool operator<= ( const 数据 other ) const

<=

<=

◆  operator>()

Bool operator> ( const 数据 other ) const

>

>

◆  operator>=()

Bool operator>= ( const 数据 other ) const

>=

>=

◆  ToConstDataPtr()

ConstDataPtr ToConstDataPtr ( const DataType expectedType ) const

◆  CheckInstanceOf() [1/2]

static const ObjectInterface * CheckInstanceOf ( const ObjectInterface obj ,
const DataType type  
)
static private

◆  CheckInstanceOf() [2/2]

static const ObjectRef* CheckInstanceOf ( const ObjectRef *  obj ,
const DataType type  
)
static private

◆  SetImpl()

std::enable_if< GetCollectionKind < SRC >::value== COLLECTION_KIND::ARRAY , Result < void > >::type SetImpl ( SRC &&  data ,
OverloadRank1    
)
private

◆  GetImpl() [1/6]

Result <typename ByValueParam <T>::type> GetImpl ( OverloadRank0   ) const
private

◆  GetImpl() [2/6]

std::enable_if< GetCollectionKind < T >::value== COLLECTION_KIND::ARRAY , Result < T > >::type GetImpl ( OverloadRank1   ) const
private

◆  GetImpl() [3/6]

Result <typename std::conditional< STD_IS_REPLACEMENT (void, T), void, T&>::type> GetImpl ( OverloadRank0   )
private

◆  GetImpl() [4/6]

std::enable_if< GetCollectionKind < T >::value== COLLECTION_KIND::ARRAY , Result < T > >::type GetImpl ( OverloadRank1   )
private

◆  GetImpl() [5/6]

SFINAEHelper < Result <T>, typename T::IsBlock>::type GetImpl ( OverloadRank2   )
private

◆  GetImpl() [6/6]

SFINAEHelper < Result <T>, typename T::IsBlock>::type GetImpl ( OverloadRank2   ) const
private

◆  InitSet()

void InitSet ( HTTPREQUESTTYPE &&  d )

Friends And Related Function Documentation

◆  DataDictionaryInterface

friend class DataDictionaryInterface
friend

◆  DataDictionaryObjectInterface

friend class DataDictionaryObjectInterface
friend

◆  ConstDataPtr

friend class ConstDataPtr
friend

Member Data Documentation

◆  _typeInfo

DataType _typeInfo
private

pointer to the DataType structure

◆  _memBlock

DataMemBlock _memBlock
private

placeholder for embedded data. this size must stay for compatibility reasons.