mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
** Big Maps Projects code (incl. Multiplayer v1.5 ** ********************************************************** - Merged Big Maps Project code from BMP+MP trunk (Revision: 3340) o Complete SVN Revision history: https://81.169.133.124/source/ja2/branches/Wanne/JA2%201.13%20MP - Before THIS merge, I made a branch of the existing 1.13 source o SVN Branch: https://81.169.133.124/source/ja2/branches/JA2_rev.3336/src - Removed old VS 6.0 and VS 2003 project and solutions files, because compilation is broken long time ago - I will add VS 2010 projects and solution file in the next few days git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@3341 3b4a5df2-a311-0410-b5c6-a8a6f20db521
131 lines
3.0 KiB
C++
131 lines
3.0 KiB
C++
#ifndef _PARSER_TOOLS_H_
|
|
#define _PARSER_TOOLS_H_
|
|
|
|
#include "../vfs_types.h"
|
|
#include "../Interface/vfs_file_interface.h"
|
|
|
|
#include <list>
|
|
|
|
/**************************************************************/
|
|
/**************************************************************/
|
|
const vfs::size_t BUFFER_SIZE = 1024;
|
|
|
|
class CReadLine
|
|
{
|
|
public:
|
|
CReadLine(vfs::tReadableFile& rFile);
|
|
~CReadLine();
|
|
|
|
bool fillBuffer();
|
|
bool fromBuffer(std::string& line);
|
|
bool getLine(std::string& line);
|
|
private:
|
|
vfs::Byte _buffer[BUFFER_SIZE+1];
|
|
vfs::tReadableFile& _file;
|
|
vfs::size_t _bytes_left;
|
|
vfs::size_t _buffer_pos;
|
|
vfs::size_t _buffer_last;
|
|
bool _eof;
|
|
|
|
void operator=(CReadLine const& rl);
|
|
};
|
|
|
|
/**************************************************************/
|
|
/**************************************************************/
|
|
|
|
class CSplitStringList
|
|
{
|
|
public:
|
|
CSplitStringList(utf8string const& sList);
|
|
~CSplitStringList();
|
|
|
|
bool nextListEntry(utf8string &sEntry);
|
|
private:
|
|
const utf8string m_list;
|
|
utf8string::size_t current,next;
|
|
|
|
void operator=(CSplitStringList const& strlist);
|
|
};
|
|
|
|
|
|
/**************************************************************/
|
|
/**************************************************************/
|
|
|
|
class CTransferRules
|
|
{
|
|
public:
|
|
enum EAction
|
|
{
|
|
DENY,
|
|
ACCEPT,
|
|
};
|
|
public:
|
|
CTransferRules();
|
|
|
|
bool initFromTxtFile(vfs::Path const& sPath);
|
|
bool initFromTxtFile(vfs::tReadableFile* pFile);
|
|
|
|
void setDefaultAction(EAction act);
|
|
EAction getDefaultAction();
|
|
|
|
EAction applyRule(utf8string const& sStr);
|
|
private:
|
|
struct SRule
|
|
{
|
|
EAction action;
|
|
vfs::Path pattern;
|
|
};
|
|
typedef std::list<SRule> tPatternList;
|
|
tPatternList m_listRules;
|
|
EAction m_eDefaultAction;
|
|
};
|
|
|
|
/**************************************************************/
|
|
/**************************************************************/
|
|
|
|
//#define USE_CODE_PAGE
|
|
|
|
#ifdef USE_CODE_PAGE
|
|
class CodePageReader
|
|
{
|
|
public:
|
|
enum EMode
|
|
{
|
|
Error, Normal, Shift, Ctrl, Alt
|
|
};
|
|
void ReadCodePage(vfs::Path const& codepagefile);
|
|
private:
|
|
CodePageReader::EMode ExtractMode(std::string const &readStr, size_t startPos);
|
|
bool ExtractCode(std::string const& str, int iStart, vfs::UInt32& rInsertPoint, utf8string::str_t& u8s);
|
|
};
|
|
|
|
namespace charSet
|
|
{
|
|
enum ECharSet
|
|
{
|
|
CS_SPACE = 1,
|
|
CS_ALPHA_LC = 2,
|
|
CS_ALPHA_UC = 4,
|
|
CS_ALPHA = CS_ALPHA_LC + CS_ALPHA_UC,
|
|
CS_NUMERIC = 8,
|
|
CS_ALPHA_NUM = CS_ALPHA + CS_NUMERIC,
|
|
CS_SPECIAL_ALPHA_LC = 16,
|
|
CS_SPECIAL_ALPHA_UC = 32,
|
|
CS_SPECIAL_ALPHA = CS_SPECIAL_ALPHA_LC + CS_SPECIAL_ALPHA_UC,
|
|
CS_SPECIAL_NON_CHAR = 65,
|
|
};
|
|
|
|
bool IsFromSet(char wc, unsigned int char_set);
|
|
bool IsFromSet(int wc, unsigned int char_set);
|
|
bool IsFromSet(unsigned int wc, unsigned int char_set);
|
|
bool IsFromSet(wchar_t wc, unsigned int char_set);
|
|
|
|
void AddToCharSet(ECharSet eset, std::wstring cset);
|
|
|
|
void InitializeCharSets();
|
|
};
|
|
#endif // USE_CODE_PAGE
|
|
|
|
#endif // _PARSER_TOOLS_H_
|
|
|