| 1 |
/* |
| 2 |
* lineparse.h |
| 3 |
* |
| 4 |
* This file is a part of NSIS. |
| 5 |
* |
| 6 |
* Copyright (C) 1999-2026 Nullsoft and Contributors |
| 7 |
* |
| 8 |
* Licensed under the zlib/libpng license (the "License"); |
| 9 |
* you may not use this file except in compliance with the License. |
| 10 |
* |
| 11 |
* Licence details can be found in the file COPYING. |
| 12 |
* |
| 13 |
* This software is provided 'as-is', without any express or implied |
| 14 |
* warranty. |
| 15 |
* |
| 16 |
* Unicode support by Jim Park -- 08/09/2007 |
| 17 |
*/ |
| 18 |
|
| 19 |
#ifndef _LINEPARSE_H_ |
| 20 |
#define _LINEPARSE_H_ |
| 21 |
|
| 22 |
#include "tchar.h" |
| 23 |
#include "utf.h" |
| 24 |
|
| 25 |
class LineParser { |
| 26 |
public: |
| 27 |
|
| 28 |
LineParser(bool bCommentBlock); |
| 29 |
virtual ~LineParser(); |
| 30 |
|
| 31 |
bool inComment(); |
| 32 |
bool inCommentBlock(); |
| 33 |
int parse(const TCHAR *line, int ignore_escaping=0, NStreamEncoding*pEncChange=NULL); // returns -1 on error |
| 34 |
int getnumtokens(); |
| 35 |
void eattoken(); |
| 36 |
int gettoken_int(int token, int *success=0) const; |
| 37 |
int gettoken_intx(int token, int *success=0) const; // basic operator expressions parser |
| 38 |
double gettoken_float(int token, int *success=0) const; |
| 39 |
double gettoken_number(int token, int *success=0) const; |
| 40 |
int gettoken_binstrdata(int token, char*buffer, int bufcap) const; |
| 41 |
TCHAR *gettoken_str(int token) const; |
| 42 |
int gettoken_enum(int token, const TCHAR *strlist); // null separated list |
| 43 |
|
| 44 |
static int parse_int(const TCHAR *str, int *success=0); |
| 45 |
static int parse_intx(const TCHAR *str, int *success=0); |
| 46 |
static double parse_float(const TCHAR *str, int *success=0); |
| 47 |
static double parse_number(const TCHAR *str, int *success=0); |
| 48 |
|
| 49 |
private: |
| 50 |
|
| 51 |
void freetokens(); |
| 52 |
int doline(const TCHAR *line, int ignore_escaping=0, NStreamEncoding*pEncChange=NULL); |
| 53 |
inline int validate_token_index(int token, int *success=0) const; |
| 54 |
|
| 55 |
int m_eat; |
| 56 |
int m_nt; |
| 57 |
bool m_incommentblock; |
| 58 |
bool m_incomment; |
| 59 |
TCHAR **m_tokens; |
| 60 |
}; |
| 61 |
#endif//_LINEPARSE_H_ |