diff --git a/src/odb/include/odb/dbStream.h b/src/odb/include/odb/dbStream.h index 0599a46354e..c14a6517838 100644 --- a/src/odb/include/odb/dbStream.h +++ b/src/odb/include/odb/dbStream.h @@ -38,6 +38,7 @@ #include #include #include +#include #include "ZException.h" #include "dbObject.h" @@ -192,6 +193,18 @@ class dbOStream return *this; } + template + dbOStream& operator<<(const std::unordered_map& m) + { + uint sz = m.size(); + *this << sz; + for (auto const& [key, val] : m) { + *this << key; + *this << val; + } + return *this; + } + template dbOStream& operator<<(const std::array& a) { @@ -342,6 +355,20 @@ class dbIStream } return *this; } + template + dbIStream& operator>>(std::unordered_map& m) + { + uint sz; + *this >> sz; + for (uint i = 0; i < sz; i++) { + T1 key; + T2 val; + *this >> key; + *this >> val; + m[key] = val; + } + return *this; + } template dbIStream& operator>>(std::array& a) {