tron@6460: /* $Id$ */ tron@6460: tron@6460: #ifndef CMD_HELPER_H tron@6460: #define CMD_HELPER_H tron@6460: tron@6460: #include "direction.h" tron@6460: #include "macros.h" tron@6460: #include "road.h" tron@6460: tron@6460: tron@6460: template static inline void ExtractValid(); tron@6460: template<> static inline void ExtractValid<1>() {} tron@6460: tron@6460: tron@6460: template struct ExtractBits; tron@6460: template<> struct ExtractBits { static const uint Count = 1; }; tron@6460: template<> struct ExtractBits { static const uint Count = 2; }; tron@6460: template<> struct ExtractBits { static const uint Count = 4; }; tron@6460: tron@6460: tron@6460: template static inline T Extract(U v) tron@6460: { tron@6460: // Check if there are enough bits in v tron@6460: ExtractValid::Count <= sizeof(U) * 8>(); tron@6460: return (T)GB(v, N, ExtractBits::Count); tron@6460: } tron@6460: tron@6460: #endif