comparison C++/Pack.h @ 219:8fc177bbc4a6

Update some code
author David Demelier <markand@malikania.fr>
date Thu, 08 May 2014 22:55:48 +0200
parents 523156bb3af5
children c6513d9c696b
comparison
equal deleted inserted replaced
218:9324b9e0e7b7 219:8fc177bbc4a6
56 static void writeFile(std::ofstream &out, Endian endian, const T &value, Args&... args) 56 static void writeFile(std::ofstream &out, Endian endian, const T &value, Args&... args)
57 { 57 {
58 static_assert(TypeInfo<T>::supported, "unsupported type"); 58 static_assert(TypeInfo<T>::supported, "unsupported type");
59 59
60 T ret = convert(value, endian); 60 T ret = convert(value, endian);
61 out.write(reinterpret_cast<char *>(&ret), TypeInfo<T>::size); 61 out.write(reinterpret_cast<unsigned char *>(&ret), TypeInfo<T>::size);
62 writeFile(out, endian, args...); 62 writeFile(out, endian, args...);
63 } 63 }
64 64
65 static void readFile(std::ifstream &in, Endian endian) 65 static void readFile(std::ifstream &in, Endian endian)
66 { 66 {
70 template <typename T, typename... Args> 70 template <typename T, typename... Args>
71 static void readFile(std::ifstream &in, Endian endian, T &value, Args&&... args) 71 static void readFile(std::ifstream &in, Endian endian, T &value, Args&&... args)
72 { 72 {
73 static_assert(TypeInfo<T>::supported, "unsupported type"); 73 static_assert(TypeInfo<T>::supported, "unsupported type");
74 74
75 in.read(reinterpret_cast<char *>(&value), TypeInfo<T>::size); 75 in.read(reinterpret_cast<unsigned char *>(&value), TypeInfo<T>::size);
76 value = convert(value, endian); 76 value = convert(value, endian);
77 readFile(in, endian, args...); 77 readFile(in, endian, args...);
78 } 78 }
79 79
80 public: 80 public:
81 /**
82 * Host system endian mode.
83 */
81 static const Endian mode; 84 static const Endian mode;
82 85
83 /** 86 /**
84 * @struct TypeInfo 87 * @struct TypeInfo
85 * @brief Type information 88 * @brief Type information