1 /**
2  * @file
3  * @brief Shared parsing functions.
4  */
5 
6 /*
7 All original material Copyright (C) 2002-2013 UFO: Alien Invasion.
8 
9 Copyright (C) 1997-2001 Id Software, Inc.
10 
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License
13 as published by the Free Software Foundation; either version 2
14 of the License, or (at your option) any later version.
15 
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 
20 See the GNU General Public License for more details.
21 
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 
26 */
27 
28 #pragma once
29 
30 #include "ufotypes.h"
31 #include "cxx.h"
32 
33 enum Com_TokenType_t {
34 	TT_EOF = 0,
35 	TT_BEGIN_BLOCK = '{',
36 	TT_END_BLOCK = '}',
37 	TT_COMMA = ',',
38 	TT_BEGIN_LIST = '(',
39 	TT_END_LIST = ')',
40 
41 	TT_CONTENT = 0xFF,
42 	TT_WORD,
43 	TT_QUOTED_WORD
44 };
45 
46 const char* Com_GetToken(const char** data_p);
47 Com_TokenType_t Com_GetType(const char** data_p);
48 Com_TokenType_t Com_NextToken(const char** data_p);
49 
50 const char* Com_Parse(const char** data_p, char* target = nullptr, size_t size = 0, bool replaceWhitespaces = true);
51 int Com_CountTokensInBuffer(const char* buffer);
52 void Com_UnParseLastToken(void);
53 void Com_SkipBlock(const char** text);
54 int Com_GetBlock(const char** text, const char** start);
55