src/cmd_helper.h
author translators
Sat, 29 Nov 2008 18:44:52 +0000
changeset 10391 8c1d42c0818d
parent 9111 48ce04029fe4
permissions -rw-r--r--
(svn r14642) -Update: WebTranslator2 update to 2008-11-29 18:44:42
croatian - 163 fixed, 30 changed by knovak (193)
czech - 1 fixed, 1 changed by miris2009 (2)
esperanto - 41 fixed by Athaba (41)
german - 4 fixed, 2 changed by Athaba (6)
greek - 20 fixed by vesnikos (20)
hungarian - 6 changed by IPG (6)
indonesian - 46 fixed by fanioz (46)
malay - 259 fixed by SeaGates (259)
polish - 1 fixed, 10 changed by meush (11)
6134
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
     1
/* $Id$ */
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
     2
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8128
diff changeset
     3
/** @file cmd_helper.h Helper functions to extract data from command parameters. */
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8128
diff changeset
     4
6134
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
     5
#ifndef CMD_HELPER_H
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
     6
#define CMD_HELPER_H
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
     7
8100
6bc08f98ec16 (svn r11661) -Codechange: some header reworks in order to try to reduce the compile time of OpenTTD by reduce the amount of circular-ish dependencies.
rubidium
parents: 6134
diff changeset
     8
#include "direction_type.h"
8102
906a3d3b6df1 (svn r11663) -Codechange: moving of the road related types and functions.
rubidium
parents: 8100
diff changeset
     9
#include "road_type.h"
6134
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
    10
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
    11
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
    12
template<uint N> static inline void ExtractValid();
8128
6856dfdd65f7 (svn r11689) -Fix: compilation error and most of warnings for gcc 4.3
smatz
parents: 8113
diff changeset
    13
template<> inline void ExtractValid<1>() {}
6134
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
    14
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
    15
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
    16
template<typename T> struct ExtractBits;
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
    17
template<> struct ExtractBits<Axis>          { static const uint Count =  1; };
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
    18
template<> struct ExtractBits<DiagDirection> { static const uint Count =  2; };
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
    19
template<> struct ExtractBits<RoadBits>      { static const uint Count =  4; };
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
    20
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
    21
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
    22
template<typename T, uint N, typename U> static inline T Extract(U v)
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
    23
{
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
    24
	// Check if there are enough bits in v
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
    25
	ExtractValid<N + ExtractBits<T>::Count <= sizeof(U) * 8>();
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
    26
	return (T)GB(v, N, ExtractBits<T>::Count);
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
    27
}
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
    28
871305fd9ab7 (svn r8876) -Fix
tron
parents:
diff changeset
    29
#endif