aboutsummaryrefslogtreecommitdiff
path: root/src/serialize.h
diff options
context:
space:
mode:
authorJim Posen <jim.posen@gmail.com>2019-03-12 00:20:40 -0700
committerJim Posen <jim.posen@gmail.com>2019-04-06 12:03:21 -0700
commit2ad2338ef90bf661c19305afaf2fb648997b0c92 (patch)
tree1b479c647b8fbb3cccbe64ec908d8a5b3b1dc52a /src/serialize.h
parentba6ff9a6f70139594362b4b4a6b816707bb165c8 (diff)
serialize: Serialization support for big-endian 32-bit ints.
Diffstat (limited to 'src/serialize.h')
-rw-r--r--src/serialize.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/serialize.h b/src/serialize.h
index 2d0cfbbbf0..b001ee1324 100644
--- a/src/serialize.h
+++ b/src/serialize.h
@@ -89,6 +89,11 @@ template<typename Stream> inline void ser_writedata32(Stream &s, uint32_t obj)
obj = htole32(obj);
s.write((char*)&obj, 4);
}
+template<typename Stream> inline void ser_writedata32be(Stream &s, uint32_t obj)
+{
+ obj = htobe32(obj);
+ s.write((char*)&obj, 4);
+}
template<typename Stream> inline void ser_writedata64(Stream &s, uint64_t obj)
{
obj = htole64(obj);
@@ -118,6 +123,12 @@ template<typename Stream> inline uint32_t ser_readdata32(Stream &s)
s.read((char*)&obj, 4);
return le32toh(obj);
}
+template<typename Stream> inline uint32_t ser_readdata32be(Stream &s)
+{
+ uint32_t obj;
+ s.read((char*)&obj, 4);
+ return be32toh(obj);
+}
template<typename Stream> inline uint64_t ser_readdata64(Stream &s)
{
uint64_t obj;