UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
parse.h File Reference

Shared parsing functions. More...

#include "ufotypes.h"
#include "cxx.h"

Go to the source code of this file.

Enumerations

enum  Com_TokenType_t {
  TT_EOF = 0, TT_BEGIN_BLOCK = '{', TT_END_BLOCK = '}', TT_COMMA = ',',
  TT_BEGIN_LIST = '(', TT_END_LIST = ')', TT_CONTENT = 0xFF, TT_WORD,
  TT_QUOTED_WORD
}
 

Functions

const char * Com_GetToken (const char **data_p)
 Get the current token value. More...
 
Com_TokenType_t Com_GetType (const char **data_p)
 Get the current token type. More...
 
Com_TokenType_t Com_NextToken (const char **data_p)
 Compute the next token. More...
 
const char * Com_Parse (const char **data_p, char *target=nullptr, size_t size=0, bool replaceWhitespaces=true)
 
int Com_CountTokensInBuffer (const char *buffer)
 Counts the tokens in the given buffer that the Com_Parse function would extract. More...
 
void Com_UnParseLastToken (void)
 Put back the last token into the parser The next call of Com_Parse will return the same token again. More...
 
void Com_SkipBlock (const char **text)
 Skips a block of {} in our script files. More...
 
int Com_GetBlock (const char **text, const char **start)
 Get the start and end point of a block in the given text. More...
 

Detailed Description

Shared parsing functions.

Definition in file parse.h.

Enumeration Type Documentation

Enumerator
TT_EOF 
TT_BEGIN_BLOCK 
TT_END_BLOCK 
TT_COMMA 
TT_BEGIN_LIST 
TT_END_LIST 
TT_CONTENT 
TT_WORD 
TT_QUOTED_WORD 

Definition at line 33 of file parse.h.

Function Documentation

int Com_CountTokensInBuffer ( const char *  buffer)

Counts the tokens in the given buffer that the Com_Parse function would extract.

Parameters
[in]bufferThe buffer to count the tokens in
Returns
The amount of tokens in the given buffer

Definition at line 80 of file parse.cpp.

References Com_Parse().

Referenced by R_ModLoadAnims().

int Com_GetBlock ( const char **  text,
const char **  start 
)

Get the start and end point of a block in the given text.

Parameters
[in,out]textThe text pointer to get the start and end for. The pointer is set to the end of the block in this function.
[out]startThe pointer to the beginning of the block
Returns
The amount of characters in the block, or -1 if the text does not start with the script block character '{'

Definition at line 272 of file parse.cpp.

References Com_Parse(), and Com_SkipBlock().

Referenced by ParseUMP(), SV_ParseUMP(), and TEST_F().

const char* Com_GetToken ( const char **  data_p)

Get the current token value.

Returns
The current token value

Definition at line 51 of file parse.cpp.

References com_token.

Referenced by Com_ParseList().

Com_TokenType_t Com_GetType ( const char **  data_p)

Get the current token type.

Returns
The current token type

Definition at line 60 of file parse.cpp.

References type.

Referenced by TEST_F(), UI_ParseNode(), UI_ParseProperty(), UI_ParseValueExpression(), and UI_ParseWindow().

Com_TokenType_t Com_NextToken ( const char **  data_p)

Compute the next token.

Returns
Type of the next token

Definition at line 69 of file parse.cpp.

References Com_Parse(), and type.

Referenced by Com_ParseList().

const char* Com_Parse ( const char **  data_p,
char *  target = nullptr,
size_t  size = 0,
bool  replaceWhitespaces = true 
)
void Com_SkipBlock ( const char **  text)

Skips a block of {} in our script files.

Parameters
[in,out]textThe text pointer to skip the block in. This pointer is set to the end of the block
Note
Even multiple depth levels are supported. Skipping a block with nested blocks works, too.

Definition at line 253 of file parse.cpp.

References Com_Parse().

Referenced by AIR_ParseAircraft(), CL_ParseMessageID(), Com_GetBlock(), Com_ParseGameTypes(), Com_ParseItemEffect(), Com_ParseTeam(), FS_NextScriptHeader(), and SV_ParseUMP().

void Com_UnParseLastToken ( void  )

Put back the last token into the parser The next call of Com_Parse will return the same token again.

Note
Only allow to use it one time
With it, we can't read to file at the same time

Definition at line 42 of file parse.cpp.

References isUnparsedToken.

Referenced by CL_ParseSequence(), Com_ParseBlockToken(), TEST_F(), UI_ParseCallAction(), UI_ParseExpression(), and UI_ParseSetAction().