1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
/*
* .þÛÛþ þ þ þÛÛþ. þ þ þÛÛÛþ. þÛÛÛþ .þÛÛþ. þ þ
* .þ Û Ûþ. Û Û þ. Û Û Û þ Û. Û. Û Ûþ. Û
* Û Û Û Û Û Û Û Û þ. Û. Û Û Û Û Û Û Û
* .þþÛÛÛÛþ Û Û Û þÛÛÛÛþþ. þþÛÛ. þþÛÛþ. þÛ Û Û Û Û Û
* .Û Û Û .þÛ Û Û. Û Û Û Û Û. þ. Û Û .þÛ
* þ. þ þ þ þ .þ þ .þ þ .þ þÛÛÛþ .þÛÛþ. þ þ
*
* Berusky (C) AnakreoN
* Martin Stransky <stransky@anakreon.cz>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __DATA_PARSER_H__
#define __DATA_PARSER_H__
#include <stdio.h>
#include <ctype.h>
#define MAX_POS_NAME 50
typedef struct position_table_item {
char name[MAX_POS_NAME];
int position;
} POSITION_TABLE_ITEM;
typedef struct data_record {
int base;
int offset;
int num;
} DATA_RECORD;
typedef class data_parser {
// ***********************************************************************
// Main data
// ***********************************************************************
POSITION_TABLE_ITEM *p_table;
int table_items;
#define MAX_RECORD_LEN 2000
char record[MAX_RECORD_LEN];
FHANDLE datafile;
// ***********************************************************************
// Helper functions
// ***********************************************************************
#ifdef WINDOWS
bool isblank(char c)
{
return(c == ' ' || c == 0x9);
}
#endif
char * token_get_next(char *p_line)
{
while(*p_line && isblank(*p_line))
p_line++;
return(p_line);
}
char * token_get_next_end(char *p_line)
{
while(*p_line && !isblank(*p_line) && *p_line != '+' && *p_line != '|' &&
*p_line != '\n' && *p_line != '\r')
p_line++;
return(p_line);
}
char * token_translate(char *p_token, int *p_sum, int *p_base);
int record_load(void);
public:
data_parser(POSITION_TABLE_ITEM *p_pos_table, int pos_table_items) :
p_table(p_pos_table), table_items(pos_table_items) {};
~data_parser(void);
int open(const char *p_file, const char *p_dir);
void close(void);
int get_max_index(void);
void get_indexes(int *p_indexes, int index_num);
int records_get(DATA_RECORD *p_records, int record_num);
} DATA_PARSER;
#endif // __DATA_PARSER_H__
|