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