entitiesdef.h File Reference

Handles definition of entities, parsing them from entities.ufo. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

union  int_float_u
struct  entityKeyRange_s
struct  entityKeyDef_s
struct  entityDef_s

Defines

#define ED_MAX_DEFS   64
#define ED_ERROR   -1
#define ED_OK   1
#define ED_OPTIONAL   (1<<0)
#define ED_MANDATORY   (1<<1)
#define ED_ABSTRACT   (1<<2)
#define ED_TYPE_FLOAT   (1<<3)
#define ED_TYPE_INT   (1<<4)
#define ED_TYPE_STRING   (1<<5)
#define ED_DEFAULT   (1<<6)
#define ED_MODE_TYPE   (1<<7)
#define ED_RANGE   (1<<8)
#define ED_INSIST_POSITIVE   (1<<9)
#define ED_CONCRETE   (ED_OPTIONAL | ED_MANDATORY)
#define ED_KEY_TYPE   (ED_TYPE_FLOAT | ED_TYPE_INT | ED_TYPE_STRING)

Typedefs

typedef union int_float_u int_float_tu
typedef struct entityKeyRange_s entityKeyRange_t
typedef struct entityKeyDef_s entityKeyDef_t
typedef struct entityDef_s entityDef_t

Functions

int ED_GetDefaultFloat (float *defaultBuf, const int n, const entityKeyDef_t *kd)
 gets the default value for the key
int ED_GetDefaultInt (int *defaultBuf, const int n, const entityKeyDef_t *kd)
 gets the default value for the key
int ED_GetDefaultString (char *defaultBuf, const size_t n, const entityKeyDef_t *kd)
 gets the default value for the key
int ED_GetIntVector (const entityKeyDef_t *kd, int v[], const int n)
 parses a value from the definition
int ED_Check (const char *classname, const char *key, const char *value)
 tests if a value string matches the type for this key. Also checks the value against the range, if one was defined.
int ED_CheckKey (const entityKeyDef_t *kd, const char *value)
 as ED_Check, but where the entity and key are known, so takes different arguments.
const entityDef_tED_GetEntityDef (const char *classname)
 searches for the parsed entity def by classname
const entityKeyDef_tED_GetKeyDef (const char *classname, const char *keyname, const int abstract)
 searches for the parsed key def
const entityKeyDef_tED_GetKeyDefEntity (const entityDef_t *ed, const char *keyname, const int abstract)
 searches for the parsed key def, when the entity def is known
int ED_Parse (const char *data_p)
const char * ED_GetLastError (void)
void ED_Free (void)

Variables

int numEntityDefs
entityDef_t entityDefs [ED_MAX_DEFS+1]

Detailed Description

Handles definition of entities, parsing them from entities.ufo.

Definition in file entitiesdef.h.


Define Documentation

#define ED_ABSTRACT   (1<<2)

flag and parse mode, radiant use exclusively, should not be in .map file as a key

Definition at line 42 of file entitiesdef.h.

Referenced by ED_Block2Constant(), ED_Constant2Block(), ED_FindKeyDefInArray(), ED_GetKeyDefEntity(), ED_PairParsed(), and ED_ParseEntities().

#define ED_CONCRETE   (ED_OPTIONAL | ED_MANDATORY)

flags indicating that this is a real key for use in a map file

Definition at line 51 of file entitiesdef.h.

#define ED_DEFAULT   (1<<6)

Definition at line 46 of file entitiesdef.h.

Referenced by ED_Block2Constant(), ED_Constant2Block(), and ED_PairParsed().

#define ED_ERROR   -1
#define ED_INSIST_POSITIVE   (1<<9)

the type insists that the values are unsigned

Definition at line 49 of file entitiesdef.h.

Referenced by ED_CheckNumericType(), ED_ParseType(), and ED_ProcessRanges().

#define ED_KEY_TYPE   (ED_TYPE_FLOAT | ED_TYPE_INT | ED_TYPE_STRING)

Definition at line 52 of file entitiesdef.h.

Referenced by ED_CheckKey(), and ED_ProcessRanges().

#define ED_MANDATORY   (1<<1)

flag and parse mode. for entityKeyDef_t flags. entities of this type are not valid without this key. also a parse mode

Definition at line 41 of file entitiesdef.h.

Referenced by CheckEntities(), ED_Block2Constant(), ED_Constant2Block(), ED_PairParsed(), and ED_ParseEntities().

#define ED_MAX_DEFS   64

Definition at line 35 of file entitiesdef.h.

Referenced by ED_Parse(), and ED_ParseEntities().

#define ED_MODE_TYPE   (1<<7)

flag parse mode indicating that a type is being parsed

Definition at line 47 of file entitiesdef.h.

Referenced by ED_Block2Constant(), ED_Constant2Block(), and ED_PairParsed().

#define ED_OK   1
#define ED_OPTIONAL   (1<<0)

flag and parse mode

Definition at line 40 of file entitiesdef.h.

Referenced by ED_Block2Constant(), ED_Constant2Block(), and ED_PairParsed().

#define ED_RANGE   (1<<8)

Definition at line 48 of file entitiesdef.h.

Referenced by ED_Block2Constant(), ED_Constant2Block(), and ED_PairParsed().

#define ED_TYPE_FLOAT   (1<<3)
#define ED_TYPE_INT   (1<<4)
#define ED_TYPE_STRING   (1<<5)

Typedef Documentation

typedef struct entityDef_s entityDef_t
typedef union int_float_u int_float_tu

Function Documentation

int ED_Check ( const char *  classname,
const char *  key,
const char *  value 
)

tests if a value string matches the type for this key. Also checks the value against the range, if one was defined.

Returns:
ED_OK or ED_ERROR
See also:
ED_GetLastError
Note:
abstract (radiant) keys may not have types. keys used here must be declared in entities.ufo in an optional or mandatory block.

Definition at line 402 of file entitiesdef.c.

References ED_CheckKey(), ED_ERROR, and ED_GetKeyDef().

int ED_CheckKey ( const entityKeyDef_t kd,
const char *  value 
)

as ED_Check, but where the entity and key are known, so takes different arguments.

Returns:
ED_ERROR or ED_OK
See also:
ED_GetLastError

Definition at line 417 of file entitiesdef.c.

References ED_CheckNumericType(), ED_KEY_TYPE, ED_OK, ED_RETURN_ERROR, ED_TEST_RETURN_ERROR, ED_TYPE_FLOAT, ED_TYPE_INT, ED_TYPE_STRING, and entityKeyDef_s::flags.

Referenced by CheckEntities(), ED_Check(), and ED_CheckDefaultTypes().

void ED_Free ( void   ) 
int ED_GetDefaultFloat ( float *  defaultBuf,
const int  n,
const entityKeyDef_t kd 
)

gets the default value for the key

Parameters:
[in] defaultBuf the calling function is responsible for ensuring this buffer has enough space
n the number of floats the defaultBuf can hold
kd the key definition to get the default for.
See also:
ED_GetKeyDef can be used to find kd.
Returns:
ED_OK or ED_ERROR (no default, or n is too small).
Note:
the defualt int array is tested on parsing

Definition at line 230 of file entitiesdef.c.

References entityKeyDef_s::defaultVal, ED_GetFloatVectorFromString(), ED_OK, ED_PASS_ERROR, ED_TEST_RETURN_ERROR, ED_TYPE_FLOAT, and entityKeyDef_s::flags.

int ED_GetDefaultInt ( int *  defaultBuf,
const int  n,
const entityKeyDef_t kd 
)

gets the default value for the key

Parameters:
[in] defaultBuf the calling function is responsible for ensuring this buffer has enough space
n the number of ints the defaultBuf can hold
kd the key definition to get the default for.
See also:
ED_GetKeyDef can be used to find kd.
Returns:
ED_OK or ED_ERROR (no default, or n is too small).
Note:
the defualt int array is tested on parsing

Definition at line 248 of file entitiesdef.c.

References entityKeyDef_s::defaultVal, ED_GetIntVectorFromString(), ED_OK, ED_PASS_ERROR, ED_TEST_RETURN_ERROR, ED_TYPE_INT, and entityKeyDef_s::flags.

int ED_GetDefaultString ( char *  defaultBuf,
const size_t  n,
const entityKeyDef_t kd 
)

gets the default value for the key

Parameters:
[in] defaultBuf the calling function is responsible for ensuring this buffer has enough space
n the number of chars the defualtBuf can hold
kd the key definition to get the default for. E
See also:
D_GetKeyDef can be used to find kd.
Returns:
ED_OK or ED_ERROR (no default, or n is too small).

Definition at line 442 of file entitiesdef.c.

References entityKeyDef_s::defaultVal, ED_OK, and ED_TEST_RETURN_ERROR.

const entityDef_t* ED_GetEntityDef ( const char *  classname  ) 

searches for the parsed entity def by classname

Returns:
NULL if the entity def is not found. call ED_GetLastError to get a relevant message.

Definition at line 875 of file entitiesdef.c.

References entityDef_s::classname, lastErr, and entityDef_s::numKeyDefs.

Referenced by CheckEntities(), ED_GetKeyDef(), and ED_ParseEntities().

int ED_GetIntVector ( const entityKeyDef_t kd,
int  v[],
const int  n 
)

parses a value from the definition

Parameters:
kd the key definition to parse from
[out] v the array of int to put the answer in it must have enough space for n elements.
n the number of elements expected in the vector
Returns:
ED_ERROR or ED_OK
See also:
ED_GetLastError.

Definition at line 265 of file entitiesdef.c.

References entityKeyDef_s::desc, ED_GetIntVectorFromString(), ED_OK, and ED_PASS_ERROR.

Referenced by Check_InfoStartAligned().

const entityKeyDef_t* ED_GetKeyDef ( const char *  classname,
const char *  keyname,
const int  abstract 
)

searches for the parsed key def

Parameters:
abstract send abstract to find an abstract key with this name
Returns:
NULL if the entity def or key def is not found. call ED_GetLastError to get a relevant message.

Definition at line 837 of file entitiesdef.c.

References ED_GetEntityDef(), and ED_GetKeyDefEntity().

Referenced by ED_Check().

const entityKeyDef_t* ED_GetKeyDefEntity ( const entityDef_t ed,
const char *  keyname,
const int  abstract 
)

searches for the parsed key def, when the entity def is known

Parameters:
abstract send a nonzero value if the abstract (radiant - not in any block) version of the key is required
Returns:
NULL if the entity def or key def is not found. call ED_GetLastError to get a relevant message.

Definition at line 849 of file entitiesdef.c.

References entityDef_s::classname, ED_ABSTRACT, entityKeyDef_s::flags, entityDef_s::keyDefs, lastErr, and entityKeyDef_s::name.

Referenced by Check_InfoStartAligned(), CheckEntities(), and ED_GetKeyDef().

const char* ED_GetLastError ( void   ) 

Definition at line 827 of file entitiesdef.c.

References lastErr.

Referenced by Check_InfoStartAligned(), Check_InitEntityDefs(), and CheckEntities().

int ED_Parse ( const char *  data_p  ) 

parses entity definitions from entities.ufo

Returns:
ED_OK or ED_ERR
See also:
ED_GetLastErr

Definition at line 798 of file entitiesdef.c.

References ED_CheckDefaultTypes(), ED_MAX_DEFS, ED_OK, ED_ParseEntities(), ED_PASS_ERROR, ED_ProcessRanges(), ED_TEST_RETURN_ERROR, lastErr, and numEntityDefs.

Referenced by Check_InitEntityDefs().


Variable Documentation

entityDef_t entityDefs[ED_MAX_DEFS+1]

Definition at line 45 of file entitiesdef.c.

Referenced by Check_Stats().

Definition at line 44 of file entitiesdef.c.

Referenced by Check_InitEntityDefs(), Check_Stats(), ED_Free(), ED_Parse(), and ED_ParseEntities().


Generated by  doxygen 1.6.2