added ticket parser: plugins/ticket/ticketparser.h plugins/ticket/ticketparser.cpp

git-svn-id: svn://ttmath.org/publicrep/winix/trunk@663 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-10-11 20:42:49 +00:00
parent 07511a2eb0
commit 33057acd62
23 changed files with 777 additions and 86 deletions

56
plugins/ticket/ticketparser.h Executable file
View File

@@ -0,0 +1,56 @@
#ifndef headerfile_winix_plugins_ticket_ticketparser
#define headerfile_winix_plugins_ticket_ticketparser
#include "ticketconf.h"
#define WINIX_TICKET_ERR_OK 0
#define WINIX_TICKET_ERR_UKNOWN_TYPE 1
#define WINIX_TICKET_ERR_NO_ITEM_NAME 2
#define WINIX_TICKET_ERR_SYNTAX_ERROR 3
class TicketParser
{
public:
int Parse(const char * str, TicketConf & conf);
int Parse(const std::string & str, TicketConf & conf);
private:
TicketConf * pconf;
const char * pchar;
int error; // last error code
TicketConf::TicketItem item;
std::string type;
std::string id_str;
std::string int_min, int_max;
TicketConf::TicketItem::Select select;
bool IsWhite(int c);
void SkipWhite();
void SkipWhiteLines();
void SkipLine();
void ReadTextQuoted(std::string & text);
void ReadTextSimple(std::string & text, bool comma_separator);
void ReadText(std::string & text, bool comma_separator = false);
void CheckId(int & id, bool & def);
void SetItemId();
bool CheckEndLine();
bool ReadItemType();
bool ReadItemName();
void ReadItemInteger();
void ReadItemSelect();
bool ReadItem();
void LogItemInteger(TicketConf::TicketItem & item);
void LogItemSelect(TicketConf::TicketItem & item);
void LogItem(TicketConf::TicketItem & item);
};
#endif