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));
258 explicit data_t(
const char *s);
261 explicit data_t(
const std::string &s);
268 swap(std::move(tmp));
278 swap(std::move(tmp));
293 swap(std::move(tmp));
308 swap(std::move(tmp));
323 swap(std::move(tmp));
387 class custom_t:
public sag_underlying_custom_t
398 T *
get() {
return this->data ?
reinterpret_cast<T*
>(this->data->custom) : 0; }
400 const T *
get()
const {
return this->data ?
reinterpret_cast<T*
>(this->data->custom) : 0; }
419 static void deleter(
void *d)
423 delete reinterpret_cast<T*
>(d);
431 static void *copier(
void *d)
434 return d ?
new T(*reinterpret_cast<T*>(d)) : 0;
447 #include <sag_internal/convert_to.hpp>
460 inline typename get_details::GetVisitor<const T>::result_type
get(
const data_t &t) {
return apply_visitor(get_details::GetVisitor<const T>(), t); }
472 inline typename get_details::GetVisitor<T>::result_type
get(
data_t &t) {
return apply_visitor(get_details::GetVisitor<T>(), t); }
508 class list_t:
protected sag_underlying_vector_t
514 static size_t MIN_CAPACITY() {
return 10; }
522 template<
typename DATA,
typename UNDERLYING>
523 struct _iterator:
public std::iterator<std::random_access_iterator_tag, DATA>
527 explicit _iterator(UNDERLYING ptr,
bool forward=
true)
528 : ptr(ptr), direction(forward?1:-1)
530 iterator &operator+=(
size_t n) { ptr += direction*n;
return *
this; }
531 iterator &operator-=(
size_t n) { ptr -= direction*n;
return *
this; }
532 iterator operator+(
size_t n)
const {
return iterator(ptr+(direction*n), direction>0); }
533 iterator operator-(
size_t n)
const {
return iterator(ptr+(direction*-n), direction > 0); }
534 ptrdiff_t operator-(
const iterator &other)
const {
return direction*(ptr-other.ptr); }
535 DATA &operator[](
size_t n)
const {
return static_cast<DATA&
>(ptr[n*direction]); }
536 bool operator<(
const iterator &other)
const {
return direction>0 ? ptr < other.ptr : ptr > other.ptr; }
537 bool operator>(
const iterator &other)
const {
return direction>0 ? ptr > other.ptr : ptr < other.ptr; }
538 bool operator>=(
const iterator &other)
const {
return direction>0 ? ptr >= other.ptr : ptr <= other.ptr; }
539 bool operator<=(
const iterator &other)
const {
return direction>0 ? ptr <= other.ptr : ptr >= other.ptr; }
540 bool operator==(
const iterator &other)
const {
return ptr == other.ptr; }
541 bool operator!=(
const iterator &other)
const {
return !operator==(other); }
542 iterator &operator++() {
return operator+=(1); }
543 iterator operator++(
int)
549 iterator &operator--() {
return operator-=(1); }
550 iterator operator--(
int)
556 DATA &operator*()
const {
return static_cast<DATA&
>(*ptr); }
557 DATA *operator->()
const {
return static_cast<DATA*
>(ptr); }
572 explicit list_t(
size_t n);
586 swap(std::move(tmp));
588 swap(std::move(other));
595 swap(std::move(other));
600 std::swap(table, other.table);
606 for (const_iterator it =
begin(); it !=
end(); ++it) {
631 iterator
end() {
return iterator(table?table->data+table->count:0); }
641 iterator
rbegin() {
return iterator(table?table->data+table->count-1:0,
false); }
650 size_t size()
const {
return table?table->count:0; }
676 if (!table) resize(n);
677 if (n > table->capacity) resize(n);
699 void resize(
size_t newsize);
719 class map_t:
protected sag_underlying_map_t
724 static size_t MIN_CAPACITY() {
return 8; }
726 typedef sag_underlying_map_table_entry_t item_t;
727 typedef int64_t hash_t;
730 template<
typename DATA>
744 template<
typename DATA,
typename UNDERLYING,
typename PAIR>
745 struct _iterator:
public std::iterator<std::bidirectional_iterator_tag, DATA>
749 typedef PAIR element_t;
751 _iterator(): tabledata(0), capacity(0), offs(0) {}
752 _iterator(
const UNDERLYING &tabledata,
size_t capacity, int64_t offs,
bool stepToItem=
false)
753 : tabledata(tabledata), capacity(capacity), offs(offs)
755 if (!valid() && stepToItem) {
760 iterator &operator--()
769 iterator operator--(
int)
775 iterator &operator++()
777 if (offs < capacity) {
784 iterator operator++(
int)
791 DATA &key()
const {
return static_cast<DATA&
>(tabledata[offs].key); }
792 DATA &value()
const {
return static_cast<DATA&
>(tabledata[offs].value); }
794 bool operator==(
const iterator &other)
const
796 bool b = offs == other.offs;
799 bool operator!=(
const iterator &other)
const
801 bool b = !operator==(other);
804 element_t &operator*()
const
806 return reinterpret_cast<element_t &
>(tabledata[offs]);
808 element_t *operator->()
const
810 return reinterpret_cast<element_t *
>(tabledata + offs);
816 return offs >= capacity || offs < 0 || tabledata[offs].key.tag !=
SAG_DATA_EMPTY;
818 UNDERLYING tabledata;
837 explicit map_t(
size_t n);
851 swap(std::move(tmp));
853 swap(std::move(other));
860 swap(std::move(other));
866 std::swap(table, other.table);
873 for (const_iterator it =
begin(); it !=
end(); ++it) {
874 newmap.
insert(std::make_pair(it->first.copy(), it->second.copy()));
889 if (
size() != other.
size())
return false;
890 for (const_iterator it =
begin(); it !=
end(); ++it) {
891 const_iterator jt = other.
find(it.key());
892 if (jt == other.
end())
return false;
893 if (it.value() != jt.value())
return false;
906 iterator
begin() {
return iterator(table?table->table:0, table?table->capacity:0, 0,
true); }
908 iterator
end() {
return iterator(table?table->table:0, table?table->capacity:0, table?table->capacity:0,
false); }
910 const_iterator
begin()
const {
return const_iterator(table?table->table:0, table?table->capacity:0, 0,
true); }
912 const_iterator
end()
const {
return const_iterator(table?table->table:0, table?table->capacity:0, table?table->capacity:0,
false); }
914 const_iterator
cbegin()
const {
return const_iterator(table?table->table:0, table?table->capacity:0, 0,
true); }
916 const_iterator
cend()
const {
return const_iterator(table?table->table:0, table?table->capacity:0, table?table->capacity:0,
false); }
919 size_t size()
const {
return table?table->count:0; }
927 return maybe_insert(std::pair<const data_t&,const data_t&>(k,
data_t())).first->second;
933 const_iterator it =
find(k);
935 throw std::runtime_error(
"Element not in map");
959 std::pair<iterator, bool>
insert(
const std::pair<data_t&&, data_t&&> &v);
973 return insert(std::make_pair(std::move(k), std::move(v)));
978 std::pair<iterator, bool>
insert(
const std::pair<data_t&&, data_t&&> &v, hash_t hash);
989 void erase(iterator it);
1002 void resize(
size_t newsize);
1005 void really_insert(item_t &item,
const std::pair<data_t&&, data_t&&> &v, hash_t hash);
1007 std::pair<iterator, bool> maybe_insert(
const std::pair<const data_t&, const data_t&> &v);
1009 std::pair<map_t::const_iterator, map_t::const_iterator> find_for_insert(
const data_t &k, hash_t hash)
const;
1012 bool empty(
const item_t &item)
const {
return 0 == item.hash &&
SAG_DATA_EMPTY == item.key.tag; }
1014 bool empty(
const const_iterator::element_t &item)
const {
return 0 == item.hash &&
SAG_DATA_EMPTY == item.first.tag; }
1016 bool hole(
const item_t &item)
const {
return 0 != item.hash &&
SAG_DATA_EMPTY == item.key.tag; }
1018 bool hole(
const const_iterator::element_t &item)
const {
return 0 != item.hash &&
SAG_DATA_EMPTY == item.first.tag; }
1020 bool live(
const item_t &item)
const {
return SAG_DATA_EMPTY != item.key.tag; }
1022 bool live(
const const_iterator::element_t &item)
const {
return SAG_DATA_EMPTY != item.first.tag; }
1025 size_t index(hash_t hash)
const
1027 if (!table)
return 0;
1028 return table->capacity ? hash % table->capacity : 0;
1031 #ifdef _SAG_INTERNAL_UNSUPPORTED_DEBUG
1033 SAG_CONNECTIVITY_API
static size_t clashes;
1034 SAG_CONNECTIVITY_API
static size_t inserts;
1035 SAG_CONNECTIVITY_API
static double resizeUsage;
1036 SAG_CONNECTIVITY_API
static size_t resizes;
1037 SAG_CONNECTIVITY_API
static size_t max_lookup_clash;
1038 SAG_CONNECTIVITY_API
static size_t lookups;
1039 SAG_CONNECTIVITY_API
static size_t lookup_clashes;
1040 static double getInsertClashRatio() {
return (
double)clashes/(double)inserts; }
1041 static double getAverageResizeRatio() {
return resizeUsage/(double)resizes; }
1042 static void resetCounters() { clashes = inserts = resizeUsage = resizes = 0; }
1043 static double getAverageLookupProbes() {
return 1.0+(double)lookup_clashes/(
double)lookups; }
1044 static size_t getMaxLookupProbes() {
return 1+max_lookup_clash; }
1078 swap(std::move(tmp));
1080 swap(std::move(other));
1087 swap(std::move(other));
1092 std::swap(table, other.table);
1116 typedef uint8_t *iterator;
1117 typedef const uint8_t *const_iterator;
1123 iterator
begin() {
return table?table->data:0; }
1125 iterator
end() {
return table?table->data+table->length:0; }
1127 const_iterator
begin()
const {
return table?table->data:0; }
1129 const_iterator
end()
const {
return table?table->data+table->length:0; }
1131 const_iterator
cbegin()
const {
return table?table->data:0; }
1133 const_iterator
cend()
const {
return table?table->data+table->length:0; }
1136 size_t size()
const {
return table ? table->length : 0; }
1144 if (n >=
size())
throw std::runtime_error(
"Out of bounds");
1145 return table->data[n];
1151 if (n >=
size())
throw std::runtime_error(
"Out of bounds");
1152 return table->data[n];
1171 template<
typename T>
1187 static std::string
getString(
const map_t &map,
const char *key) {
return getAs<std::string>(map, key); }
1189 static std::string
getString(
const map_t &map,
const char *key,
const char *defaultValue) {
return getAs<std::string>(map, key, defaultValue); }
1191 static std::string
getString(
const map_t &map,
const std::string &key) {
return getAs<std::string>(map, key.c_str()); }
1193 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); }
1196 static int64_t
getInteger(
const map_t &map,
const char *key) {
return getAs<int64_t>(map, key); }
1198 static int64_t
getInteger(
const map_t &map,
const char *key, int64_t defaultValue) {
return getAs<int64_t>(map, key, defaultValue); }
1200 static int64_t
getInteger(
const map_t &map,
const std::string &key) {
return getAs<int64_t>(map, key.c_str()); }
1202 static int64_t
getInteger(
const map_t &map,
const std::string &key, int64_t defaultValue) {
return getAs<int64_t>(map, key.c_str(), defaultValue); }
1205 static double getDouble(
const map_t &map,
const char *key) {
return getAs<double>(map, key); }
1207 static double getDouble(
const map_t &map,
const char *key,
double defaultValue) {
return getAs<double>(map, key, defaultValue); }
1209 static double getDouble(
const map_t &map,
const std::string &key) {
return getAs<double>(map, key.c_str()); }
1211 static double getDouble(
const map_t &map,
const std::string &key,
double defaultValue) {
return getAs<double>(map, key.c_str(), defaultValue); }
1214 static bool getBoolean(
const map_t &map,
const char *key) {
return getAs<bool>(map, key); }
1216 static bool getBoolean(
const map_t &map,
const char *key,
bool defaultValue) {
return getAs<bool>(map, key, defaultValue); }
1218 static bool getBoolean(
const map_t &map,
const std::string &key) {
return getAs<bool>(map, key.c_str()); }
1220 static bool getBoolean(
const map_t &map,
const std::string &key,
bool defaultValue) {
return getAs<bool>(map, key.c_str(), defaultValue); }
1223 static const map_t &
getMap(
const map_t &map,
const char *key) {
return getAs<const map_t&>(map, key); }
1225 static const map_t &
getMap(
const map_t &map,
const char *key,
const map_t &defaultValue) {
return getAs<const map_t&>(map, key, defaultValue); }
1227 static const map_t &
getMap(
const map_t &map,
const std::string &key) {
return getAs<const map_t&>(map, key.c_str()); }
1229 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); }
1232 static const list_t &
getList(
const map_t &map,
const char *key) {
return getAs<const list_t&>(map, key); }
1234 static const list_t &
getList(
const map_t &map,
const char *key,
const list_t &defaultValue) {
return getAs<const list_t&>(map, key, defaultValue); }
1236 static const list_t &
getList(
const map_t &map,
const std::string &key) {
return getAs<const list_t&>(map, key.c_str()); }
1238 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); }
1242 template<
typename T>
1243 static T getAs(
const map_t &map,
const char *key);
1245 template<
typename T>
1246 static T getAs(
const map_t &map,
const char *key,
const T &def);
1281 template<
typename DATA,
typename UNDERLYING,
typename PAIR>
1288 _iterator(
const UNDERLYING &tabledata,
size_t capacity, int64_t offs,
bool stepToItem=
false)
1289 : map_iterator(tabledata, capacity, offs, stepToItem)
1291 _iterator(
const map_iterator &other): map_iterator(other) {}
1292 iterator &operator=(
const map_iterator &other)
1294 map_iterator::tabledata = other.tabledata;
1295 map_iterator::offs = other.offs;
1296 map_iterator::step = other.step;
1297 map_iterator::capacity = other.capacity;
1301 const char* key()
const
1303 assert(map_iterator::tabledata[map_iterator::offs].key.tag ==
SAG_DATA_STRING);
1304 if (map_iterator::tabledata[map_iterator::offs].key.tag !=
SAG_DATA_STRING)
throw std::runtime_error(
"Metadata key not a string");
1305 return map_iterator::tabledata[map_iterator::offs].key.string;
1307 const char* value()
const
1309 assert(map_iterator::tabledata[map_iterator::offs].value.tag ==
SAG_DATA_STRING);
1310 if (map_iterator::tabledata[map_iterator::offs].value.tag !=
SAG_DATA_STRING)
throw std::runtime_error(
"Metadata value not a string");
1311 return map_iterator::tabledata[map_iterator::offs].value.string;
1314 typename map_iterator::element_t &operator*()
const
1316 return reinterpret_cast<typename map_iterator::element_t &
>(map_iterator::tabledata[map_iterator::offs]);
1318 typename map_iterator::element_t *operator->()
const
1320 return reinterpret_cast<typename map_iterator::element_t *
>(map_iterator::tabledata + map_iterator::offs);
1337 swap(std::move(tmp));
1338 swap(std::move(other));
1351 return static_cast<const map_t&
>(*this) ==
static_cast<const map_t&
>(other);
1359 return static_cast<map_t&
>(*this).
swap(static_cast<map_t&&>(other));
1367 iterator it =
find(k);
1369 throw std::runtime_error(
"Element not in map");
1378 const_iterator it =
find(k);
1380 throw std::runtime_error(
"Element not in map");
1390 iterator it =
find(k);
1392 throw std::runtime_error(
"Element not in map");
1401 const_iterator it =
find(k);
1403 throw std::runtime_error(
"Element not in map");
1416 const_iterator
find(
const char *k)
const
1422 iterator
find(
const std::string &k)
1428 const_iterator
find(
const std::string &k)
const
1441 std::pair<iterator, bool>
insert(
const std::pair<std::string, std::string> &v)
1454 std::pair<iterator, bool>
insert(
const std::pair<const char*, const char*> &v)
1487 iterator
begin() {
return iterator(table?table->table:0, table?table->capacity:0, 0,
true); }
1489 iterator
end() {
return iterator(table?table->table:0, table?table->capacity:0, table?table->capacity:0,
false); }
1491 const_iterator
begin()
const {
return const_iterator(table?table->table:0, table?table->capacity:0, 0,
true); }
1493 const_iterator
end()
const {
return const_iterator(table?table->table:0, table?table->capacity:0, table?table->capacity:0,
false); }
1495 const_iterator
cbegin()
const {
return const_iterator(table?table->table:0, table?table->capacity:0, 0,
true); }
1497 const_iterator
cend()
const {
return const_iterator(table?table->table:0, table?table->capacity:0, table?table->capacity:0,
false); }
1527 explicit Message(payload_t &&_payload);
1532 Message(payload_t &&_payload, metadata_t &&_metadata);
1548 swap(std::move(tmp));
1549 swap(std::move(other));
1558 payload_t &
getPayload() {
return static_cast<payload_t&
>(payload); }
1560 metadata_t &
getMetadata() {
return static_cast<metadata_t&
>(metadata); }
1587 return "sag.channel";
1630 template<
typename DERIVED,
typename RV>
1640 result_type
operator()()
const {
return derived().visitEmpty(); }
1642 result_type
visitEmpty()
const {
return derived().error(
"Empty"); }
1645 result_type
operator()(int64_t &i)
const {
return derived().visitInteger(i); }
1647 result_type
visitInteger(int64_t &i)
const {
return derived().error(
"Integer"); }
1650 result_type
operator()(
double &i)
const {
return derived().visitDouble(i); }
1652 result_type
visitDouble(
double &i)
const {
return derived().error(
"Double"); }
1655 result_type
operator()(
bool &i)
const {
return derived().visitBoolean(i); }
1657 result_type
visitBoolean(
bool &i)
const {
return derived().error(
"Boolean"); }
1660 result_type
operator()(
const char *&i)
const {
return derived().visitString(i); }
1662 result_type
visitString(
const char *&i)
const {
return derived().error(
"String"); }
1665 result_type
operator()(decimal_t &i)
const {
return derived().visitDecimal(i); }
1667 result_type
visitDecimal(decimal_t &i)
const {
return derived().error(
"Decimal"); }
1685 result_type
operator()(sag_underlying_custom_t &i)
const {
return derived().visitCustom(i); }
1687 result_type
visitCustom(sag_underlying_custom_t &i)
const {
return derived().error(
"Custom"); }
1692 result_type
error(
const std::string &reason)
const {
throw std::runtime_error(
"Visit type error: "+reason); }
1695 const derived_t &derived()
const {
return static_cast<const derived_t&
>(*this); }
1722 template<
typename DERIVED,
typename RV>
1732 result_type
operator()()
const {
return derived().visitEmpty(); }
1734 result_type
visitEmpty()
const {
return derived().error(
"Empty"); }
1737 result_type
operator()(int64_t i)
const {
return derived().visitInteger(i); }
1739 result_type
visitInteger(int64_t i)
const {
return derived().error(
"Integer"); }
1742 result_type
operator()(
double i)
const {
return derived().visitDouble(i); }
1744 result_type
visitDouble(
double i)
const {
return derived().error(
"Double"); }
1747 result_type
operator()(
bool i)
const {
return derived().visitBoolean(i); }
1749 result_type
visitBoolean(
bool i)
const {
return derived().error(
"Boolean"); }
1752 result_type
operator()(
const char *i)
const {
return derived().visitString(i); }
1754 result_type
visitString(
const char *i)
const {
return derived().error(
"String"); }
1757 result_type
operator()(
const decimal_t &i)
const {
return derived().visitDecimal(i); }
1759 result_type
visitDecimal(
const decimal_t &i)
const {
return derived().error(
"Decimal"); }
1777 result_type
operator()(
const sag_underlying_custom_t &i)
const {
return derived().visitCustom(i); }
1779 result_type
visitCustom(
const sag_underlying_custom_t &i)
const {
return derived().error(
"Custom"); }
1784 result_type
error(
const std::string &reason)
const {
throw std::runtime_error(
"Visit type error: "+reason); }
1787 const derived_t &derived()
const {
return static_cast<const derived_t&
>(*this); }
1794 #include <sag_internal/data.hpp>
1796 #endif // _CPPMESSAGEDATA_H_
data_t & operator=(list_t &&d)
Assign this to a list_t, freeing the existing contents.
Definition: sag_connectivity_cpp.hpp:290
result_type visitString(const char *&i) const
Visit a string.
Definition: sag_connectivity_cpp.hpp:1662
result_type visitList(list_t &i) const
Visit a list.
Definition: sag_connectivity_cpp.hpp:1677
bool empty() const
Returns true if the map is empty (size() == 0)
Definition: sag_connectivity_cpp.hpp:921
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:1209
~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:1672
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:1560
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:1129
result_type operator()(bool &i) const
Visit a boolean (don't override this, instead override visitBoolean)
Definition: sag_connectivity_cpp.hpp:1655
result_type operator()(const buffer_t &i) const
Visit a byte buffer (don't override this, instead override visitBuffer)
Definition: sag_connectivity_cpp.hpp:1762
result_type visitMap(const map_t &i) const
Visit a map.
Definition: sag_connectivity_cpp.hpp:1774
const_iterator rend() const
Reverse const_iterator end.
Definition: sag_connectivity_cpp.hpp:647
T convert_to(const data_t &d)
Get a T from a data_t, parsing it from a string if neccessary/possible.
Definition: sag_connectivity_cpp.hpp:1172
void clear()
Empty the map and free the underlying data.
iterator begin()
Forward iterator begin.
Definition: sag_connectivity_cpp.hpp:906
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:1518
Message copy() const
Return a deep copy of this message, payload and metadata.
Definition: sag_connectivity_cpp.hpp:1575
byte-array (8-bit signed int)
Definition: sag_connectivity_c.h:43
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:1182
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:662
result_type operator()(const list_t &i) const
Visit a list (don't override this, instead override visitList)
Definition: sag_connectivity_cpp.hpp:1767
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:1202
list of data
Definition: sag_connectivity_c.h:41
const T & operator*() const
Return the wrapped pointer as the correct type.
Definition: sag_connectivity_cpp.hpp:412
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:1723
const_iterator begin() const
Forward const_iterator begin.
Definition: sag_connectivity_cpp.hpp:1127
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:668
void clear()
Free the underlying buffer;.
iterator begin()
Forward iterator begin.
Definition: sag_connectivity_cpp.hpp:629
result_type error(const std::string &reason) const
Handles visiting unhandled types.
Definition: sag_connectivity_cpp.hpp:1784
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:1200
iterator rend()
Reverse iterator end.
Definition: sag_connectivity_cpp.hpp:643
~Message()
Free the underlying payload and metadata.
map_t()
Construct an empty map.
Definition: sag_connectivity_cpp.hpp:832
result_type visitBoolean(bool i) const
Visit a boolean.
Definition: sag_connectivity_cpp.hpp:1749
iterator end()
Forward iterator end.
Definition: sag_connectivity_cpp.hpp:631
result_type operator()(double i) const
Visit a double (don't override this, instead override visitDouble)
Definition: sag_connectivity_cpp.hpp:1742
result_type visitDouble(double &i) const
Visit a double.
Definition: sag_connectivity_cpp.hpp:1652
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:1205
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:1211
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:1229
result_type visitMap(map_t &i) const
Visit a map.
Definition: sag_connectivity_cpp.hpp:1682
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:1191
RV result_type
The return type from applying this visitor.
Definition: sag_connectivity_cpp.hpp:1635
const_iterator rbegin() const
Reverse const_iterator begin.
Definition: sag_connectivity_cpp.hpp:645
Definition: sag_connectivity_cpp.hpp:35
data_t & operator[](const data_t &k)
Return a reference to the item with the given key.
Definition: sag_connectivity_cpp.hpp:925
const_iterator cend() const
Forward const_iterator end.
Definition: sag_connectivity_cpp.hpp:1133
result_type operator()(list_t &i) const
Visit a list (don't override this, instead override visitList)
Definition: sag_connectivity_cpp.hpp:1675
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:345
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:1236
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:1234
const_iterator cbegin() const
Forward const_iterator begin.
Definition: sag_connectivity_cpp.hpp:1131
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:1225
bool operator==(const map_t &other) const
Returns true if this map deep-equals other.
Definition: sag_connectivity_cpp.hpp:887
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:1220
result_type operator()(int64_t &i) const
Visit an integer (don't override this, instead override visitInteger)
Definition: sag_connectivity_cpp.hpp:1645
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 assignement.
Definition: sag_connectivity_cpp.hpp:847
64-bit signed int
Definition: sag_connectivity_c.h:38
~custom_t()
deletes the underlying pointer.
const_iterator cend() const
Forward const_iterator end.
Definition: sag_connectivity_cpp.hpp:639
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:603
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:972
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:1769
result_type operator()(buffer_t &i) const
Visit a byte buffer (don't override this, instead override visitBuffer)
Definition: sag_connectivity_cpp.hpp:1670
A list class which implements many of the functions on std::vector.
Definition: sag_connectivity_cpp.hpp:508
result_type operator()() const
Visit an empty variant (don't override this, instead override visitEmpty)
Definition: sag_connectivity_cpp.hpp:1640
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:575
result_type operator()(map_t &i) const
Visit a map (don't override this, instead override visitMap)
Definition: sag_connectivity_cpp.hpp:1680
result_type visitString(const char *i) const
Visit a string.
Definition: sag_connectivity_cpp.hpp:1754
void swap(buffer_t &&other)
Swap the contents of this buffer and other.
Definition: sag_connectivity_cpp.hpp:1090
const_iterator cbegin() const
Forward const_iterator begin.
Definition: sag_connectivity_cpp.hpp:914
const_iterator cbegin() const
Forward const_iterator begin.
Definition: sag_connectivity_cpp.hpp:637
data_t()
Construct an empty data_t.
Definition: sag_connectivity_cpp.hpp:77
64-bit IEEE-754 decimal
Definition: sag_connectivity_c.h:39
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:1545
const_iterator cend() const
Forward const_iterator end.
Definition: sag_connectivity_cpp.hpp:916
const uint8_t & operator[](size_t n) const
Return a reference the byte at the given offset.
Definition: sag_connectivity_cpp.hpp:1149
result_type visitDecimal(decimal_t &i) const
Visit a decimal.
Definition: sag_connectivity_cpp.hpp:1667
const_iterator begin() const
Forward const_iterator begin.
Definition: sag_connectivity_cpp.hpp:910
result_type error(const std::string &reason) const
Handles visiting unhandled types.
Definition: sag_connectivity_cpp.hpp:1692
map of data:data
Definition: sag_connectivity_c.h:42
list_t(list_t &&other)
Move construction. Other will be left as the empty list.
Definition: sag_connectivity_cpp.hpp:592
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:1216
const_iterator end() const
Forward const_iterator end.
Definition: sag_connectivity_cpp.hpp:912
void swap(map_t &&other)
Swap the contents of this map and other.
Definition: sag_connectivity_cpp.hpp:864
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:1214
pair< const data_t > const_element
The type of an element in a const map.
Definition: sag_connectivity_cpp.hpp:829
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:665
result_type visitCustom(sag_underlying_custom_t &i) const
Visit a custom object.
Definition: sag_connectivity_cpp.hpp:1687
result_type visitCustom(const sag_underlying_custom_t &i) const
Visit a custom object.
Definition: sag_connectivity_cpp.hpp:1779
const T * operator->() const
Return the wrapped pointer as the correct type.
Definition: sag_connectivity_cpp.hpp:416
~buffer_t()
Free the underlying buffer contents.
Definition: sag_connectivity_cpp.hpp:1067
const data_t & operator[](const data_t &k) const
Return a reference to the item with the given key.
Definition: sag_connectivity_cpp.hpp:931
bool operator!=(const list_t &other) const
Returns false if this list is deep equals to other list.
Definition: sag_connectivity_cpp.hpp:623
void reserve(size_t n)
Ensure the capacity is (at least) n.
Definition: sag_connectivity_cpp.hpp:674
list_t()
Construct an empty list.
Definition: sag_connectivity_cpp.hpp:567
_iterator< const data_t, const sag_underlying_data_t * > const_iterator
The type of iterators over a const list.
Definition: sag_connectivity_cpp.hpp:564
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:1727
map_t(map_t &&other)
Move constructor. Other will be left as the empty map.
Definition: sag_connectivity_cpp.hpp:857
data_t & operator=(const std::string &s)
Assign this to a string, freeing the existing contents (copies the string).
Definition: sag_connectivity_cpp.hpp:275
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:1238
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:1196
Message & putMetadataValue(const std::string &key, const std::string &value)
Sets a value in the metadata.
Definition: sag_connectivity_cpp.hpp:1598
T * operator->()
Return the wrapped pointer as the correct type.
Definition: sag_connectivity_cpp.hpp:414
iterator end()
Forward iterator end.
Definition: sag_connectivity_cpp.hpp:1125
result_type operator()(const char *i) const
Visit a string (don't override this, instead override visitString)
Definition: sag_connectivity_cpp.hpp:1752
uint8_t & operator[](size_t n)
Return a reference the byte at the given offset.
Definition: sag_connectivity_cpp.hpp:1142
result_type operator()(const decimal_t &i) const
Visit a decimal (don't override this, instead override visitDecimal)
Definition: sag_connectivity_cpp.hpp:1757
bool empty() const
Returns true if the buffer is unallocated (size() == 0)
Definition: sag_connectivity_cpp.hpp:1138
size_t size() const
Return the number of items in this list.
Definition: sag_connectivity_cpp.hpp:650
const_iterator end() const
Forward const_iterator end.
Definition: sag_connectivity_cpp.hpp:635
payload_t & getPayload()
Return a reference to the payload.
Definition: sag_connectivity_cpp.hpp:1558
result_type visitDecimal(const decimal_t &i) const
Visit a decimal.
Definition: sag_connectivity_cpp.hpp:1759
A map class which implements many of the functions on std::map.
Definition: sag_connectivity_cpp.hpp:719
get_details::GetVisitor< custom_t< T > >::result_type get_custom(data_t &t)
Get the contents of the variant as a typed custom_t.
Definition: sag_connectivity_cpp.hpp:481
size_t size() const
Returns the number of key/value pairs in the map.
Definition: sag_connectivity_cpp.hpp:919
result_type visitBuffer(const buffer_t &i) const
Visit a byte buffer.
Definition: sag_connectivity_cpp.hpp:1764
A container for an payload and associated metadata.
Definition: sag_connectivity_cpp.hpp:1514
data_t & operator=(const char *s)
Assign this to a string, freeing the existing contents (copies the string).
Definition: sag_connectivity_cpp.hpp:265
result_type operator()() const
Visit an empty variant (don't override this, instead override visitEmpty)
Definition: sag_connectivity_cpp.hpp:1732
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:1207
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:1054
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:1772
~map_t()
Free the underlying map contents.
Definition: sag_connectivity_cpp.hpp:840
result_type visitEmpty() const
Visit an empty variant.
Definition: sag_connectivity_cpp.hpp:1734
result_type visitEmpty() const
Visit an empty variant.
Definition: sag_connectivity_cpp.hpp:1642
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:1187
_iterator< data_t, sag_underlying_data_t * > iterator
The type of iterators over a mutable list.
Definition: sag_connectivity_cpp.hpp:562
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:1198
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:1193
data_t & operator=(buffer_t &&d)
Assign this to a buffer_t, freeing the existing contents.
Definition: sag_connectivity_cpp.hpp:320
_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:825
data_t & operator=(map_t &&d)
Assign this to a map_t, freeing the existing contents.
Definition: sag_connectivity_cpp.hpp:305
bool operator!=(const buffer_t &other) const
Returns false.
Definition: sag_connectivity_cpp.hpp:1111
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:1586
Decimals are implemented with an underlying 64bit int conforming to IEEE 754 decimal 64...
Definition: sag_connectivity_c.h:74
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 assignement operator.
Definition: sag_connectivity_cpp.hpp:582
_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:823
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:671
map_t copy() const
Return a deep copy of this map.
Definition: sag_connectivity_cpp.hpp:870
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:1223
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:1777
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:1650
result_type operator()(const char *&i) const
Visit a string (don't override this, instead override visitString)
Definition: sag_connectivity_cpp.hpp:1660
Helper class for writing visitors to apply to data_t.
Definition: sag_connectivity_cpp.hpp:1631
result_type visitBoolean(bool &i) const
Visit a boolean.
Definition: sag_connectivity_cpp.hpp:1657
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:1729
a void* + deleter and copy function pointers
Definition: sag_connectivity_c.h:44
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:36
buffer_t(buffer_t &&other)
Move constructor. Other will be left as the empty buffer.
Definition: sag_connectivity_cpp.hpp:1084
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:1581
utf8-encoded const char*
Definition: sag_connectivity_c.h:40
const_iterator begin() const
Forward const_iterator begin.
Definition: sag_connectivity_cpp.hpp:633
result_type visitInteger(int64_t &i) const
Visit an integer.
Definition: sag_connectivity_cpp.hpp:1647
bool operator!=(const map_t &other) const
Returns false if this map deep-equals other.
Definition: sag_connectivity_cpp.hpp:899
iterator end()
Forward iterator end.
Definition: sag_connectivity_cpp.hpp:908
bool empty() const
Returns true if there are no items in this list.
Definition: sag_connectivity_cpp.hpp:652
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:1520
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:598
Forward/reverse and const/non-const iterators are implemented using this class.
Definition: sag_connectivity_cpp.hpp:523
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:1737
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:1685
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:827
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:1218
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:1232
result_type operator()(bool i) const
Visit a boolean (don't override this, instead override visitBoolean)
Definition: sag_connectivity_cpp.hpp:1747
custom_t()
Create an empty custom_t.
bool operator==(const buffer_t &other) const
Returns true.
Definition: sag_connectivity_cpp.hpp:1106
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:1739
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:1227
DERIVED derived_t
The type of the derived class.
Definition: sag_connectivity_cpp.hpp:1637
64-bit float
Definition: sag_connectivity_c.h:37
buffer_t & operator=(buffer_t &&other)
Move assignement.
Definition: sag_connectivity_cpp.hpp:1074
Empty.
Definition: sag_connectivity_c.h:35
T & operator*()
Return the wrapped pointer as the correct type.
Definition: sag_connectivity_cpp.hpp:410
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:1189
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:1744
size_t size() const
Returns the size of the buffer.
Definition: sag_connectivity_cpp.hpp:1136
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:641
Forward/reverse and const/non-const iterators are implemented using this class.
Definition: sag_connectivity_cpp.hpp:745
buffer_t()
Construct an empty buffer.
Definition: sag_connectivity_cpp.hpp:1059
result_type operator()(decimal_t &i) const
Visit a decimal (don't override this, instead override visitDecimal)
Definition: sag_connectivity_cpp.hpp:1665
iterator begin()
Forward iterator begin.
Definition: sag_connectivity_cpp.hpp:1123