2#ifndef __ASE_VALUE_HH__ 
    3#define __ASE_VALUE_HH__ 
   18  static const ValueS empty_array;
 
 
   30  bool operator== (
const ValueField &other) 
const;
 
   31  bool operator!= (
const ValueField &other)
 const { 
return !(other == *
this); }
 
 
   36  using ValueFieldVector::operator[];
 
   44  static const ValueR empty_record;
 
 
   50template<
size_t I, 
size_t J> 
using IDX = typename ::std::enable_if<I == J, bool>::type;
 
   51template<
class T, 
class C>   
using TYP = typename ::std::enable_if<std::is_same<T, C>::value, 
bool>::type;
 
   55  using ValueVariant::ValueVariant;
 
   56  enum Type { NONE, BOOL, INT64, DOUBLE, STRING, ARRAY, RECORD, INSTANCE };
 
   58  size_t         count     () 
const;
 
   63  const ValueR&  as_record () 
const;
 
   68  bool           is_numeric (
bool boolisnumeric = 
true) 
const;
 
   69  bool           is_string ()
 const     { 
return index() == Type::STRING; }
 
   82  Value&       operator[] (
size_t i);
 
   83  const Value& operator[] (
size_t i) 
const;
 
   87  Value (
bool v)                { this->operator= (v); }
 
   91  Value (
double v)              { this->operator= (v); }
 
   92  Value (
const char *v)         { this->operator= (
String (v)); }
 
   94  bool operator== (
const Value &other) 
const;
 
   95  bool operator!= (
const Value &other)
 const { 
return !(other == *
this); }
 
   96  static const Value empty_value;
 
 
  104  template<
class E> 
static EnumInfo value_info (E value);
 
  106  template<
class E> 
static bool     impl       (
EnumInfo (*enuminfo) (E));
 
 
  114  String type()
 const   { 
return (*
this)[
"type"].as_string(); }
 
  115  String detail()
 const { 
return (*
this)[
"detail"].as_string(); }
 
  116  using ValueR::operator[];
 
 
  126  void             call          (
ValueS &&args) 
const;
 
  132  void             ondestroy     (
const VoidFunc &vf);
 
  134  explicit         operator bool () 
const noexcept;
 
  135  template<
class ...A> 
void 
  136  operator() (
const A &...a)
 const 
  139    (args.push_back (a), ...);  
 
  140    call (std::move (args));
 
 
  146Value::operator== (
const Value &other)
 const 
  155  if (v1.size() != v2.size())
 
  157  for (
size_t i = 0; i < v1.size(); i++)
 
  159      const ValueP p1 = v1[i], p2 = v2[i];
 
  172ValueField::operator== (
const ValueField &other)
 const 
  174  if (other.name != name)
 
  176  else if (value && other.value)
 
  177    return *value == *other.value;
 
  179    return value == other.value;
 
  182template<
class E> 
inline EnumInfo
 
  183EnumInfo::value_info (E value)
 
  185  return value_info (
typeid (E), 
int64 (value));
 
  188template<
class E> 
inline bool 
  189EnumInfo::impl (EnumInfo (*enuminfo) (E))
 
  192  impl (
typeid (E), [enuminfo] (
int64 v) { 
return enuminfo (E (v)); });
 
Callback mechanism for Jsonapi/Jsonipc.
 
#define ASE_ASSERT_RETURN(expr,...)
Return from the current function if expr evaluates to false and issue an assertion warning.
 
The Anklang C++ API namespace.
 
int32_t int32
A 32-bit signed integer.
 
int64_t int64
A 64-bit unsigned integer, use PRI*64 in format strings.
 
uint32_t uint32
A 32-bit unsigned integer.
 
Get auxiallary enum information.
 
Structure for callback based notifications.
 
Value type used to interface with various property types.
 
double as_double() const
Convert Value to double or return 0.
 
String repr() const
Convert Value to a string representation, useful for debugging.
 
bool is_numeric(bool boolisnumeric=true) const
Checks if Value is a DOUBLE, INT64, or BOOL.
 
int64 as_int() const
Convert Value to int64 or return 0.
 
size_t count() const
Number of elements in a RECORD or ARRAY Value.
 
bool has(const String &key) const
Check for a named field in a RECORD.
 
String as_string() const
Convert Value to a string, not very useful for RECORD or ARRAY.
 
void filter(const std::function< bool(const ValueField &)> &pred)
Recursively purge/remove RECORD elements iff to pred (recordfield) == true.
 
StringS keys() const
List the field names of a RECORD Value.
 
const ValueS & as_array() const
Retrive a non-empty array if Value contains a non-empty array.