1234567891011121314151617181920212223242526 |
- #ifndef tool_byte_h
- #define tool_byte_h
- #include <vector>
- #include <string>
- struct tool_byte{
-
- template<class T>
- static void memcpy_int(std::vector<char>& msg, T val)
- {
- for(int i = sizeof(T) - 1; i>=0; --i)
- {
- msg.push_back((val>>(i*8))&0xff);
- }
- }
- static std::string to_cardid(const int ctype, const int cid)
- {
- char sz[20] = {0};
- sprintf(sz, "%.3d%.10d", ctype, cid);
- return std::string(sz);
- }
- };
- #endif
|