14 #ifndef _CPPMESSAGEDATA_H_
15 #define _CPPMESSAGEDATA_H_
36 namespace softwareag {
38 namespace connectivity {
69 class data_t:
protected sag_underlying_data_t
79 memset(
this, 0,
sizeof(sag_underlying_data_t));
86 memset(
this, 0,
sizeof(sag_underlying_data_t));
88 swap(std::move(other));
98 data_t tmp(std::move(other));
196 swap(std::move(tmp));
209 swap(std::move(tmp));
222 swap(std::move(tmp));
240 swap(std::move(tmp));
253 swap(std::move(tmp));
259 explicit data_t(
const char *s,
size_t n);
262 explicit data_t(
const char *s);
265 explicit data_t(
const std::string &s);
272 swap(std::move(tmp));
282 swap(std::move(tmp));
297 swap(std::move(tmp));
312 swap(std::move(tmp));
327 swap(std::move(tmp));
391 class custom_t:
public sag_underlying_custom_t
402 T *
get() {
return this->data ?
reinterpret_cast<T*
>(this->data->custom) : 0; }
404 const T *
get()
const {
return this->data ?
reinterpret_cast<T*
>(this->data->custom) : 0; }
423 static void deleter(
void *d)
427 delete reinterpret_cast<T*
>(d);
435 static void *copier(
void *d)
438 return d ?
new T(*reinterpret_cast<T*>(d)) : 0;
451 #include <sag_internal/convert_to.hpp>
464 inline typename get_details::GetVisitor<const T>::result_type
get(
const data_t &t) {
return apply_visitor(get_details::GetVisitor<const T>(), t); }
476 inline typename get_details::GetVisitor<T>::result_type
get(
data_t &t) {
return apply_visitor(get_details::GetVisitor<T>(), t); }
512 class list_t:
protected sag_underlying_vector_t
518 static size_t MIN_CAPACITY() {
return 10; }
526 template<
typename DATA,
typename UNDERLYING>
527 struct _iterator:
public std::iterator<std::random_access_iterator_tag, DATA>
531 explicit _iterator(UNDERLYING ptr,
bool forward=
true)
532 : ptr(ptr), direction(forward?1:-1)
534 iterator &operator+=(
size_t n) { ptr += direction*n;
return *
this; }
535 iterator &operator-=(
size_t n) { ptr -= direction*n;
return *
this; }
536 iterator operator+(
size_t n)
const {
return iterator(ptr+(direction*n), direction>0); }
537 iterator operator-(
size_t n)
const {
return iterator(ptr+(direction*-n), direction > 0); }
538 ptrdiff_t operator-(
const iterator &other)
const {
return direction*(ptr-other.ptr); }
539 DATA &operator[](
size_t n)
const {
return static_cast<DATA&
>(ptr[n*direction]); }
540 bool operator<(
const iterator &other)
const {
return direction>0 ? ptr < other.ptr : ptr > other.ptr; }
541 bool operator>(
const iterator &other)
const {
return direction>0 ? ptr > other.ptr : ptr < other.ptr; }
542 bool operator>=(
const iterator &other)
const {
return direction>0 ? ptr >= other.ptr : ptr <= other.ptr; }
543 bool operator<=(
const iterator &other)
const {
return direction>0 ? ptr <= other.ptr : ptr >= other.ptr; }
544 bool operator==(
const iterator &other)
const {
return ptr == other.ptr; }
545 bool operator!=(
const iterator &other)
const {
return !operator==(other); }
546 iterator &operator++() {
return operator+=(1); }
547 iterator operator++(
int)
553 iterator &operator--() {
return operator-=(1); }
554 iterator operator--(
int)
560 DATA &operator*()
const {
return static_cast<DATA&
>(*ptr); }
561 DATA *operator->()
const {
return static_cast<DATA*
>(ptr); }
576 explicit list_t(
size_t n);
590 swap(std::move(tmp));
592 swap(std::move(other));
599 swap(std::move(other));
604 std::swap(table, other.table);
610 for (const_iterator it =
begin(); it !=
end(); ++it) {
635 iterator
end() {
return iterator(table?table->data+table->count:0); }
645 iterator
rbegin() {
return iterator(table?table->data+table->count-1:0,
false); }
654 size_t size()
const {
return table?table->count:0; }
680 if (!table) resize(n);
681 if (n > table->capacity) resize(n);
703 void resize(
size_t newsize);
723 class map_t:
protected sag_underlying_map_t
728 static size_t MIN_CAPACITY() {
return 8; }
730 typedef sag_underlying_map_table_entry_t item_t;
731 typedef int64_t hash_t;
734 template<
typename DATA>
748 template<
typename DATA,
typename UNDERLYING,
typename PAIR>
749 struct _iterator:
public std::iterator<std::bidirectional_iterator_tag, DATA>
753 typedef PAIR element_t;
755 _iterator(): tabledata(0), capacity(0), offs(0) {}
756 _iterator(
const UNDERLYING &tabledata,
size_t capacity, int64_t offs,
bool stepToItem=
false)
757 : tabledata(tabledata), capacity(capacity), offs(offs)
759 if (!valid() && stepToItem) {
764 iterator &operator--()
773 iterator operator--(
int)
779 iterator &operator++()
781 if (offs < capacity) {
788 iterator operator++(
int)
795 DATA &key()
const {
return static_cast<DATA&
>(tabledata[offs].key); }
796 DATA &value()
const {
return static_cast<DATA&
>(tabledata[offs].value); }
798 bool operator==(
const iterator &other)
const
800 bool b = offs == other.offs;
803 bool operator!=(
const iterator &other)
const
805 bool b = !operator==(other);
808 element_t &operator*()
const
810 return reinterpret_cast<element_t &
>(tabledata[offs]);
812 element_t *operator->()
const
814 return reinterpret_cast<element_t *
>(tabledata + offs);
820 return offs >= capacity || offs < 0 || tabledata[offs].hash > 1 ||
SAG_DATA_EMPTY != tabledata[offs].key.tag;
822 UNDERLYING tabledata;
841 explicit map_t(
size_t n);
855 swap(std::move(tmp));
857 swap(std::move(other));
864 swap(std::move(other));
870 std::swap(table, other.table);
877 for (const_iterator it =
begin(); it !=
end(); ++it) {
878 newmap.
insert(std::make_pair(it->first.copy(), it->second.copy()));
893 if (
size() != other.
size())
return false;
894 for (const_iterator it =
begin(); it !=
end(); ++it) {
895 const_iterator jt = other.
find(it.key());
896 if (jt == other.
end())
return false;
897 if (it.value() != jt.value())
return false;
910 iterator
begin() {
return iterator(table?table->table:0, table?table->capacity:0, 0,
true); }
912 iterator
end() {
return iterator(table?table->table:0, table?table->capacity:0, table?table->capacity:0,
false); }
914 const_iterator
begin()
const {
return const_iterator(table?table->table:0, table?table->capacity:0, 0,
true); }
916 const_iterator
end()
const {
return const_iterator(table?table->table:0, table?table->capacity:0, table?table->capacity:0,
false); }
918 const_iterator
cbegin()
const {
return const_iterator(table?table->table:0, table?table->capacity:0, 0,
true); }
920 const_iterator
cend()
const {
return const_iterator(table?table->table:0, table?table->capacity:0, table?table->capacity:0,
false); }
923 size_t size()
const {
return table?table->count:0; }
932 return maybe_insert(std::pair<data_t&&,data_t&&>(std::move(k),
data_t())).first->second;
939 return maybe_insert(std::pair<const data_t&,const data_t&>(k,
data_t())).first->second;
945 const_iterator it =
find(k);
947 throw std::runtime_error(
"Element not in map");
971 std::pair<iterator, bool>
insert(
const std::pair<data_t&&, data_t&&> &v);
985 return insert(std::make_pair(std::move(k), std::move(v)));
990 std::pair<iterator, bool>
insert(
const std::pair<data_t&&, data_t&&> &v, hash_t hash);
1001 void erase(iterator it);
1014 void resize(
size_t newsize);
1017 void really_insert(item_t &item,
const std::pair<data_t&&, data_t&&> &v, hash_t hash);
1019 std::pair<iterator, bool> maybe_insert(
const std::pair<const data_t&, const data_t&> &v);
1021 std::pair<iterator, bool> maybe_insert(
const std::pair<data_t&&, data_t&&> &v);
1023 std::pair<map_t::const_iterator, map_t::const_iterator> find_for_insert(
const data_t &k, hash_t hash)
const;
1026 bool empty(
const item_t &item)
const {
return 0 == item.hash &&
SAG_DATA_EMPTY == item.key.tag; }
1028 bool empty(
const const_iterator::element_t &item)
const {
return 0 == item.hash &&
SAG_DATA_EMPTY == item.first.tag; }
1030 bool hole(
const item_t &item)
const {
return 1 == item.hash &&
SAG_DATA_EMPTY == item.key.tag; }
1032 bool hole(
const const_iterator::element_t &item)
const {
return 1 == item.hash &&
SAG_DATA_EMPTY == item.first.tag; }
1034 bool live(
const item_t &item)
const {
return SAG_DATA_EMPTY != item.key.tag || item.hash > 1; }
1036 bool live(
const const_iterator::element_t &item)
const {
return SAG_DATA_EMPTY != item.first.tag || item.hash > 1; }
1039 size_t index(hash_t hash)
const
1041 if (!table)
return 0;
1042 return table->capacity ? hash % table->capacity : 0;
1045 #ifdef _SAG_INTERNAL_UNSUPPORTED_DEBUG
1047 SAG_CONNECTIVITY_API
static size_t clashes;
1048 SAG_CONNECTIVITY_API
static size_t inserts;
1049 SAG_CONNECTIVITY_API
static double resizeUsage;
1050 SAG_CONNECTIVITY_API
static size_t resizes;
1051 SAG_CONNECTIVITY_API
static size_t max_lookup_clash;
1052 SAG_CONNECTIVITY_API
static size_t lookups;
1053 SAG_CONNECTIVITY_API
static size_t lookup_clashes;
1054 static double getInsertClashRatio() {
return (
double)clashes/(double)inserts; }
1055 static double getAverageResizeRatio() {
return resizeUsage/(double)resizes; }
1056 static void resetCounters() { clashes = inserts = resizeUsage = resizes = 0; }
1057 static double getAverageLookupProbes() {
return 1.0+(double)lookup_clashes/(
double)lookups; }
1058 static size_t getMaxLookupProbes() {
return 1+max_lookup_clash; }
1094 swap(std::move(tmp));
1096 swap(std::move(other));
1103 swap(std::move(other));
1108 std::swap(table, other.table);
1121 typedef uint8_t *iterator;
1122 typedef const uint8_t *const_iterator;
1127 return (this->
size() == other.
size() &&
1141 iterator
begin() {
return table?table->data:0; }
1143 iterator
end() {
return table?table->data+table->length:0; }
1145 const_iterator
begin()
const {
return table?table->data:0; }
1147 const_iterator
end()
const {
return table?table->data+table->length:0; }
1149 const_iterator
cbegin()
const {
return table?table->data:0; }
1151 const_iterator
cend()
const {
return table?table->data+table->length:0; }
1154 size_t size()
const {
return table ? table->length : 0; }
1162 if (n >=
size())
throw std::runtime_error(
"Out of bounds");
1163 return table->data[n];
1169 if (n >=
size())
throw std::runtime_error(
"Out of bounds");
1170 return table->data[n];
1189 template<
typename T>
1205 static std::string
getString(
const map_t &map,
const char *key) {
return getAs<std::string>(map, key); }
1207 static std::string
getString(
const map_t &map,
const char *key,
const char *defaultValue) {
return getAs<std::string>(map, key, defaultValue); }
1209 static std::string
getString(
const map_t &map,
const std::string &key) {
return getAs<std::string>(map, key.c_str()); }
1211 static std::string
getString(
const map_t &map,
const std::string &key,
const std::string &defaultValue) {
return getAs<std::string>(map, key.c_str(), defaultValue); }
1214 static int64_t
getInteger(
const map_t &map,
const char *key) {
return getAs<int64_t>(map, key); }
1216 static int64_t
getInteger(
const map_t &map,
const char *key, int64_t defaultValue) {
return getAs<int64_t>(map, key, defaultValue); }
1218 static int64_t
getInteger(
const map_t &map,
const std::string &key) {
return getAs<int64_t>(map, key.c_str()); }
1220 static int64_t
getInteger(
const map_t &map,
const std::string &key, int64_t defaultValue) {
return getAs<int64_t>(map, key.c_str(), defaultValue); }
1223 static double getDouble(
const map_t &map,
const char *key) {
return getAs<double>(map, key); }
1225 static double getDouble(
const map_t &map,
const char *key,
double defaultValue) {
return getAs<double>(map, key, defaultValue); }
1227 static double getDouble(
const map_t &map,
const std::string &key) {
return getAs<double>(map, key.c_str()); }
1229 static double getDouble(
const map_t &map,
const std::string &key,
double defaultValue) {
return getAs<double>(map, key.c_str(), defaultValue); }
1232 static bool getBoolean(
const map_t &map,
const char *key) {
return getAs<bool>(map, key); }
1234 static bool getBoolean(
const map_t &map,
const char *key,
bool defaultValue) {
return getAs<bool>(map, key, defaultValue); }
1236 static bool getBoolean(
const map_t &map,
const std::string &key) {
return getAs<bool>(map, key.c_str()); }
1238 static bool getBoolean(
const map_t &map,
const std::string &key,
bool defaultValue) {
return getAs<bool>(map, key.c_str(), defaultValue); }
1241 static const map_t &
getMap(
const map_t &map,
const char *key) {
return getAs<const map_t&>(map, key); }
1243 static const map_t &
getMap(
const map_t &map,
const char *key,
const map_t &defaultValue) {
return getAs<const map_t&>(map, key, defaultValue); }
1245 static const map_t &
getMap(
const map_t &map,
const std::string &key) {
return getAs<const map_t&>(map, key.c_str()); }
1247 static const map_t &
getMap(
const map_t &map,
const std::string &key,
const map_t &defaultValue) {
return getAs<const map_t&>(map, key.c_str(), defaultValue); }
1250 static const list_t &
getList(
const map_t &map,
const char *key) {
return getAs<const list_t&>(map, key); }
1252 static const list_t &
getList(
const map_t &map,
const char *key,
const list_t &defaultValue) {
return getAs<const list_t&>(map, key, defaultValue); }
1254 static const list_t &
getList(
const map_t &map,
const std::string &key) {
return getAs<const list_t&>(map, key.c_str()); }
1256 static const list_t &
getList(
const map_t &map,
const std::string &key,
const list_t &defaultValue) {
return getAs<const list_t&>(map, key.c_str(), defaultValue); }
1260 template<
typename T>
1261 static T getAs(
const map_t &map,
const char *key);
1263 template<
typename T>
1264 static T getAs(
const map_t &map,
const char *key,
const T &def);
1299 template<
typename DATA,
typename UNDERLYING,
typename PAIR>
1306 _iterator(
const UNDERLYING &tabledata,
size_t capacity, int64_t offs,
bool stepToItem=
false)
1307 : map_iterator(tabledata, capacity, offs, stepToItem)
1309 _iterator(
const map_iterator &other): map_iterator(other) {}
1310 iterator &operator=(
const map_iterator &other)
1312 map_iterator::tabledata = other.tabledata;
1313 map_iterator::offs = other.offs;
1314 map_iterator::step = other.step;
1315 map_iterator::capacity = other.capacity;
1319 const char* key()
const
1321 assert(map_iterator::tabledata[map_iterator::offs].key.tag ==
SAG_DATA_STRING);
1322 if (map_iterator::tabledata[map_iterator::offs].key.tag !=
SAG_DATA_STRING)
throw std::runtime_error(
"Metadata key not a string");
1323 return map_iterator::tabledata[map_iterator::offs].key.string;
1325 const char* value()
const
1327 assert(map_iterator::tabledata[map_iterator::offs].value.tag ==
SAG_DATA_STRING);
1328 if (map_iterator::tabledata[map_iterator::offs].value.tag !=
SAG_DATA_STRING)
throw std::runtime_error(
"Metadata value not a string");
1329 return map_iterator::tabledata[map_iterator::offs].value.string;
1332 typename map_iterator::element_t &operator*()
const
1334 return reinterpret_cast<typename map_iterator::element_t &
>(map_iterator::tabledata[map_iterator::offs]);
1336 typename map_iterator::element_t *operator->()
const
1338 return reinterpret_cast<typename map_iterator::element_t *
>(map_iterator::tabledata + map_iterator::offs);
1355 swap(std::move(tmp));
1356 swap(std::move(other));
1369 return static_cast<const map_t&
>(*this) ==
static_cast<const map_t&
>(other);
1377 return static_cast<map_t&
>(*this).
swap(static_cast<map_t&&>(other));
1385 iterator it =
find(k);
1387 throw std::runtime_error(
"Element not in map");
1396 const_iterator it =
find(k);
1398 throw std::runtime_error(
"Element not in map");
1408 iterator it =
find(k);
1410 throw std::runtime_error(
"Element not in map");
1419 const_iterator it =
find(k);
1421 throw std::runtime_error(
"Element not in map");
1434 const_iterator
find(
const char *k)
const
1440 iterator
find(
const std::string &k)
1446 const_iterator
find(
const std::string &k)
const
1471 std::pair<iterator, bool>
insert(
const std::pair<std::string, std::string> &v)
1484 std::pair<iterator, bool>
insert(
const std::pair<const char*, const char*> &v)
1518 iterator
begin() {
return iterator(table?table->table:0, table?table->capacity:0, 0,
true); }
1520 iterator
end() {
return iterator(table?table->table:0, table?table->capacity:0, table?table->capacity:0,
false); }
1522 const_iterator
begin()
const {
return const_iterator(table?table->table:0, table?table->capacity:0, 0,
true); }
1524 const_iterator
end()
const {
return const_iterator(table?table->table:0, table?table->capacity:0, table?table->capacity:0,
false); }
1526 const_iterator
cbegin()
const {
return const_iterator(table?table->table:0, table?table->capacity:0, 0,
true); }
1528 const_iterator
cend()
const {
return const_iterator(table?table->table:0, table?table->capacity:0, table?table->capacity:0,
false); }
1558 explicit Message(payload_t &&_payload);
1563 Message(payload_t &&_payload, metadata_t &&_metadata);
1579 swap(std::move(tmp));
1580 swap(std::move(other));
1589 payload_t &
getPayload() {
return static_cast<payload_t&
>(payload); }
1591 metadata_t &
getMetadata() {
return static_cast<metadata_t&
>(metadata); }
1618 return "sag.channel";
1667 template<
typename DERIVED,
typename RV>
1677 result_type
operator()()
const {
return derived().visitEmpty(); }
1679 result_type
visitEmpty()
const {
return derived().error(
"empty"); }
1682 result_type
operator()(int64_t &i)
const {
return derived().visitInteger(i); }
1684 result_type
visitInteger(int64_t &i)
const {
return derived().error(
"integer"); }
1687 result_type
operator()(
double &i)
const {
return derived().visitDouble(i); }
1689 result_type
visitDouble(
double &i)
const {
return derived().error(
"double"); }
1692 result_type
operator()(
bool &i)
const {
return derived().visitBoolean(i); }
1694 result_type
visitBoolean(
bool &i)
const {
return derived().error(
"boolean"); }
1697 result_type
operator()(
const char *&i)
const {
return derived().visitString(i); }
1699 result_type
visitString(
const char *&i)
const {
return derived().error(
"string"); }
1702 result_type
operator()(decimal_t &i)
const {
return derived().visitDecimal(i); }
1704 result_type
visitDecimal(decimal_t &i)
const {
return derived().error(
"decimal"); }
1722 result_type
operator()(sag_underlying_custom_t &i)
const {
return derived().visitCustom(i); }
1724 result_type
visitCustom(sag_underlying_custom_t &i)
const {
return derived().error(
"custom"); }
1729 result_type
error(
const std::string &reason)
const {
throw std::runtime_error(
"Visit type error: "+reason); }
1732 const derived_t &derived()
const {
return static_cast<const derived_t&
>(*this); }
1759 template<
typename DERIVED,
typename RV>
1769 result_type
operator()()
const {
return derived().visitEmpty(); }
1771 result_type
visitEmpty()
const {
return derived().error(
"empty"); }
1774 result_type
operator()(int64_t i)
const {
return derived().visitInteger(i); }
1776 result_type
visitInteger(int64_t i)
const {
return derived().error(
"integer"); }
1779 result_type
operator()(
double i)
const {
return derived().visitDouble(i); }
1781 result_type
visitDouble(
double i)
const {
return derived().error(
"double"); }
1784 result_type
operator()(
bool i)
const {
return derived().visitBoolean(i); }
1786 result_type
visitBoolean(
bool i)
const {
return derived().error(
"boolean"); }
1789 result_type
operator()(
const char *i)
const {
return derived().visitString(i); }
1791 result_type
visitString(
const char *i)
const {
return derived().error(
"string"); }
1794 result_type
operator()(
const decimal_t &i)
const {
return derived().visitDecimal(i); }
1796 result_type
visitDecimal(
const decimal_t &i)
const {
return derived().error(
"decimal"); }
1814 result_type
operator()(
const sag_underlying_custom_t &i)
const {
return derived().visitCustom(i); }
1816 result_type
visitCustom(
const sag_underlying_custom_t &i)
const {
return derived().error(
"custom"); }
1821 result_type
error(
const std::string &reason)
const {
throw std::runtime_error(
"Visit type error: "+reason); }
1824 const derived_t &derived()
const {
return static_cast<const derived_t&
>(*this); }
1831 #include <sag_internal/data.hpp>
1833 #endif // _CPPMESSAGEDATA_H_
data_t & operator=(list_t &&d)
Assign this to a list_t, freeing the existing contents.
Definition: sag_connectivity_cpp.hpp:294
result_type visitString(const char *&i) const
Visit a string.
Definition: sag_connectivity_cpp.hpp:1699
result_type visitList(list_t &i) const
Visit a list.
Definition: sag_connectivity_cpp.hpp:1714
bool empty() const
Returns true if the map is empty (size() == 0)
Definition: sag_connectivity_cpp.hpp:926
static double getDouble(const map_t &map, const std::string &key)
Get a double value from the map, throwing if the key is not present.
Definition: sag_connectivity_cpp.hpp:1227
~data_t()
For non-primitives free the underlying memory.
void setMetadata(metadata_t &&_metadata)
Set the metadata.
result_type visitBuffer(buffer_t &i) const
Visit a byte buffer.
Definition: sag_connectivity_cpp.hpp:1709
const metadata_t & getMetadata() const
Return a reference to the metadata.
metadata_t & getMetadata()
Return a reference to the metadata.
Definition: sag_connectivity_cpp.hpp:1591
void clear()
Clear the list and free the underlying data structure (capacity is now 0)
const_iterator end() const
Forward const_iterator end.
Definition: sag_connectivity_cpp.hpp:1147
result_type operator()(bool &i) const
Visit a boolean (don't override this, instead override visitBoolean)
Definition: sag_connectivity_cpp.hpp:1692
result_type operator()(const buffer_t &i) const
Visit a byte buffer (don't override this, instead override visitBuffer)
Definition: sag_connectivity_cpp.hpp:1799
result_type visitMap(const map_t &i) const
Visit a map.
Definition: sag_connectivity_cpp.hpp:1811
const_iterator rend() const
Reverse const_iterator end.
Definition: sag_connectivity_cpp.hpp:651
T convert_to(const data_t &d)
Get a T from a data_t, parsing it from a string if necessary/possible.
Definition: sag_connectivity_cpp.hpp:1190
void clear()
Empty the map and free the underlying data.
iterator begin()
Forward iterator begin.
Definition: sag_connectivity_cpp.hpp:910
sag_data_tag
A descriminator for the content of the data_t union.
Definition: sag_connectivity_c.h:33
com::softwareag::connectivity::metadata_t metadata_t
The type of a message metadata.
Definition: sag_connectivity_cpp.hpp:1549
Message copy() const
Return a deep copy of this message, payload and metadata.
Definition: sag_connectivity_cpp.hpp:1606
byte-array (8-bit signed int)
Definition: sag_connectivity_c.h:52
Helper class for extracting values from a string->data_t map_t in a type-safe way with error checking...
Definition: sag_connectivity_cpp.hpp:1200
const data_t & front() const
Returns a reference to the data_t at position 0 Throws std::runtime_error if the list is empty...
Definition: sag_connectivity_cpp.hpp:666
result_type operator()(const list_t &i) const
Visit a list (don't override this, instead override visitList)
Definition: sag_connectivity_cpp.hpp:1804
static int64_t getInteger(const map_t &map, const std::string &key, int64_t defaultValue)
Get an integer value from the map, returning the given default if the key is not present.
Definition: sag_connectivity_cpp.hpp:1220
list of data
Definition: sag_connectivity_c.h:48
const T & operator*() const
Return the wrapped pointer as the correct type.
Definition: sag_connectivity_cpp.hpp:416
data_t(int64_t d)
Create a data_t from an int64_t.
Definition: sag_connectivity_cpp.hpp:187
bool operator==(const data_t &other) const
Returns true if two data_ts are deep-equals.
Helper class for writing visitors to apply to data_t.
Definition: sag_connectivity_cpp.hpp:1760
const_iterator begin() const
Forward const_iterator begin.
Definition: sag_connectivity_cpp.hpp:1145
data_t & front()
Returns a reference to the data_t at position 0 Throws std::runtime_error if the list is empty...
Definition: sag_connectivity_cpp.hpp:672
void clear()
Free the underlying buffer;.
iterator begin()
Forward iterator begin.
Definition: sag_connectivity_cpp.hpp:633
result_type error(const std::string &reason) const
Handles visiting unhandled types.
Definition: sag_connectivity_cpp.hpp:1821
data_t copy() const
Return a deep copy of this data_t.
void swap(data_t &&other)
Swap the contents of this data_t with another.
static int64_t getInteger(const map_t &map, const std::string &key)
Get an integer value from the map, throwing if the key is not present.
Definition: sag_connectivity_cpp.hpp:1218
iterator rend()
Reverse iterator end.
Definition: sag_connectivity_cpp.hpp:647
~Message()
Free the underlying payload and metadata.
map_t()
Construct an empty map.
Definition: sag_connectivity_cpp.hpp:836
result_type visitBoolean(bool i) const
Visit a boolean.
Definition: sag_connectivity_cpp.hpp:1786
iterator end()
Forward iterator end.
Definition: sag_connectivity_cpp.hpp:635
result_type operator()(double i) const
Visit a double (don't override this, instead override visitDouble)
Definition: sag_connectivity_cpp.hpp:1779
result_type visitDouble(double &i) const
Visit a double.
Definition: sag_connectivity_cpp.hpp:1689
static double getDouble(const map_t &map, const char *key)
Get a double value from the map, throwing if the key is not present.
Definition: sag_connectivity_cpp.hpp:1223
static double getDouble(const map_t &map, const std::string &key, double defaultValue)
Get a double value from the map, returning the given default if the key is not present.
Definition: sag_connectivity_cpp.hpp:1229
static const map_t & getMap(const map_t &map, const std::string &key, const map_t &defaultValue)
Get a map value from the map, returning the given default if the key is not present.
Definition: sag_connectivity_cpp.hpp:1247
result_type visitMap(map_t &i) const
Visit a map.
Definition: sag_connectivity_cpp.hpp:1719
static std::string getString(const map_t &map, const std::string &key)
Get a string value from the map, throwing if the key is not present.
Definition: sag_connectivity_cpp.hpp:1209
RV result_type
The return type from applying this visitor.
Definition: sag_connectivity_cpp.hpp:1672
const_iterator rbegin() const
Reverse const_iterator begin.
Definition: sag_connectivity_cpp.hpp:649
Definition: sag_connectivity_threading.h:178
data_t & operator[](const data_t &k)
Return a reference to the item with the given key.
Definition: sag_connectivity_cpp.hpp:937
const_iterator cend() const
Forward const_iterator end.
Definition: sag_connectivity_cpp.hpp:1151
result_type operator()(list_t &i) const
Visit a list (don't override this, instead override visitList)
Definition: sag_connectivity_cpp.hpp:1712
bool operator==(const list_t &other) const
Returns true if this list is deep equals to other list.
V::result_type apply_visitor(const V &v, data_t &t)
Apply a visitor (using the boost::static_visitor pattern) to the given data_t.
Definition: sag_connectivity_cpp.hpp:349
static const list_t & getList(const map_t &map, const std::string &key)
Get a list value from the map, throwing if the key is not present.
Definition: sag_connectivity_cpp.hpp:1254
static const list_t & getList(const map_t &map, const char *key, const list_t &defaultValue)
Get a list value from the map, returning the given default if the key is not present.
Definition: sag_connectivity_cpp.hpp:1252
const_iterator cbegin() const
Forward const_iterator begin.
Definition: sag_connectivity_cpp.hpp:1149
static const map_t & getMap(const map_t &map, const char *key, const map_t &defaultValue)
Get a map value from the map, returning the given default if the key is not present.
Definition: sag_connectivity_cpp.hpp:1243
bool operator==(const map_t &other) const
Returns true if this map deep-equals other.
Definition: sag_connectivity_cpp.hpp:891
static bool getBoolean(const map_t &map, const std::string &key, bool defaultValue)
Get a boolean value from the map, returning the given default if the key is not present.
Definition: sag_connectivity_cpp.hpp:1238
result_type operator()(int64_t &i) const
Visit an integer (don't override this, instead override visitInteger)
Definition: sag_connectivity_cpp.hpp:1682
Message & putMetadataValue(const char *key, const char *value)
Sets a value in the metadata.
bool empty() const
Returns true if this is the empty data_t.
Definition: sag_connectivity_cpp.hpp:107
size_t erase(const data_t &k)
Remove the item with the specified key.
data_t & operator=(double d)
Assign a double to this, freeing the existing contents of this.
Definition: sag_connectivity_cpp.hpp:219
map_t & operator=(map_t &&other)
Move assignment.
Definition: sag_connectivity_cpp.hpp:851
64-bit signed int
Definition: sag_connectivity_c.h:42
~custom_t()
deletes the underlying pointer.
const_iterator cend() const
Forward const_iterator end.
Definition: sag_connectivity_cpp.hpp:643
data_t & operator=(bool b)
Assign a bool to this, freeing the existing contents of this.
Definition: sag_connectivity_cpp.hpp:206
data_t & operator=(decimal_t d)
Assign this to a decimal, freeing the existing contents.
Definition: sag_connectivity_cpp.hpp:250
Message()
Construct an empty message.
list_t copy() const
Return a deep copy of this list.
Definition: sag_connectivity_cpp.hpp:607
std::pair< iterator, bool > insert(data_t &&k, data_t &&v)
Insert a new key/value pair into the map.
Definition: sag_connectivity_cpp.hpp:984
A wrapper type for holding arbitrary objects inside a data_t.
Definition: sag_connectivity_cpp.hpp:43
result_type visitList(const list_t &i) const
Visit a list.
Definition: sag_connectivity_cpp.hpp:1806
result_type operator()(buffer_t &i) const
Visit a byte buffer (don't override this, instead override visitBuffer)
Definition: sag_connectivity_cpp.hpp:1707
A list class which implements many of the functions on std::vector.
Definition: sag_connectivity_cpp.hpp:512
result_type operator()() const
Visit an empty variant (don't override this, instead override visitEmpty)
Definition: sag_connectivity_cpp.hpp:1677
data_t & operator=(custom_t< T > &&d)
Assign this to a custom value, freeing the existing contents This is a move constructor and will leav...
Definition: sag_connectivity_cpp.hpp:237
~list_t()
Free the underlying list.
Definition: sag_connectivity_cpp.hpp:579
result_type operator()(map_t &i) const
Visit a map (don't override this, instead override visitMap)
Definition: sag_connectivity_cpp.hpp:1717
result_type visitString(const char *i) const
Visit a string.
Definition: sag_connectivity_cpp.hpp:1791
void swap(buffer_t &&other)
Swap the contents of this buffer and other.
Definition: sag_connectivity_cpp.hpp:1106
const_iterator cbegin() const
Forward const_iterator begin.
Definition: sag_connectivity_cpp.hpp:918
const_iterator cbegin() const
Forward const_iterator begin.
Definition: sag_connectivity_cpp.hpp:641
data_t()
Construct an empty data_t.
Definition: sag_connectivity_cpp.hpp:77
64-bit IEEE-754 decimal
Definition: sag_connectivity_c.h:44
void swap(Message &&other)
Swap the contents of this message with another.
Message & operator=(Message &&other)
Move assignment from another message.
Definition: sag_connectivity_cpp.hpp:1576
const_iterator cend() const
Forward const_iterator end.
Definition: sag_connectivity_cpp.hpp:920
const uint8_t & operator[](size_t n) const
Return a reference the byte at the given offset.
Definition: sag_connectivity_cpp.hpp:1167
result_type visitDecimal(decimal_t &i) const
Visit a decimal.
Definition: sag_connectivity_cpp.hpp:1704
const_iterator begin() const
Forward const_iterator begin.
Definition: sag_connectivity_cpp.hpp:914
result_type error(const std::string &reason) const
Handles visiting unhandled types.
Definition: sag_connectivity_cpp.hpp:1729
map of data:data
Definition: sag_connectivity_c.h:50
list_t(list_t &&other)
Move construction.
Definition: sag_connectivity_cpp.hpp:596
const payload_t & getPayload() const
Return a reference to the payload.
static bool getBoolean(const map_t &map, const char *key, bool defaultValue)
Get a boolean value from the map, returning the given default if the key is not present.
Definition: sag_connectivity_cpp.hpp:1234
const_iterator end() const
Forward const_iterator end.
Definition: sag_connectivity_cpp.hpp:916
void swap(map_t &&other)
Swap the contents of this map and other.
Definition: sag_connectivity_cpp.hpp:868
data_t & operator=(data_t &&other)
Move-assignment from another data_t.
Definition: sag_connectivity_cpp.hpp:96
static bool getBoolean(const map_t &map, const char *key)
Get a boolean value from the map, throwing if the key is not present.
Definition: sag_connectivity_cpp.hpp:1232
pair< const data_t > const_element
The type of an element in a const map.
Definition: sag_connectivity_cpp.hpp:833
const data_t & back() const
Returns a reference to the data_t at position size()-1 Throws std::runtime_error if the list is empty...
Definition: sag_connectivity_cpp.hpp:669
result_type visitCustom(sag_underlying_custom_t &i) const
Visit a custom object.
Definition: sag_connectivity_cpp.hpp:1724
result_type visitCustom(const sag_underlying_custom_t &i) const
Visit a custom object.
Definition: sag_connectivity_cpp.hpp:1816
const T * operator->() const
Return the wrapped pointer as the correct type.
Definition: sag_connectivity_cpp.hpp:420
~buffer_t()
Free the underlying buffer contents.
Definition: sag_connectivity_cpp.hpp:1083
const data_t & operator[](const data_t &k) const
Return a reference to the item with the given key.
Definition: sag_connectivity_cpp.hpp:943
bool operator!=(const list_t &other) const
Returns false if this list is deep equals to other list.
Definition: sag_connectivity_cpp.hpp:627
void reserve(size_t n)
Ensure the capacity is (at least) n.
Definition: sag_connectivity_cpp.hpp:678
list_t()
Construct an empty list.
Definition: sag_connectivity_cpp.hpp:571
_iterator< const data_t, const sag_underlying_data_t * > const_iterator
The type of iterators over a const list.
Definition: sag_connectivity_cpp.hpp:568
std::pair< iterator, bool > insert(const std::pair< data_t &&, data_t && > &v)
Insert a new key/value pair into the map.
RV result_type
The return type from applying this visitor.
Definition: sag_connectivity_cpp.hpp:1764
map_t(map_t &&other)
Move constructor.
Definition: sag_connectivity_cpp.hpp:861
data_t & operator=(const std::string &s)
Assign this to a string, freeing the existing contents (copies the string).
Definition: sag_connectivity_cpp.hpp:279
static const list_t & getList(const map_t &map, const std::string &key, const list_t &defaultValue)
Get a list value from the map, returning the given default if the key is not present.
Definition: sag_connectivity_cpp.hpp:1256
static int64_t getInteger(const map_t &map, const char *key)
Get an integer value from the map, throwing if the key is not present.
Definition: sag_connectivity_cpp.hpp:1214
Message & putMetadataValue(const std::string &key, const std::string &value)
Sets a value in the metadata.
Definition: sag_connectivity_cpp.hpp:1635
T * operator->()
Return the wrapped pointer as the correct type.
Definition: sag_connectivity_cpp.hpp:418
iterator end()
Forward iterator end.
Definition: sag_connectivity_cpp.hpp:1143
result_type operator()(const char *i) const
Visit a string (don't override this, instead override visitString)
Definition: sag_connectivity_cpp.hpp:1789
uint8_t & operator[](size_t n)
Return a reference to the byte at the given offset.
Definition: sag_connectivity_cpp.hpp:1160
result_type operator()(const decimal_t &i) const
Visit a decimal (don't override this, instead override visitDecimal)
Definition: sag_connectivity_cpp.hpp:1794
bool empty() const
Returns true if the buffer is unallocated (size() == 0)
Definition: sag_connectivity_cpp.hpp:1156
size_t size() const
Return the number of items in this list.
Definition: sag_connectivity_cpp.hpp:654
const_iterator end() const
Forward const_iterator end.
Definition: sag_connectivity_cpp.hpp:639
payload_t & getPayload()
Return a reference to the payload.
Definition: sag_connectivity_cpp.hpp:1589
result_type visitDecimal(const decimal_t &i) const
Visit a decimal.
Definition: sag_connectivity_cpp.hpp:1796
A map class which implements many of the functions on std::map.
Definition: sag_connectivity_cpp.hpp:723
get_details::GetVisitor< custom_t< T > >::result_type get_custom(data_t &t)
Get the contents of the data_t as a typed custom_t.
Definition: sag_connectivity_cpp.hpp:485
size_t size() const
Returns the number of key/value pairs in the map.
Definition: sag_connectivity_cpp.hpp:923
result_type visitBuffer(const buffer_t &i) const
Visit a byte buffer.
Definition: sag_connectivity_cpp.hpp:1801
data_t & operator[](data_t &&k)
Return a reference to the item with the given key.
Definition: sag_connectivity_cpp.hpp:930
A container for an payload and associated metadata.
Definition: sag_connectivity_cpp.hpp:1545
data_t & operator=(const char *s)
Assign this to a string, freeing the existing contents (copies the string).
Definition: sag_connectivity_cpp.hpp:269
result_type operator()() const
Visit an empty variant (don't override this, instead override visitEmpty)
Definition: sag_connectivity_cpp.hpp:1769
static double getDouble(const map_t &map, const char *key, double defaultValue)
Get a double value from the map, returning the given default if the key is not present.
Definition: sag_connectivity_cpp.hpp:1225
data_t(bool b)
Create a data_t from a bool.
Definition: sag_connectivity_cpp.hpp:200
A class that holds an untyped byte buffer.
Definition: sag_connectivity_cpp.hpp:1070
void swap(custom_t &&other)
Swap with another custom_t of the same type.
result_type operator()(const map_t &i) const
Visit a map (don't override this, instead override visitMap)
Definition: sag_connectivity_cpp.hpp:1809
~map_t()
Free the underlying map contents.
Definition: sag_connectivity_cpp.hpp:844
result_type visitEmpty() const
Visit an empty variant.
Definition: sag_connectivity_cpp.hpp:1771
result_type visitEmpty() const
Visit an empty variant.
Definition: sag_connectivity_cpp.hpp:1679
static std::string getString(const map_t &map, const char *key)
Get a string value from the map, throwing if the key is not present.
Definition: sag_connectivity_cpp.hpp:1205
_iterator< data_t, sag_underlying_data_t * > iterator
The type of iterators over a mutable list.
Definition: sag_connectivity_cpp.hpp:566
static int64_t getInteger(const map_t &map, const char *key, int64_t defaultValue)
Get an integer value from the map, returning the given default if the key is not present.
Definition: sag_connectivity_cpp.hpp:1216
static std::string getString(const map_t &map, const std::string &key, const std::string &defaultValue)
Get a string value from the map, returning the given default if the key is not present.
Definition: sag_connectivity_cpp.hpp:1211
data_t & operator=(buffer_t &&d)
Assign this to a buffer_t, freeing the existing contents.
Definition: sag_connectivity_cpp.hpp:324
_iterator< const data_t, sag_underlying_map_table_entry_t const *, const pair< const data_t > > const_iterator
The type of iterators on const maps.
Definition: sag_connectivity_cpp.hpp:829
data_t & operator=(map_t &&d)
Assign this to a map_t, freeing the existing contents.
Definition: sag_connectivity_cpp.hpp:309
bool operator!=(const buffer_t &other) const
Returns true if both buffers are different sizes or have different contents.
Definition: sag_connectivity_cpp.hpp:1132
static const char * CHANNEL()
Returns the metadata key used by the host for identifying the channel of the message - "sag...
Definition: sag_connectivity_cpp.hpp:1617
Decimals are implemented with an underlying 64bit int conforming to IEEE 754 decimal 64...
Definition: sag_connectivity_c.h:95
data_t & operator=(int64_t d)
Assign an int64_t to this, freeing the existing contents of this.
Definition: sag_connectivity_cpp.hpp:193
bool operator!=(const data_t &other) const
Returns true if two data_ts are non-equal (deep equality)
Definition: sag_connectivity_cpp.hpp:115
data_t(double d)
Create a data_t from a double.
Definition: sag_connectivity_cpp.hpp:213
list_t & operator=(list_t &&other)
Move assignment operator.
Definition: sag_connectivity_cpp.hpp:586
_iterator< data_t, sag_underlying_map_table_entry_t *, pair< data_t > > iterator
The type of iterators on mutable maps.
Definition: sag_connectivity_cpp.hpp:827
data_t & back()
Returns a reference to the data_t at position size()-1 Throws std::runtime_error if the list is empty...
Definition: sag_connectivity_cpp.hpp:675
map_t copy() const
Return a deep copy of this map.
Definition: sag_connectivity_cpp.hpp:874
sag_data_tag type_tag() const
Return the descriminator for this union (as an enum of the possible values)
Definition: sag_connectivity_cpp.hpp:177
static const map_t & getMap(const map_t &map, const char *key)
Get a map value from the map, throwing if the key is not present.
Definition: sag_connectivity_cpp.hpp:1241
result_type operator()(const sag_underlying_custom_t &i) const
Visit a custom object (don't override this, instead override visitCustom)
Definition: sag_connectivity_cpp.hpp:1814
const data_t & operator[](size_t n) const
Returns a reference to the data_t at position n.
result_type operator()(double &i) const
Visit a double (don't override this, instead override visitDouble)
Definition: sag_connectivity_cpp.hpp:1687
result_type operator()(const char *&i) const
Visit a string (don't override this, instead override visitString)
Definition: sag_connectivity_cpp.hpp:1697
Helper class for writing visitors to apply to data_t.
Definition: sag_connectivity_cpp.hpp:1668
result_type visitBoolean(bool &i) const
Visit a boolean.
Definition: sag_connectivity_cpp.hpp:1694
const char * type_name() const
Return the name of the contained type as a string (mainly useful for debugging)
Definition: sag_connectivity_cpp.hpp:156
DERIVED derived_t
The type of the derived class.
Definition: sag_connectivity_cpp.hpp:1766
a void* + deleter and copy function pointers
Definition: sag_connectivity_c.h:54
void push_back(data_t &&d)
Add an item to the end of the list.
custom_t & operator=(custom_t &&other)
Move assignment, destroying the current contents.
Bool.
Definition: sag_connectivity_c.h:38
buffer_t(buffer_t &&other)
Move constructor.
Definition: sag_connectivity_cpp.hpp:1100
static const char * HOST_MESSAGE_TYPE()
Returns the metadata key used by the host for identifying the type of the message - "sag...
Definition: sag_connectivity_cpp.hpp:1612
utf8-encoded const char*
Definition: sag_connectivity_c.h:46
const_iterator begin() const
Forward const_iterator begin.
Definition: sag_connectivity_cpp.hpp:637
result_type visitInteger(int64_t &i) const
Visit an integer.
Definition: sag_connectivity_cpp.hpp:1684
bool operator!=(const map_t &other) const
Returns false if this map deep-equals other.
Definition: sag_connectivity_cpp.hpp:903
iterator end()
Forward iterator end.
Definition: sag_connectivity_cpp.hpp:912
bool empty() const
Returns true if there are no items in this list.
Definition: sag_connectivity_cpp.hpp:656
V::result_type apply_visitor(const V &v) const
Apply a visitor (using the boost::static_visitor pattern) to this data_t.
data_t payload_t
The type of a message payload.
Definition: sag_connectivity_cpp.hpp:1551
buffer_t copy() const
Return a deep copy of this buffer.
void swap(list_t &&other)
Swap the contents of this list with other.
Definition: sag_connectivity_cpp.hpp:602
Forward/reverse and const/non-const iterators are implemented using this class.
Definition: sag_connectivity_cpp.hpp:527
A variant type which can be one of the following:
Definition: sag_connectivity_cpp.hpp:69
void pop_back()
Remove the last item in the list.
result_type operator()(int64_t i) const
Visit an integer (don't override this, instead override visitInteger)
Definition: sag_connectivity_cpp.hpp:1774
data_t(data_t &&other)
Construct a data_t, move the contents from another data_t.
Definition: sag_connectivity_cpp.hpp:84
result_type operator()(sag_underlying_custom_t &i) const
Visit a custom object (don't override this, instead override visitCustom)
Definition: sag_connectivity_cpp.hpp:1722
iterator find(const data_t &k)
Searches the map for an item with the given key and returns an iterator to that position in the map...
pair< data_t > element
The type of an element in a mutable map.
Definition: sag_connectivity_cpp.hpp:831
static bool getBoolean(const map_t &map, const std::string &key)
Get a boolean value from the map, throwing if the key is not present.
Definition: sag_connectivity_cpp.hpp:1236
static const list_t & getList(const map_t &map, const char *key)
Get a list value from the map, throwing if the key is not present.
Definition: sag_connectivity_cpp.hpp:1250
result_type operator()(bool i) const
Visit a boolean (don't override this, instead override visitBoolean)
Definition: sag_connectivity_cpp.hpp:1784
custom_t()
Create an empty custom_t.
bool operator==(const buffer_t &other) const
Returns true if both buffers are the same size and have the same contents.
Definition: sag_connectivity_cpp.hpp:1125
custom_t copy() const
Return a copy of the underlying pointer.
result_type visitInteger(int64_t i) const
Visit an integer.
Definition: sag_connectivity_cpp.hpp:1776
static const map_t & getMap(const map_t &map, const std::string &key)
Get a map value from the map, throwing if the key is not present.
Definition: sag_connectivity_cpp.hpp:1245
DERIVED derived_t
The type of the derived class.
Definition: sag_connectivity_cpp.hpp:1674
64-bit float
Definition: sag_connectivity_c.h:40
buffer_t & operator=(buffer_t &&other)
Move assignment.
Definition: sag_connectivity_cpp.hpp:1090
Empty.
Definition: sag_connectivity_c.h:36
T & operator*()
Return the wrapped pointer as the correct type.
Definition: sag_connectivity_cpp.hpp:414
static std::string getString(const map_t &map, const char *key, const char *defaultValue)
Get a string value from the map, returning the given default if the key is not present.
Definition: sag_connectivity_cpp.hpp:1207
void setPayload(payload_t &&_payload)
Set the payload.
Contains the C ABI for connectivity plugins.
result_type visitDouble(double i) const
Visit a double.
Definition: sag_connectivity_cpp.hpp:1781
size_t size() const
Returns the size of the buffer.
Definition: sag_connectivity_cpp.hpp:1154
data_t(decimal_t d)
Create a data_t from a decimal.
Definition: sag_connectivity_cpp.hpp:244
iterator rbegin()
Reverse iterator begin.
Definition: sag_connectivity_cpp.hpp:645
Forward/reverse and const/non-const iterators are implemented using this class.
Definition: sag_connectivity_cpp.hpp:749
buffer_t()
Construct an empty buffer.
Definition: sag_connectivity_cpp.hpp:1075
result_type operator()(decimal_t &i) const
Visit a decimal (don't override this, instead override visitDecimal)
Definition: sag_connectivity_cpp.hpp:1702
iterator begin()
Forward iterator begin.
Definition: sag_connectivity_cpp.hpp:1141