(svn r27754) -Codechange: Add GetStringTab(), GetStringIndex() and MakeStringID() to access the structure of StringIDs.

This commit is contained in:
frosch
2017-02-26 19:39:58 +00:00
parent b264dd2a8d
commit 9ad09627ad
7 changed files with 54 additions and 20 deletions

View File

@@ -15,6 +15,38 @@
#include "strings_type.h"
#include "string_type.h"
#include "gfx_type.h"
#include "core/bitmath_func.hpp"
/**
* Extract the StringTab from a StringID.
* @param str String identifier
* @return StringTab from \a str
*/
static inline uint GetStringTab(StringID str)
{
return GB(str, 11, 5);
}
/**
* Extract the StringIndex from a StringID.
* @param str String identifier
* @return StringIndex from \a str
*/
static inline uint GetStringIndex(StringID str)
{
return GB(str, 0, 11);
}
/**
* Create a StringID
* @param tab StringTab
* @param index StringIndex
* @return StringID composed from \a tab and \a index
*/
static inline StringID MakeStringID(uint tab, uint index)
{
return tab << 11 | index;
}
class StringParameters {
StringParameters *parent; ///< If not NULL, this instance references data from this parent instance.