tron@6460: /* $Id$ */ tron@6460: tron@6460: #ifndef CMD_HELPER_H tron@6460: #define CMD_HELPER_H tron@6460: rubidium@8596: #include "direction_type.h" rubidium@8598: #include "road_type.h" tron@6460: tron@6460: tron@6460: template static inline void ExtractValid(); smatz@8624: template<> 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