mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Data Fields | Private Attributes | Friends
m::Value Struct Reference

This class holds a SQL attribute value. More...

#include <Tuple.hpp>

Collaboration diagram for m::Value:
[legend]

Public Types

using val_t = union { bool b
 

Public Member Functions

 Value ()
 
template<typename T >
 Value (T val)
 
template<typename T >
std::conditional_t< std::is_pointer_v< T >, T, T & > as ()
 Returns a reference to the value interpreted as of type T.
 
template<typename T >
T as () const
 Returns the value interpreted as of type T.
 
auto & as_b ()
 Returns a reference to the value interpreted as of type bool.
 
auto & as_i ()
 Returns a reference to the value interpreted as of type int64_t.
 
auto & as_f ()
 Returns a reference to the value interpreted as of type float.
 
auto & as_d ()
 Returns a reference to the value interpreted as of type double.
 
auto as_p ()
 Returns a reference to the value interpreted as of type void*.
 
auto as_b () const
 Returns the value interpreted as of type bool.
 
auto as_i () const
 Returns the value interpreted as of type int64_t.
 
auto as_f () const
 Returns the value interpreted as of type float.
 
auto as_d () const
 Returns the value interpreted as of type double.
 
auto as_p () const
 Returns the value interpreted as of type void*.
 
 operator bool () const
 
 operator int32_t () const
 
 operator int64_t () const
 
 operator float () const
 
 operator double () const
 
template<typename T >
 operator T* () const
 
M_LCOV_EXCL_STOP void print (std::ostream &out, const Type &ty) const
 Interpret this Value as of Type ty and print a human-readable representation to out.
 
bool operator== (Value other) const
 Checks whether this Value is equal to other.
 
bool operator!= (Value other) const
 Checks whether this Value is not equal to other.
 
void dump (std::ostream &out) const
 
void dump () const
 

Data Fields

int64_t i
 
float f
 
double d
 
void * p
 

Private Attributes

val_t val_
 

Friends

M_LCOV_EXCL_START friend std::ostream & operator<< (std::ostream &out, Value val)
 Print a hexdump of val to out.
 

Detailed Description

This class holds a SQL attribute value.

It cannot represent NULL.

Definition at line 18 of file Tuple.hpp.

Member Typedef Documentation

◆ val_t

using m::Value::val_t = union { bool b

Definition at line 22 of file Tuple.hpp.

Constructor & Destructor Documentation

◆ Value() [1/2]

m::Value::Value ( )
inline

Definition at line 46 of file Tuple.hpp.

◆ Value() [2/2]

template<typename T >
m::Value::Value ( T  val)
inline

Definition at line 54 of file Tuple.hpp.

References SET, and SET_TYPE.

Member Function Documentation

◆ as() [1/2]

template<typename T >
std::conditional_t< std::is_pointer_v< T >, T, T & > m::Value::as ( )
inline

Returns a reference to the value interpreted as of type T.

Definition at line 79 of file Tuple.hpp.

References GET, m::T(), and VALIDATE_TYPE.

Referenced by m::idx::ArrayIndex< Key >::bulkload(), and m::StackMachine::operator()().

◆ as() [2/2]

template<typename T >
T m::Value::as ( ) const
inline

Returns the value interpreted as of type T.

Definition at line 98 of file Tuple.hpp.

References m::T().

◆ as_b() [1/2]

auto & m::Value::as_b ( )
inline

Returns a reference to the value interpreted as of type bool.

Definition at line 101 of file Tuple.hpp.

Referenced by m::StackMachine::operator()(), and print().

◆ as_b() [2/2]

auto m::Value::as_b ( ) const
inline

Returns the value interpreted as of type bool.

Definition at line 112 of file Tuple.hpp.

◆ as_d() [1/2]

auto & m::Value::as_d ( )
inline

Returns a reference to the value interpreted as of type double.

Definition at line 107 of file Tuple.hpp.

Referenced by print().

◆ as_d() [2/2]

auto m::Value::as_d ( ) const
inline

Returns the value interpreted as of type double.

Definition at line 118 of file Tuple.hpp.

◆ as_f() [1/2]

auto & m::Value::as_f ( )
inline

Returns a reference to the value interpreted as of type float.

Definition at line 105 of file Tuple.hpp.

Referenced by print().

◆ as_f() [2/2]

auto m::Value::as_f ( ) const
inline

Returns the value interpreted as of type float.

Definition at line 116 of file Tuple.hpp.

◆ as_i() [1/2]

auto & m::Value::as_i ( )
inline

Returns a reference to the value interpreted as of type int64_t.

Definition at line 103 of file Tuple.hpp.

Referenced by print().

◆ as_i() [2/2]

auto m::Value::as_i ( ) const
inline

Returns the value interpreted as of type int64_t.

Definition at line 114 of file Tuple.hpp.

◆ as_p() [1/2]

auto m::Value::as_p ( )
inline

Returns a reference to the value interpreted as of type void*.

Definition at line 109 of file Tuple.hpp.

◆ as_p() [2/2]

auto m::Value::as_p ( ) const
inline

Returns the value interpreted as of type void*.

Definition at line 120 of file Tuple.hpp.

◆ dump() [1/2]

void Value::dump ( ) const

Definition at line 69 of file Tuple.cpp.

References dump().

Referenced by dump().

◆ dump() [2/2]

void Value::dump ( std::ostream &  out) const

Definition at line 68 of file Tuple.cpp.

◆ operator bool()

m::Value::operator bool ( ) const
inlineexplicit

Definition at line 122 of file Tuple.hpp.

◆ operator double()

m::Value::operator double ( ) const
inlineexplicit

Definition at line 126 of file Tuple.hpp.

◆ operator float()

m::Value::operator float ( ) const
inlineexplicit

Definition at line 125 of file Tuple.hpp.

◆ operator int32_t()

m::Value::operator int32_t ( ) const
inlineexplicit

Definition at line 123 of file Tuple.hpp.

◆ operator int64_t()

m::Value::operator int64_t ( ) const
inlineexplicit

Definition at line 124 of file Tuple.hpp.

◆ operator T*()

template<typename T >
m::Value::operator T* ( ) const
inlineexplicit

Definition at line 129 of file Tuple.hpp.

References m::T().

◆ operator!=()

bool m::Value::operator!= ( Value  other) const
inline

Checks whether this Value is not equal to other.

This operation is only sane if both Values are of the same type.

Definition at line 168 of file Tuple.hpp.

◆ operator==()

bool m::Value::operator== ( Value  other) const
inline

Checks whether this Value is equal to other.

This operation is only sane if both Values are of the same type.

Definition at line 160 of file Tuple.hpp.

References M_insist, and val_.

◆ print()

M_LCOV_EXCL_START void Value::print ( std::ostream &  out,
const Type ty 
) const

Interpret this Value as of Type ty and print a human-readable representation to out.

Definition at line 17 of file Tuple.cpp.

References as_b(), as_d(), as_f(), as_i(), M_unreachable, m::powi(), and m::visit().

Referenced by m::Tuple::print().

Friends And Related Function Documentation

◆ operator<<

M_LCOV_EXCL_START friend std::ostream & operator<< ( std::ostream &  out,
Value  val 
)
friend

Print a hexdump of val to out.

Definition at line 134 of file Tuple.hpp.

Field Documentation

◆ d

double m::Value::d

Definition at line 26 of file Tuple.hpp.

◆ f

float m::Value::f

Definition at line 25 of file Tuple.hpp.

◆ i

int64_t m::Value::i

Definition at line 24 of file Tuple.hpp.

◆ p

void* m::Value::p

Definition at line 27 of file Tuple.hpp.

◆ val_

val_t m::Value::val_
private

Definition at line 43 of file Tuple.hpp.

Referenced by std::hash< m::Value >::operator()(), and operator==().


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