MySQL 9.3.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
shcore::Value Struct Referencefinal

Pointer to a function that may be implemented in any language. More...

#include <jit_executor_value.h>

Classes

struct  binary_string
 
class  Map_type
 
struct  null_value
 

Public Types

typedef std::vector< ValueArray_type
 
typedef std::shared_ptr< Array_typeArray_type_ref
 
typedef std::shared_ptr< Map_typeMap_type_ref
 

Public Member Functions

 Value ()=default
 
 Value (const Value &)=default
 
 Value (Value &&) noexcept=default
 
Valueoperator= (const Value &)=default
 
Valueoperator= (Value &&) noexcept=default
 
 ~Value () noexcept=default
 
 Value (const std::string &s, bool binary=false)
 
 Value (std::string &&s, bool binary=false)
 
 Value (const char *)
 
 Value (const char *, size_t n, bool binary=false)
 
 Value (std::string_view s, bool binary=false)
 
 Value (std::wstring_view s)
 
 Value (std::nullptr_t)
 
 Value (int i)
 
 Value (unsigned int ui)
 
 Value (int64_t i)
 
 Value (uint64_t ui)
 
 Value (float f)
 
 Value (double d)
 
 Value (bool b)
 
 Value (const std::shared_ptr< polyglot::Polyglot_object > &o)
 
 Value (const std::shared_ptr< polyglot::Object_bridge > &o)
 
 Value (const Map_type_ref &n)
 
 Value (Map_type_ref &&n)
 
 Value (const Array_type_ref &n)
 
 Value (Array_type_ref &&n)
 
bool operator== (const Value &other) const
 
bool operator!= (const Value &other) const
 
bool operator< (const Value &) const =delete
 
bool operator> (const Value &) const =delete
 
bool operator<= (const Value &) const =delete
 
bool operator>= (const Value &) const =delete
 
 operator bool () const noexcept
 
bool is_null () const noexcept
 
std::string descr (bool pprint=false) const
 returns a human-readable description text for the value. More...
 
std::string repr () const
 returns a string representation of the serialized object, suitable to be passed to parse() More...
 
std::string json (bool pprint=false) const
 returns a JSON representation of the object More...
 
std::string & append_descr (std::string &s_out, int indent=-1, char quote_strings='\0') const
 returns a YAML representation of the Value More...
 
std::string & append_repr (std::string &s_out) const
 
void check_type (Value_type t) const
 
Value_type get_type () const noexcept
 
bool as_bool () const
 
int64_t as_int () const
 
uint64_t as_uint () const
 
double as_double () const
 
std::string as_string () const
 
std::wstring as_wstring () const
 
const std::string & get_string () const
 
template<class C >
std::shared_ptr< C > as_object_bridge () const
 
std::shared_ptr< polyglot::Object_bridgeas_object_bridge () const
 
std::shared_ptr< polyglot::Polyglot_objectas_object () const
 
std::shared_ptr< Map_typeas_map () const
 
std::shared_ptr< Array_typeas_array () const
 

Static Public Member Functions

static Value new_array ()
 
static Value new_map ()
 
static Value Null ()
 
static Value True ()
 
static Value False ()
 
static Value parse (std::string_view s)
 parse a string returned by repr() back into a Value More...
 

Private Attributes

std::variant< std::monostate, null_value, bool, std::string, binary_string, int64_t, uint64_t, double, std::shared_ptr< polyglot::Polyglot_object >, std::shared_ptr< polyglot::Object_bridge >, std::shared_ptr< Array_type >, std::shared_ptr< Map_type > > m_value
 

Friends

std::ostream & operator<< (std::ostream &os, const Value &v)
 

Detailed Description

Pointer to a function that may be implemented in any language.

A generic value that can be used from any language we support.

Anything that can be represented using this can be passed as a parameter to scripting functions or stored in the internal registry or anywhere. If serializable types are used, then they may also be stored as a JSON document.

Values are exposed to scripting languages according to the following rules:

  • Simple types (Null, Bool, String, Integer, Float, UInteger) are converted directly to the target type, both ways
  • Arrays and Maps are converted directly to the target type, both ways
  • Functions are wrapped into callable objects from C++ to scripting language
  • Scripting language functions are wrapped into an instance of a language specific subclass of Function_base
  • C++ Objects are generically wrapped into a scripting language object, except when there's a specific native counterpart
  • Scripting language objects are either generically wrapped to a language specific generic object wrapper or converted to a specific C++ Object subclass

Example: JS Date object is converted to a C++ Date object and vice-versa, but Mysql_connection is wrapped generically

type conversions

      Null Bool  String  Integer UInteger  Float Object  Array Map

Null OK - - - - - OK OK OK Bool - OK - OK OK OK - - - String - OK OK OK OK OK - - - Integer - OK - OK OK OK - - - UInteger - OK - OK OK OK - - - Float - OK - OK OK OK - - - Object - - - - - - OK - - Array - - - - - - - OK - Map - - - - - - - - OK

Integer <-> UInteger conversions are only possible if the range allows it Null can be cast to Object/Array/Map, but a valid Object/Array/Map pointer is not NULL, so it can't be cast to it.

Member Typedef Documentation

◆ Array_type

typedef std::vector<Value> shcore::Value::Array_type

◆ Array_type_ref

typedef std::shared_ptr<Array_type> shcore::Value::Array_type_ref

◆ Map_type_ref

typedef std::shared_ptr<Map_type> shcore::Value::Map_type_ref

Constructor & Destructor Documentation

◆ Value() [1/23]

shcore::Value::Value ( )
default

◆ Value() [2/23]

shcore::Value::Value ( const Value )
default

◆ Value() [3/23]

shcore::Value::Value ( Value &&  )
defaultnoexcept

◆ ~Value()

shcore::Value::~Value ( )
defaultnoexcept

◆ Value() [4/23]

shcore::Value::Value ( const std::string &  s,
bool  binary = false 
)
explicit

◆ Value() [5/23]

shcore::Value::Value ( std::string &&  s,
bool  binary = false 
)
explicit

◆ Value() [6/23]

shcore::Value::Value ( const char *  s)
explicit

◆ Value() [7/23]

shcore::Value::Value ( const char *  s,
size_t  n,
bool  binary = false 
)
explicit

◆ Value() [8/23]

shcore::Value::Value ( std::string_view  s,
bool  binary = false 
)
explicit

◆ Value() [9/23]

shcore::Value::Value ( std::wstring_view  s)
explicit

◆ Value() [10/23]

shcore::Value::Value ( std::nullptr_t  )
explicit

◆ Value() [11/23]

shcore::Value::Value ( int  i)
explicit

◆ Value() [12/23]

shcore::Value::Value ( unsigned int  ui)
explicit

◆ Value() [13/23]

shcore::Value::Value ( int64_t  i)
explicit

◆ Value() [14/23]

shcore::Value::Value ( uint64_t  ui)
explicit

◆ Value() [15/23]

shcore::Value::Value ( float  f)
explicit

◆ Value() [16/23]

shcore::Value::Value ( double  d)
explicit

◆ Value() [17/23]

shcore::Value::Value ( bool  b)
explicit

◆ Value() [18/23]

shcore::Value::Value ( const std::shared_ptr< polyglot::Polyglot_object > &  o)
explicit

◆ Value() [19/23]

shcore::Value::Value ( const std::shared_ptr< polyglot::Object_bridge > &  o)
explicit

◆ Value() [20/23]

shcore::Value::Value ( const Map_type_ref n)
explicit

◆ Value() [21/23]

shcore::Value::Value ( Map_type_ref &&  n)
explicit

◆ Value() [22/23]

shcore::Value::Value ( const Array_type_ref n)
explicit

◆ Value() [23/23]

shcore::Value::Value ( Array_type_ref &&  n)
explicit

Member Function Documentation

◆ append_descr()

std::string & shcore::Value::append_descr ( std::string &  s_out,
int  indent = -1,
char  quote_strings = '\0' 
) const

returns a YAML representation of the Value

◆ append_repr()

std::string & shcore::Value::append_repr ( std::string &  s_out) const

◆ as_array()

std::shared_ptr< Array_type > shcore::Value::as_array ( ) const
inline

◆ as_bool()

bool shcore::Value::as_bool ( ) const

◆ as_double()

double shcore::Value::as_double ( ) const

◆ as_int()

int64_t shcore::Value::as_int ( ) const

◆ as_map()

std::shared_ptr< Map_type > shcore::Value::as_map ( ) const
inline

◆ as_object()

std::shared_ptr< polyglot::Polyglot_object > shcore::Value::as_object ( ) const

◆ as_object_bridge() [1/2]

template<class C >
std::shared_ptr< C > shcore::Value::as_object_bridge ( ) const
inline

◆ as_object_bridge() [2/2]

std::shared_ptr< polyglot::Object_bridge > shcore::Value::as_object_bridge ( ) const

◆ as_string()

std::string shcore::Value::as_string ( ) const

◆ as_uint()

uint64_t shcore::Value::as_uint ( ) const

◆ as_wstring()

std::wstring shcore::Value::as_wstring ( ) const

◆ check_type()

void shcore::Value::check_type ( Value_type  t) const

◆ descr()

std::string shcore::Value::descr ( bool  pprint = false) const

returns a human-readable description text for the value.

◆ False()

static Value shcore::Value::False ( )
inlinestatic

◆ get_string()

const std::string & shcore::Value::get_string ( ) const
inline

◆ get_type()

Value_type shcore::Value::get_type ( ) const
noexcept

◆ is_null()

bool shcore::Value::is_null ( ) const
inlinenoexcept

◆ json()

std::string shcore::Value::json ( bool  pprint = false) const

returns a JSON representation of the object

◆ new_array()

static Value shcore::Value::new_array ( )
inlinestatic

◆ new_map()

static Value shcore::Value::new_map ( )
inlinestatic

◆ Null()

static Value shcore::Value::Null ( )
inlinestatic

◆ operator bool()

shcore::Value::operator bool ( ) const
inlineexplicitnoexcept

◆ operator!=()

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

◆ operator<()

bool shcore::Value::operator< ( const Value ) const
delete

◆ operator<=()

bool shcore::Value::operator<= ( const Value ) const
delete

◆ operator=() [1/2]

Value & shcore::Value::operator= ( const Value )
default

◆ operator=() [2/2]

Value & shcore::Value::operator= ( Value &&  )
defaultnoexcept

◆ operator==()

bool shcore::Value::operator== ( const Value other) const

◆ operator>()

bool shcore::Value::operator> ( const Value ) const
delete

◆ operator>=()

bool shcore::Value::operator>= ( const Value ) const
delete

◆ parse()

Value shcore::Value::parse ( std::string_view  s)
static

parse a string returned by repr() back into a Value

◆ repr()

std::string shcore::Value::repr ( ) const

returns a string representation of the serialized object, suitable to be passed to parse()

◆ True()

static Value shcore::Value::True ( )
inlinestatic

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const Value v 
)
friend

Member Data Documentation

◆ m_value

std::variant< std::monostate, null_value, bool, std::string, binary_string, int64_t, uint64_t, double, std::shared_ptr<polyglot::Polyglot_object>, std::shared_ptr<polyglot::Object_bridge>, std::shared_ptr<Array_type>, std::shared_ptr<Map_type> > shcore::Value::m_value
private

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