X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fstlplus%2Fpersistence%2Fpersistent_bitset.tpp;fp=src%2Fstlplus%2Fpersistence%2Fpersistent_bitset.tpp;h=0000000000000000000000000000000000000000;hb=5846afb00833cc72fe72422ca896d2387c712cb4;hp=e6b4d542241ddfdac48feb4954e5aa5a111c8f38;hpb=a97500609dc3c1b11f9786d32bc458eb00de4c36;p=chaz%2Fyoink diff --git a/src/stlplus/persistence/persistent_bitset.tpp b/src/stlplus/persistence/persistent_bitset.tpp deleted file mode 100644 index e6b4d54..0000000 --- a/src/stlplus/persistence/persistent_bitset.tpp +++ /dev/null @@ -1,61 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// - -// Author: Andy Rushton -// Copyright: (c) Southampton University 1999-2004 -// (c) Andy Rushton 2004-2009 -// License: BSD License, see ../docs/license.html - -//////////////////////////////////////////////////////////////////////////////// -#include "persistent_int.hpp" - -namespace stlplus -{ - - //////////////////////////////////////////////////////////////////////////////// - // format: data msB first, packed into bytes with lowest index at the byte's lsb - - // Note: the interface does not provide access to the internal storage and yet - // to be efficient the std::bitset must be packed as bytes. Thus I have to do it the - // hard way. - - template - void dump_bitset(dump_context& context, const std::bitset& data) - throw(persistent_dump_failed) - { - size_t bits = data.size(); - size_t bytes = (bits+7)/8; - for (size_t B = bytes; B--; ) - { - unsigned char ch = 0; - for (size_t b = 0; b < 8; b++) - { - size_t bit = B*8+b; - if (bit < bits && data.test(bit)) - ch |= (0x01 << b); - } - dump_unsigned_char(context,ch); - } - } - - template - void restore_bitset(restore_context& context, std::bitset& data) - throw(persistent_restore_failed) - { - size_t bits = data.size(); - size_t bytes = (bits+7)/8; - for (size_t B = bytes; B--; ) - { - unsigned char ch = 0; - restore_unsigned_char(context,ch); - for (size_t b = 0; b < 8; b++) - { - size_t bit = B*8+b; - if (bit >= bits) break; - data.set(bit, ch & (0x01 << b) ? true : false); - } - } - } - - //////////////////////////////////////////////////////////////////////////////// - -} // end namespace stlplus