diff options
Diffstat (limited to 'lib/common/Archive.h')
-rw-r--r-- | lib/common/Archive.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/common/Archive.h b/lib/common/Archive.h index b70f12c4..139cc5fd 100644 --- a/lib/common/Archive.h +++ b/lib/common/Archive.h @@ -45,6 +45,10 @@ public: { Write((int) Item); } +<<<<<<< HEAD +======= + void WriteExact(uint32_t Item) { Write((int)Item); } +>>>>>>> 0.12 void Write(int Item) { int32_t privItem = htonl(Item); @@ -55,6 +59,10 @@ public: int64_t privItem = box_hton64(Item); mrStream.Write(&privItem, sizeof(privItem)); } +<<<<<<< HEAD +======= + void WriteExact(uint64_t Item) { Write(Item); } +>>>>>>> 0.12 void Write(uint64_t Item) { uint64_t privItem = box_hton64(Item); @@ -79,7 +87,11 @@ public: int privItem; Read(privItem); +<<<<<<< HEAD if (privItem) +======= + if(privItem) +>>>>>>> 0.12 { rItemOut = true; } @@ -88,6 +100,16 @@ public: rItemOut = false; } } +<<<<<<< HEAD +======= + void ReadIfPresent(bool &rItemOut, bool ValueIfNotPresent) + { + int privItem; + ReadIfPresent(privItem, ValueIfNotPresent ? 1 : 0); + rItemOut = privItem ? true : false; + } + void ReadExact(uint32_t &rItemOut) { Read((int&)rItemOut); } +>>>>>>> 0.12 void Read(int &rItemOut) { int32_t privItem; @@ -97,6 +119,28 @@ public: } rItemOut = ntohl(privItem); } +<<<<<<< HEAD +======= + void ReadIfPresent(int &rItemOut, int ValueIfNotPresent) + { + int32_t privItem; + int bytesRead; + if(mrStream.ReadFullBuffer(&privItem, sizeof(privItem), &bytesRead)) + { + rItemOut = ntohl(privItem); + } + else if(bytesRead == 0) + { + // item is simply not present + rItemOut = ValueIfNotPresent; + } + else + { + // bad number of remaining bytes + THROW_EXCEPTION(CommonException, ArchiveBlockIncompleteRead) + } + } +>>>>>>> 0.12 void Read(int64_t &rItemOut) { int64_t privItem; @@ -106,6 +150,10 @@ public: } rItemOut = box_ntoh64(privItem); } +<<<<<<< HEAD +======= + void ReadExact(uint64_t &rItemOut) { Read(rItemOut); } +>>>>>>> 0.12 void Read(uint64_t &rItemOut) { uint64_t privItem; |