MADARA  3.4.1
KnowledgeCast.h File Reference
#include <string>
#include <cstring>
#include <type_traits>
#include <stdbool.h>
#include "madara/knowledge/KnowledgeRecord.h"
#include "madara/utility/StlHelper.h"

Go to the source code of this file.

Classes

struct  madara::knowledge::impl::is_basic_string< T >
 
struct  madara::knowledge::impl::is_basic_string< std::basic_string< CharT, Traits, Allocator > >
 
struct  madara::knowledge::impl::simple_span< T >
 
struct  madara::knowledge::type< T >
 

Namespaces

 madara
 Copyright(c) 2020 Galois.
 
 madara::knowledge
 Provides functions and classes for the distributed knowledge base.
 
 madara::knowledge::impl
 Internal implementation details.
 

Macros

#define MADARA_KNOWLEDGE_BINARY_OP(op)
 Generates binary math operators for KnowledgeRecords, in combination with types that can be knowledge_cast into KnowledgeRecord. More...
 
#define MADARA_KNOWLEDGE_COMPARE_OP(op)
 Generates comparison operators for KnowledgeRecords, in combination with types that can be knowledge_cast into KnowledgeRecords. More...
 
#define MADARA_KNOWLEDGE_COMPOSITE_OP(op)
 Generates composite assignment operators for KnowledgeRecords, in combination with types that can be knowledge_cast into KnowledgeRecord. More...
 

Functions

template<typename T >
auto madara::knowledge::impl::get_size (const T &c) -> decltype(c.size())
 
template<typename T , size_t N>
size_t madara::knowledge::impl::get_size (const T(&arr)[N])
 
template<typename T >
auto madara::knowledge::knowledge_cast (const KnowledgeRecord &in) -> decltype(knowledge_cast(type< T >{}, in))
 For explicit type form, call through to form taking type struct. More...
 
const KnowledgeRecordmadara::knowledge::knowledge_cast (const KnowledgeRecord &in, KnowledgeRecord &out)
 Identity NOP. More...
 
template<typename Container >
void madara::knowledge::knowledge_cast (const KnowledgeRecord &in, std::back_insert_iterator< Container > iter)
 
template<typename CharT , typename Traits , typename Allocator >
std::basic_string< CharT, Traits, Allocator > & madara::knowledge::knowledge_cast (const KnowledgeRecord &in, std::basic_string< CharT, Traits, Allocator > &out)
 Conert KnowlegeRecord into an existing std::basic_string<...> More...
 
template<typename T >
auto madara::knowledge::knowledge_cast (const KnowledgeRecord &in, T &&out) -> decltype(*out=knowledge_cast(type< typename utility::decay_< T >::container_type::value_type >{}, in))
 
template<typename T >
auto madara::knowledge::knowledge_cast (const T &in) -> typename std::enable_if< std::is_integral< typename std::decay< decltype(in[0])>::type >::value &&!std::is_same< typename std::decay< decltype(in[0])>::type, char >::value &&!std::is_same< typename std::decay< decltype(in[0])>::type, unsigned char >::value &&!std::is_same< T, std::vector< int64_t >>::value, typename std::decay< decltype(KnowledgeRecord{ tags::integers, std::begin(in), std::end(in)})>::type >::type
 Construct a KnowledgeRecord with integer array type, from a container of integers, except char types. More...
 
KnowledgeRecordmadara::knowledge::knowledge_cast (KnowledgeRecord &in)
 Identity NOP. More...
 
template<class O >
auto madara::knowledge::knowledge_cast (O &&in) -> typename std::decay< decltype(KnowledgeRecord{std::forward< O >(in)})>::type
 Convert a value to KnowledgeRecord By default, if no other overload specified, this overload just calls KnowledgeRecord constructor. More...
 
bool madara::knowledge::knowledge_cast (type< bool >, const KnowledgeRecord &in)
 Convert KnowledgeRecord to bool (using in.is_true()) More...
 
KnowledgeRecord madara::knowledge::knowledge_cast (type< KnowledgeRecord >, const KnowledgeRecord &in)
 Convert KnowledgeRecord into an existing native C array, passed via a pointer and size. More...
 
template<class O >
auto madara::knowledge::knowledge_cast (type< O >, const KnowledgeRecord &in) -> typename std::enable_if< std::is_constructible< O, const KnowledgeRecord & >::value, O >::type
 By default, call constructor of target class; for other semantics, define specializations. More...
 
std::string madara::knowledge::knowledge_cast (type< std::string >, const KnowledgeRecord &in)
 Convert KnowledgeRecord to a std::string. More...
 
std::vector< double > madara::knowledge::knowledge_cast (type< std::vector< double >>, const KnowledgeRecord &in)
 Convert KnowledgeRecord to a std::vector<double> More...
 
std::vector< int64_t > madara::knowledge::knowledge_cast (type< std::vector< int64_t >>, const KnowledgeRecord &in)
 Convert KnowledgeRecord to a std::vector<int64_t> More...
 
template<typename T >
auto madara::knowledge::knowledge_cast (type< std::vector< T >>, const KnowledgeRecord &in) -> typename std::enable_if< std::is_integral< T >::value, std::vector< T >>::type
 Convert KnowledgeRecord to a std::vector of integral types besides int64_t. More...
 
template<typename T >
simple_span< T > madara::knowledge::impl::make_span (T *ptr, size_t size)
 
bool madara::knowledge::operator!= (const char *l, const KnowledgeRecord &r)
 
bool madara::knowledge::operator!= (const KnowledgeRecord &l, const char *r)
 
bool madara::knowledge::operator!= (const KnowledgeRecord &l, const std::string &r)
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator!= (const KnowledgeRecord &l, const T &r) -> decltype(knowledge_cast< T >(l) !=r)
 
bool madara::knowledge::operator!= (const KnowledgeRecord &l, std::nullptr_t)
 
bool madara::knowledge::operator!= (const std::string &l, const KnowledgeRecord &r)
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator!= (const T &l, const KnowledgeRecord &r) -> decltype(l !=knowledge_cast< T >(r))
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator% (const KnowledgeRecord &l, const T &r) -> decltype(l % knowledge_cast(r))
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator% (const T &l, const KnowledgeRecord &r) -> decltype(knowledge_cast(l) % r)
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator%= (KnowledgeRecord &l, const T &r) -> decltype(l %=knowledge_cast(r))
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator* (const KnowledgeRecord &l, const T &r) -> decltype(l *knowledge_cast(r))
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator* (const T &l, const KnowledgeRecord &r) -> decltype(knowledge_cast(l) *r)
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator*= (KnowledgeRecord &l, const T &r) -> decltype(l *=knowledge_cast(r))
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator+ (const KnowledgeRecord &l, const T &r) -> decltype(l+knowledge_cast(r))
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator+ (const T &l, const KnowledgeRecord &r) -> decltype(knowledge_cast(l)+r)
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator+= (KnowledgeRecord &l, const T &r) -> decltype(l+=knowledge_cast(r))
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator- (const KnowledgeRecord &l, const T &r) -> decltype(l - knowledge_cast(r))
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator- (const T &l, const KnowledgeRecord &r) -> decltype(knowledge_cast(l) - r)
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator-= (KnowledgeRecord &l, const T &r) -> decltype(l -=knowledge_cast(r))
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator/ (const KnowledgeRecord &l, const T &r) -> decltype(l/knowledge_cast(r))
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator/ (const T &l, const KnowledgeRecord &r) -> decltype(knowledge_cast(l)/r)
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator/= (KnowledgeRecord &l, const T &r) -> decltype(l/=knowledge_cast(r))
 
bool madara::knowledge::operator< (const char *l, const KnowledgeRecord &r)
 
bool madara::knowledge::operator< (const KnowledgeRecord &l, const char *r)
 
bool madara::knowledge::operator< (const KnowledgeRecord &l, const std::string &r)
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator< (const KnowledgeRecord &l, const T &r) -> decltype(knowledge_cast< T >(l)< r)
 
bool madara::knowledge::operator< (const KnowledgeRecord &l, std::nullptr_t)
 
bool madara::knowledge::operator< (const std::string &l, const KnowledgeRecord &r)
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator< (const T &l, const KnowledgeRecord &r) -> decltype(l< knowledge_cast< T >(r))
 
bool madara::knowledge::operator<= (const char *l, const KnowledgeRecord &r)
 
bool madara::knowledge::operator<= (const KnowledgeRecord &l, const char *r)
 
bool madara::knowledge::operator<= (const KnowledgeRecord &l, const std::string &r)
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator<= (const KnowledgeRecord &l, const T &r) -> decltype(knowledge_cast< T >(l)<=r)
 
bool madara::knowledge::operator<= (const KnowledgeRecord &l, std::nullptr_t)
 
bool madara::knowledge::operator<= (const std::string &l, const KnowledgeRecord &r)
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator<= (const T &l, const KnowledgeRecord &r) -> decltype(l<=knowledge_cast< T >(r))
 
bool madara::knowledge::operator== (const char *l, const KnowledgeRecord &r)
 
bool madara::knowledge::operator== (const KnowledgeRecord &l, const char *r)
 
bool madara::knowledge::operator== (const KnowledgeRecord &l, const std::string &r)
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator== (const KnowledgeRecord &l, const T &r) -> decltype(knowledge_cast< T >(l)==r)
 
bool madara::knowledge::operator== (const KnowledgeRecord &l, std::nullptr_t)
 
bool madara::knowledge::operator== (const std::string &l, const KnowledgeRecord &r)
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator== (const T &l, const KnowledgeRecord &r) -> decltype(l==knowledge_cast< T >(r))
 
bool madara::knowledge::operator> (const char *l, const KnowledgeRecord &r)
 
bool madara::knowledge::operator> (const KnowledgeRecord &l, const char *r)
 
bool madara::knowledge::operator> (const KnowledgeRecord &l, const std::string &r)
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator> (const KnowledgeRecord &l, const T &r) -> decltype(knowledge_cast< T >(l) > r)
 
bool madara::knowledge::operator> (const KnowledgeRecord &l, std::nullptr_t)
 
bool madara::knowledge::operator> (const std::string &l, const KnowledgeRecord &r)
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator> (const T &l, const KnowledgeRecord &r) -> decltype(l > knowledge_cast< T >(r))
 
bool madara::knowledge::operator>= (const char *l, const KnowledgeRecord &r)
 
bool madara::knowledge::operator>= (const KnowledgeRecord &l, const char *r)
 
bool madara::knowledge::operator>= (const KnowledgeRecord &l, const std::string &r)
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator>= (const KnowledgeRecord &l, const T &r) -> decltype(knowledge_cast< T >(l) >=r)
 
bool madara::knowledge::operator>= (const KnowledgeRecord &l, std::nullptr_t)
 
bool madara::knowledge::operator>= (const std::string &l, const KnowledgeRecord &r)
 
template<typename T , typename std::enable_if< !std::is_convertible< T, KnowledgeRecord >::value &&std::is_fundamental< T >::value, void * >::type = nullptr>
auto madara::knowledge::operator>= (const T &l, const KnowledgeRecord &r) -> decltype(l >=knowledge_cast< T >(r))
 
template<typename T >
auto madara::knowledge::impl::share_array (const KnowledgeRecord &in) -> typename std::enable_if< std::is_integral< typename std::decay< decltype(*std::begin(std::declval< T & >()))>::type >::value, decltype(in.share_integers())>::type
 
template<typename T >
auto madara::knowledge::impl::to_array (const KnowledgeRecord &in) -> typename std::enable_if< std::is_integral< typename std::decay< decltype(*std::begin(std::declval< T & >()))>::type >::value, decltype(in.to_integers())>::type
 

Macro Definition Documentation

◆ MADARA_KNOWLEDGE_BINARY_OP

#define MADARA_KNOWLEDGE_BINARY_OP (   op)
Value:
template<typename T, typename std::enable_if< \
!std::is_convertible<T, KnowledgeRecord>::value && \
std::is_fundamental<T>::value, \
void*>::type = nullptr> \
inline auto operator op(const KnowledgeRecord& l, const T& r) \
->decltype(l op knowledge_cast(r)) \
{ \
return l op knowledge_cast(r); \
} \
\
template<typename T, typename std::enable_if< \
!std::is_convertible<T, KnowledgeRecord>::value && \
std::is_fundamental<T>::value, \
void*>::type = nullptr> \
inline auto operator op(const T& l, const KnowledgeRecord& r) \
->decltype(knowledge_cast(l) op r) \
{ \
return knowledge_cast(l) op r; \
}
This class encapsulates an entry in a KnowledgeBase.
const KnowledgeRecord & knowledge_cast(const KnowledgeRecord &in, KnowledgeRecord &out)
Identity NOP.

Generates binary math operators for KnowledgeRecords, in combination with types that can be knowledge_cast into KnowledgeRecord.

Definition at line 479 of file KnowledgeCast.h.

◆ MADARA_KNOWLEDGE_COMPARE_OP

#define MADARA_KNOWLEDGE_COMPARE_OP (   op)

Generates comparison operators for KnowledgeRecords, in combination with types that can be knowledge_cast into KnowledgeRecords.

Definition at line 392 of file KnowledgeCast.h.

◆ MADARA_KNOWLEDGE_COMPOSITE_OP

#define MADARA_KNOWLEDGE_COMPOSITE_OP (   op)
Value:
template<typename T, typename std::enable_if< \
!std::is_convertible<T, KnowledgeRecord>::value && \
std::is_fundamental<T>::value, \
void*>::type = nullptr> \
inline auto operator op(KnowledgeRecord& l, const T& r) \
->decltype(l op knowledge_cast(r)) \
{ \
return l op knowledge_cast(r); \
}

Generates composite assignment operators for KnowledgeRecords, in combination with types that can be knowledge_cast into KnowledgeRecord.

Definition at line 508 of file KnowledgeCast.h.