OSDN Git Service

749d22d8f569fb598fe015461cf8b75c8c1dc551
[bbk/bchanf.git] / src / coll / bytearray.h
1 /*
2  * bytearray.h
3  *
4  * Copyright (c) 2013 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: bytearray */
29 /* Detail name: */
30
31 #include        <basic.h>
32
33 #ifndef __BYTEARRAY_H__
34 #define __BYTEARRAY_H__
35
36 /* Functionality name: bytearray */
37 /* Detail name: */
38 struct bytearray_t_ {
39         UB *ptr;
40         W len;
41 };
42 typedef struct bytearray_t_ bytearray_t;
43
44 /* Functionality name: bytearray */
45 /* Detail name: cursor */
46 struct bytearray_cursor_t_ {
47         bytearray_t *target;
48         W index;
49 };
50 typedef struct bytearray_cursor_t_ bytearray_cursor_t;
51
52 IMPORT W bytearray_initialize(bytearray_t *bytearray);
53 IMPORT VOID bytearray_finalize(bytearray_t *bytearray);
54 IMPORT UB* bytearray_getbuffer(bytearray_t *bytearray);
55 IMPORT W bytearray_getlength(bytearray_t *bytearray);
56 IMPORT W bytearray_pushback(bytearray_t *bytearray, UB val);
57 IMPORT W bytearray_popback(bytearray_t *bytearray);
58
59 IMPORT VOID bytearray_cursor_initialize(bytearray_cursor_t *cursor, bytearray_t *bytearray);
60 IMPORT VOID bytearray_cursor_finalize(bytearray_cursor_t *cursor);
61 IMPORT W bytearray_cursor_move(bytearray_cursor_t *cursor, W diff);
62 IMPORT W bytearray_cursor_erase(bytearray_cursor_t *cursor, W len);
63 IMPORT W bytearray_cursor_insert(bytearray_cursor_t *cursor, UB *data, W len);
64 IMPORT Bool bytearray_cursor_isend(bytearray_cursor_t *cursor);
65 IMPORT W bytearray_cursor_getB(bytearray_cursor_t *cursor, B *p);
66 IMPORT W bytearray_cursor_getH(bytearray_cursor_t *cursor, H *p);
67 IMPORT W bytearray_cursor_getW(bytearray_cursor_t *cursor, W *p);
68 IMPORT W bytearray_cursor_getUB(bytearray_cursor_t *cursor, UB *p);
69 IMPORT W bytearray_cursor_getUH(bytearray_cursor_t *cursor, UH *p);
70 IMPORT W bytearray_cursor_getUW(bytearray_cursor_t *cursor, UW *p);
71
72 #endif