template <class BufferT>

class BigEndianByteOrderer

Defined at line 802 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

BigEndianByteOrderer is an adapter for a byte buffer class which reverses

the addresses of the underlying byte buffer. It is used to implement

big-endian bit blocks.

When used by BitBlock, the resulting bits are numbered with "bit 0" as the

lowest-order bit of the *last* byte in the buffer. For example, for a

12-byte buffer, the bit ordering looks like:

bit addresses of each bit in each byte

+----+----+----+----+----+----+----+----+----+----+----+----+

bit in 7 | 95 | 87 | 79 | 71 | 63 | 55 | 47 | 39 | 31 | 23 | 15 | 7 |

byte 6 | 94 | 86 | 78 | 70 | 62 | 54 | 46 | 38 | 30 | 22 | 14 | 6 |

5 | 93 | 85 | 77 | 69 | 61 | 53 | 45 | 37 | 29 | 21 | 13 | 5 |

4 | 92 | 84 | 76 | 68 | 60 | 52 | 44 | 36 | 28 | 20 | 12 | 4 |

3 | 91 | 83 | 75 | 67 | 59 | 51 | 43 | 35 | 27 | 19 | 11 | 3 |

2 | 90 | 82 | 74 | 66 | 58 | 50 | 42 | 34 | 26 | 18 | 10 | 2 |

1 | 89 | 81 | 73 | 65 | 57 | 49 | 41 | 33 | 25 | 17 | 9 | 1 |

0 | 88 | 80 | 72 | 64 | 56 | 48 | 40 | 32 | 24 | 16 | 8 | 0 |

+----+----+----+----+----+----+----+----+----+----+----+----+

0 1 2 3 4 5 6 7 8 9 10 11

byte address

Note that some big-endian protocols are documented with "bit 0" being the

*high-order* bit of a number, in which case "bit 0" would be the

highest-order bit of the first byte in the buffer. The "bit 0 is the

high-order bit" style seems to be more common in older documents (e.g., RFCs

791 and 793, for IP and TCP), while the Emboss-style "bit 0 is in the last

byte" seems to be more common in newer documents (e.g., the hardware user

manuals bolms

@

examined).

TODO(bolms): Examine more documents to see if the old vs new pattern holds.

Because endian-specific reads and writes are handled in ContiguousBuffer,

this class exists mostly to translate VerbUInt calls to VerbBigEndianUInt.

Public Methods

void BigEndianByteOrderer<BufferT> ()

Defined at line 807 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

void BigEndianByteOrderer<BufferT> (BufferType buffer)

Defined at line 808 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

void BigEndianByteOrderer<BufferT> (const BigEndianByteOrderer<BufferT> & other)

Defined at line 809 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

void BigEndianByteOrderer<BufferT> (BigEndianByteOrderer<BufferT> && other)

Defined at line 810 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

BigEndianByteOrderer<BufferT> & operator= (const BigEndianByteOrderer<BufferT> & other)

Defined at line 811 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

bool Ok ()

Ok() and SizeInBytes() get passed through with no changes.

Defined at line 814 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

::std::size_t SizeInBytes ()

Defined at line 815 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <::std::size_t kBits>
typename LeastWidthInteger<kBits>::Unsigned ReadUInt ()

Defined at line 818 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <::std::size_t kBits>
typename LeastWidthInteger<kBits>::Unsigned UncheckedReadUInt ()

Defined at line 822 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <::std::size_t kBits>
void WriteUInt (typename LeastWidthInteger<kBits>::Unsigned value)

Defined at line 826 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h

template <::std::size_t kBits>
void UncheckedWriteUInt (typename LeastWidthInteger<kBits>::Unsigned value)

Defined at line 830 of file ../../third_party/github.com/google/emboss/src/runtime/cpp/emboss_memory_util.h