forked from UnitexGramLab/unitex-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuffer.h
73 lines (62 loc) · 2.03 KB
/
Buffer.h
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
/*
* Unitex
*
* Copyright (C) 2001-2017 Université Paris-Est Marne-la-Vallée <unitex@univ-mlv.fr>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*
*/
#ifndef BufferH
#define BufferH
#include "Unicode.h"
#ifndef HAS_UNITEX_NAMESPACE
#define HAS_UNITEX_NAMESPACE 1
#endif
namespace unitex {
/**
* This enumeration describes the possible kind of buffers.
*/
enum buffer_type_ {
INTEGER_BUFFER,
UNICHAR_BUFFER
};
typedef enum buffer_type_ BufferType;
/**
* This structure represents a buffer of integer or unichar, with its maximum capacity and
* its actual size. The 'end_of_file' field is set to 1 when no data can be
* read from the input file.
*/
struct buffer {
BufferType type;
int MAXIMUM_BUFFER_SIZE;
union {
int* int_buffer;
unichar* unichar_buffer;
};
int size;
int end_of_file;
};
struct buffer* new_buffer(int,BufferType);
struct buffer* new_buffer_for_file(BufferType,U_FILE*,int capacity_limit);
void free_buffer(struct buffer*);
int fill_buffer(struct buffer*,int,U_FILE*);
int fill_buffer(struct buffer*,int,int,U_FILE*);
int fill_buffer(struct buffer*,U_FILE*);
int fill_buffer_raw(struct buffer*, int, U_FILE*);
int fill_buffer_raw(struct buffer*, U_FILE*);
int fill_buffer_keepCR_option(struct buffer*,int,U_FILE*);
int fill_buffer_keepCR_option(struct buffer*,int,int,U_FILE*);
} // namespace unitex
#endif