#ifndef morpheo_ToBase2 #define morpheo_ToBase2 /* * $Id$ * * [ Description ] * */ #include using namespace std; namespace morpheo { template inline std::string toBase2 (const T& value, const uint32_t & size) { ostringstream res; T mask = 1<<(size-1); while (mask != 0) { res << ((value&mask)?'1':'0'); mask >>= 1; } return res.str(); } inline std::string toBase2 (const bool & value) { return toBase2 (value, 1); } inline std::string toBase2 (const uint8_t & value, const uint32_t & size) { return toBase2 (value, size); } inline std::string toBase2 (const uint16_t& value, const uint32_t & size) { return toBase2 (value, size); } inline std::string toBase2 (const uint32_t& value, const uint32_t & size) { return toBase2 (value, size); } inline std::string toBase2 (const uint64_t& value, const uint32_t & size) { return toBase2 (value, size); } }; // end namespace morpheo #endif