tron@6460: /* $Id$ */ tron@6460: rubidium@10455: /** @file cmd_helper.h Helper functions to extract data from command parameters. */ rubidium@10455: tron@6460: #ifndef CMD_HELPER_H tron@6460: #define CMD_HELPER_H tron@6460: rubidium@9723: #include "direction_type.h" rubidium@9723: #include "road_type.h" tron@6460: tron@6460: tron@6460: template static inline void ExtractValid(); rubidium@9723: 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