Misc.hpp
Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 #ifndef MISC_HPP
00007 #define MISC_HPP
00008 
00009 #include <sstream>
00010 #include <string>
00011 #include <vector>
00012 #include "Benzene.hpp"
00013 #include "Types.hpp"
00014 
00015 _BEGIN_BENZENE_NAMESPACE_
00016 
00017 
00018 
00019 
00020 namespace MiscUtil
00021 {
00022 
00023     void WordToBytes(unsigned word, byte* out);
00024 
00025 
00026     unsigned BytesToWord(const byte* bytes);
00027 
00028 
00029 
00030 
00031     int NumBytesToHoldBits(int bits);
00032 
00033 
00034     template<typename TYPE>
00035     std::string PrintVector(const std::vector<TYPE>& v);
00036 }
00037 
00038 
00039 template<typename TYPE>
00040 std::string MiscUtil::PrintVector(const std::vector<TYPE>& v)
00041 {
00042     std::ostringstream is;
00043     for (std::size_t i=0; i<v.size(); ++i) {
00044         if (i) is << ' ';
00045         is << v[i];
00046     }
00047     return is.str();
00048 } 
00049 
00050 
00051 
00052 _END_BENZENE_NAMESPACE_
00053 
00054 #endif // MISC_HPP