Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libjni-mrsid / include / c_api / lt_ioCStream.h @ 3539

History | View | Annotate | Download (5.47 KB)

1
/* $Id: lt_ioCStream.h 3539 2006-01-09 12:23:20Z nacho $ */
2
/* //////////////////////////////////////////////////////////////////////////
3
//                                                                         //
4
// This code is Copyright (c) 2004 LizardTech, Inc, 1008 Western Avenue,   //
5
// Suite 200, Seattle, WA 98104.  Unauthorized use or distribution         //
6
// prohibited.  Access to and use of this code is permitted only under     //
7
// license from LizardTech, Inc.  Portions of the code are protected by    //
8
// US and foreign patents and other filings. All Rights Reserved.          //
9
//                                                                         //
10
////////////////////////////////////////////////////////////////////////// */
11
/* PUBLIC - C */
12

    
13
#ifndef LT_IO_C_STREAM_H
14
#define LT_IO_C_STREAM_H
15

    
16
#include "lt_base.h"
17
#include "lt_lib_io.h"
18
#include "lt_ioCallbackStreamTypes.h"
19

    
20
#if defined(LT_COMPILER_MS)
21
        #pragma warning(push,4)
22
#endif
23

    
24
#ifdef LT_CPLUSPLUS
25
extern "C" {
26
#endif
27

    
28
/**
29
 * @name C functions for operating on streams
30
 *
31
 * These functions are C-callable analogues to the member
32
 * functions in the LTIOStreamInf class.
33
 */
34
/*@{*/
35

    
36
/**
37
 * destructor for C stream
38
 *
39
 * This function must be called once the stream is no longer needed
40
 * to free up the stream's allocated resources, i.e. it calls the
41
 * destructor of the underlying LTIOCallbackStream.
42
 *
43
 * @param  stream  stream to be freed
44
 * @return success/failure code
45
 */
46
LT_STATUS lt_ioCStreamDestroy(LTIOStreamH stream);
47

    
48

    
49
/**
50
 * open C stream
51
 *
52
 * Opens a previously-created C stream.
53
 *
54
 * This function is equivalent to LTIOStreamInf::open().
55
 *
56
 * @param  stream  stream to be opened
57
 * @return success/failure code
58
 */
59
LT_STATUS lt_ioCStreamOpen(LTIOStreamH stream);
60

    
61

    
62
/**
63
 * close C stream
64
 *
65
 * Closes a C stream.  Note that lt_ioCStreamDestroy() must be
66
 * called once the stream is no longer needed.
67
 *
68
 * This function is equivalent to LTIOStreamInf::close().
69
 *
70
 * @param  stream  stream to be closed
71
 * @return success/failure code
72
 */
73
LT_STATUS lt_ioCStreamClose(LTIOStreamH stream);
74

    
75

    
76
/**
77
 * read C stream
78
 *
79
 * Read from a C stream.
80
 *
81
 * This function is equivalent to LTIOStreamInf::read().
82
 *
83
 * @param  stream  stream to read from
84
 * @param  buf     buffer to read into
85
 * @param  len     number of bytes to read
86
 * @return number of bytes read
87
 */
88
lt_uint32 lt_ioCStreamRead(LTIOStreamH stream, lt_uint8* buf, lt_uint32 len);
89

    
90

    
91
/**
92
 * write C stream
93
 *
94
 * Write to a C stream.
95
 *
96
 * This function is equivalent to LTIOStreamInf::write().
97
 *
98
 * @param  stream  stream to be written to
99
 * @param  buf     buffer to write from
100
 * @param  len     number of bytes to write
101
 * @return number of bytes written
102
 */
103
lt_uint32 lt_ioCStreamWrite(LTIOStreamH stream, const lt_uint8* buf, lt_uint32 len);
104

    
105

    
106
/**
107
 * seek for C stream
108
 *
109
 * Seek on a C stream.
110
 *
111
 * This function is equivalent to LTIOStreamInf::seek().
112
 *
113
 * @param  stream  stream to be seek on
114
 * @param  offset  distance to seek
115
 * @param  dir     seek direction
116
 * @return success/failure code
117
 */
118
LT_STATUS lt_ioCStreamSeek(LTIOStreamH stream, lt_int64 offset, LTIOSeekDir dir);
119

    
120

    
121
/**
122
 * tell for C stream
123
 *
124
 * Tell on a C stream.
125
 *
126
 * This function is equivalent to LTIOStreamInf::tell().
127
 *
128
 * @param  stream  stream to get offset of
129
 * @return stream's current offset
130
 */
131
lt_int64 lt_ioCStreamTell(LTIOStreamH stream);
132

    
133

    
134
/**
135
 * is end-of-file? for C stream
136
 *
137
 * Check for EOF on a C stream.
138
 *
139
 * This function is equivalent to LTIOStreamInf::isEOF().
140
 *
141
 * @param  stream  stream to query
142
 * @return true (1), iff the stream is at EOF
143
 */
144
lt_uint8 lt_ioCStreamIsEOF(LTIOStreamH stream);
145

    
146

    
147
/**
148
 * is open? for C stream
149
 *
150
 * Check for open on a C stream.
151
 *
152
 * This function is equivalent to LTIOStreamInf::isOpen().
153
 *
154
 * @param  stream  stream to query
155
 * @return true (1) iff the stream is open
156
 */
157
lt_uint8 lt_ioCStreamIsOpen(LTIOStreamH stream);
158

    
159

    
160
/**
161
 * duplicate C stream
162
 *
163
 * Duplicate a C stream.
164
 *
165
 * This function is equivalent to LTIOStreamInf::duplicate().
166
 *
167
 * @param  stream  stream to duplicate
168
 * @return the new stream (or NULL if cannot duplicate)
169
 */
170
LTIOStreamH lt_ioCStreamDuplicate(LTIOStreamH stream);
171

    
172

    
173
/**
174
 * create callback stream
175
 *
176
 * Create an LTIOCallbackStream, via C API.  The parameters correspond
177
 * to those used in LTIOCallbackStream::initialize().
178
 *
179
 * @param  open       user's open function
180
 * @param  close      user's close function
181
 * @param  read       user's read function
182
 * @param  write      user's write function
183
 * @param  seek       user's seek function
184
 * @param  tell       user's tell function
185
 * @param  isEOF      user's isEOF function
186
 * @param  isOpen     user's isOpen function
187
 * @param  duplicate  user's duplicate function
188
 * @param  userData   user's stream data
189
 * @return the created stream
190
 */
191
LTIOStreamH lt_ioCallbackStreamCreate(LTIOCallbackStream_Open open,
192
                                      LTIOCallbackStream_Close close,
193
                                      LTIOCallbackStream_Read read,
194
                                      LTIOCallbackStream_Write write,
195
                                      LTIOCallbackStream_Seek seek,
196
                                      LTIOCallbackStream_Tell tell,
197
                                      LTIOCallbackStream_IsEOF isEOF,
198
                                      LTIOCallbackStream_IsOpen isOpen,
199
                                      LTIOCallbackStream_Duplicate duplicate,
200
                                      void* userData);
201

    
202
/*@}*/
203

    
204
#ifdef LT_CPLUSPLUS
205
}
206
#endif
207

    
208
#if defined(LT_COMPILER_MS)
209
        #pragma warning(pop)
210
#endif
211

    
212
#endif