OSDN Git Service

implement tadfragment_truncate and tadfragment_cursor_insertlang.
[bbk/bchanf.git] / src / tad / tadfragment.h
1 /*
2  * tadfragment.h
3  *
4  * Copyright (c) 2013-2014 project bchan
5  *
6  * This software is provided 'as-is', without any express or implied
7  * warranty. In no event will the authors be held liable for any damages
8  * arising from the use of this software.
9  *
10  * Permission is granted to anyone to use this software for any purpose,
11  * including commercial applications, and to alter it and redistribute it
12  * freely, subject to the following restrictions:
13  *
14  * 1. The origin of this software must not be misrepresented; you must not
15  *    claim that you wrote the original software. If you use this software
16  *    in a product, an acknowledgment in the product documentation would be
17  *    appreciated but is not required.
18  *
19  * 2. Altered source versions must be plainly marked as such, and must not be
20  *    misrepresented as being the original software.
21  *
22  * 3. This notice may not be removed or altered from any source
23  *    distribution.
24  *
25  */
26
27 /* Vendor name: */
28 /* Functionality name: tadfragment */
29 /* Detail name: */
30
31 #include    <basic.h>
32 #include        <btron/dp.h>
33 #include    <tad.h>
34
35 #include    <coll/bytearray.h>
36 #include    <coll/wordarray.h>
37 #include    "tadlangcode.h"
38
39 #ifndef __TADFRAGMENT_H__
40 #define __TADFRAGMENT_H__
41
42 /* Functionality name: tadfragment */
43 /* Detail name: */
44 struct tadfragment_t_ {
45         bytearray_t rawdata;
46         wordarray_t pos;
47 };
48 typedef struct tadfragment_t_ tadfragment_t;
49
50 /* Functionality name: tadfragment */
51 /* Detail name: cursor */
52 struct tadfragment_cursor_t_ {
53         tadfragment_t *target;
54         wordarray_cursor_t base;
55 };
56 typedef struct tadfragment_cursor_t_ tadfragment_cursor_t;
57
58 /* Functionality name: tadfragment */
59 /* Detail name: cursor */
60 /* Data structure identifier: segment */
61 struct tadfragment_cursor_segment_ {
62         enum TADFRAGMENT_CURSOR_SEGMENTTYPE {
63                 TADFRAGMENT_CURSOR_SEGMENTTYPE_VARIABLE,
64                 TADFRAGMENT_CURSOR_SEGMENTTYPE_CHAR,
65                 TADFRAGMENT_CURSOR_SEGMENTTYPE_LANGCODE,
66         } type;
67         UB *p;
68         W len;
69 };
70 typedef struct tadfragment_cursor_segment_ tadfragment_cursor_segment;
71
72 IMPORT W tadfragment_initialize(tadfragment_t *fragment);
73 IMPORT VOID tadfragment_finalize(tadfragment_t *fragment);
74 IMPORT UB* tadfragment_getbuffer(tadfragment_t *fragment);
75 IMPORT W tadfragment_getsegmentlength(tadfragment_t *fragment);
76 IMPORT W tadfragment_getbufferlength(tadfragment_t *fragment);
77 IMPORT W tadfragment_pushback(tadfragment_t *fragment, UB *data, W len);
78 IMPORT W tadfragment_popback(tadfragment_t *fragment);
79 IMPORT VOID tadfragment_truncate(tadfragment_t *fragment, W size);
80
81 IMPORT VOID tadfragment_cursor_initialize(tadfragment_cursor_t *cursor, tadfragment_t *fragment);
82 IMPORT VOID tadfragment_cursor_finalize(tadfragment_cursor_t *cursor);
83 IMPORT W tadfragment_cursor_move(tadfragment_cursor_t *cursor, W diff);
84 IMPORT W tadfragment_cursor_erase(tadfragment_cursor_t *cursor, W len);
85 IMPORT W tadfragment_cursor_insert(tadfragment_cursor_t *cursor, UB *data, W len);
86 IMPORT W tadfragment_cursor_insertlang(tadfragment_cursor_t *cursor, tadlangcode *lang);
87 IMPORT Bool tadfragment_cursor_isend(tadfragment_cursor_t *cursor);
88 IMPORT W tadfragment_cursor_getdata(tadfragment_cursor_t *cursor, tadfragment_cursor_segment *p);
89
90 #endif