Utilities.cc
Go to the documentation of this file.
2 
4 
5 #include <sstream>
6 #include <bitset>
7 
8 namespace dune {
9 
10 void display_bits(void* memstart, size_t nbytes, std::string sourcename) {
11 
12  std::stringstream bitstr;
13  bitstr << "The " << nbytes << "-byte chunk of memory beginning at " << static_cast<void*>(memstart) << " is : ";
14 
15  // -- NFB : Nov-20-2015
16  // reversed the order of the bits when printing, so that the msb remain on the left
17  for(unsigned int i = 0; i < nbytes; i++) {
18  // bitstr << std::bitset<8>(*((dune::reinterpret_cast_checked<uint8_t*>(memstart))+(nbytes-i-1))) << " ";
19  bitstr << std::bitset<8>(*((dune::reinterpret_cast_checked<uint8_t*>(memstart))+i)) << " ";
20  }
21 
22  mf::LogInfo(sourcename.c_str()) << bitstr.str();
23 }
24 
25 }
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
void display_bits(void *memstart, size_t nbytes, std::string sourcename)
Definition: Utilities.cc:10