zhuyf 3 лет назад
Родитель
Сommit
d536d5a367
1 измененных файлов с 26 добавлено и 0 удалено
  1. 26 0
      tool_byte.h

+ 26 - 0
tool_byte.h

@@ -0,0 +1,26 @@
+#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