4 * Copyright (c) 2013-2014 project bchan
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.
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:
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.
19 * 2. Altered source versions must be plainly marked as such, and must not be
20 * misrepresented as being the original software.
22 * 3. This notice may not be removed or altered from any source
28 /* Functionality name: tadfragment */
35 #include <coll/bytearray.h>
36 #include <coll/wordarray.h>
37 #include "tadlangcode.h"
39 #ifndef __TADFRAGMENT_H__
40 #define __TADFRAGMENT_H__
42 /* Functionality name: tadfragment */
44 struct tadfragment_t_ {
48 typedef struct tadfragment_t_ tadfragment_t;
50 /* Functionality name: tadfragment */
51 /* Detail name: cursor */
52 struct tadfragment_cursor_t_ {
53 tadfragment_t *target;
54 wordarray_cursor_t base;
56 typedef struct tadfragment_cursor_t_ tadfragment_cursor_t;
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,
70 typedef struct tadfragment_cursor_segment_ tadfragment_cursor_segment;
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);
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);