blob: a9276396cf51155d5b73ecbdc6a68b806c1742b3 [file] [log] [blame]
Cary Clarkd2ca79c2018-08-10 13:09:13 -04001#Topic Stream
2#Alias Stream_Reference ##
3
4#Class SkStream
5
Cary Clark61313f32018-10-08 14:57:48 -04006#Code
7#Populate
8##
9
Cary Clarkd2ca79c2018-08-10 13:09:13 -040010SkStream describes an abstract class that provides readable serial access to
11data. Subclass SkFILEStream stores readable data in a file. Subclass
12SkMemoryStream stores readable data in memory.
13
14SkStream data is immutable; data access is synchronous. Reading Stream data
15returns only as many bytes as were available when Stream was created. Unlike
16traditional streams, additional data will not become available at a later time
17or on a subsequent read request.
18
Cary Clarkd2ca79c2018-08-10 13:09:13 -040019# ------------------------------------------------------------------------------
20
21#Method virtual ~SkStream()
Cary Clark61313f32018-10-08 14:57:48 -040022#In Constructors
Cary Clarkd2ca79c2018-08-10 13:09:13 -040023#Line # incomplete ##
24
25#Example
26// incomplete
27##
28
29#SeeAlso incomplete
30
31#Method ##
32
33# ------------------------------------------------------------------------------
34
35#Method SkStream()
Cary Clark61313f32018-10-08 14:57:48 -040036#In Constructors
Cary Clarkd2ca79c2018-08-10 13:09:13 -040037#Line # incomplete ##
38
39#Return incomplete ##
40
41#Example
42// incomplete
43##
44
45#SeeAlso incomplete
46
47#Method ##
48
49# ------------------------------------------------------------------------------
50
51#Method static std::unique_ptr<SkStreamAsset> MakeFromFile(const char path[])
52#In incomplete
53#Line # incomplete ##
54
55Attempts to open the specified file as a stream, returns nullptr on failure.
56
57#Param path incomplete ##
58
59#Return incomplete ##
60
61#Example
62// incomplete
63##
64
65#SeeAlso incomplete
66
67#Method ##
68
69# ------------------------------------------------------------------------------
70
71#Method virtual size_t read(void* buffer, size_t size) = 0
72#In incomplete
73#Line # incomplete ##
74
75Reads or skips size number of bytes.
76If buffer is nullptr, skip size bytes, return how many were skipped.
77If buffer is not nullptr, copy size bytes into buffer, return how many were copied.
78
79#Param buffer when nullptr skip size bytes, otherwise copy size bytes into buffer
80##
81#Param size the number of bytes to skip or copy
82##
83
84#Return the number of bytes actually read.
85##
86
87#Example
88// incomplete
89##
90
91#SeeAlso incomplete
92
93#Method ##
94
95# ------------------------------------------------------------------------------
96
97#Method size_t skip(size_t size)
98#In incomplete
99#Line # incomplete ##
100
101Skip size number of bytes. #Param size incomplete ##
102
103#Return the actual number bytes that could be skipped
104##
105
106#Example
107// incomplete
108##
109
110#SeeAlso incomplete
111
112#Method ##
113
114# ------------------------------------------------------------------------------
115
116#Method virtual size_t peek(void* buffer, size_t size) const
117#In incomplete
118#Line # incomplete ##
119
120Attempt to peek at size bytes.
121If this stream supports peeking, copy min(size, peekable bytes) into
122buffer, and return the number of bytes copied.
123If the stream does not support peeking, or cannot peek any bytes,
124return 0 and leave buffer unchanged.
125The stream is guaranteed to be in the same visible state after this
126call, regardless of success or failure.
127
128#Param buffer must not be nullptr, and must be at least size bytes. Destination
129 to copy bytes
130##
131#Param size number of bytes to copy
132##
133
134#Return number of bytes peeked/copied.
135##
136
137#Example
138// incomplete
139##
140
141#SeeAlso incomplete
142
143#Method ##
144
145# ------------------------------------------------------------------------------
146
147#Method virtual bool isAtEnd() const = 0
148#In incomplete
149#Line # incomplete ##
150
151Returns true when all the bytes in the stream have been read.
152This may return true early (when there are no more bytes to be read)
153or late (after the first unsuccessful read).
154
155#Return incomplete ##
156
157#Example
158// incomplete
159##
160
161#SeeAlso incomplete
162
163#Method ##
164
165# ------------------------------------------------------------------------------
166
Cary Clark61313f32018-10-08 14:57:48 -0400167#Method bool readS8(int8_t* i)
Cary Clarkd2ca79c2018-08-10 13:09:13 -0400168#In incomplete
169#Line # incomplete ##
170
171#Param i incomplete ##
172
173#Return incomplete ##
174
175#Example
176// incomplete
177##
178
179#SeeAlso incomplete
180
181#Method ##
182
183# ------------------------------------------------------------------------------
184
Cary Clark61313f32018-10-08 14:57:48 -0400185#Method bool readS16(int16_t* i)
Cary Clarkd2ca79c2018-08-10 13:09:13 -0400186#In incomplete
187#Line # incomplete ##
188
189#Param i incomplete ##
190
191#Return incomplete ##
192
193#Example
194// incomplete
195##
196
197#SeeAlso incomplete
198
199#Method ##
200
201# ------------------------------------------------------------------------------
202
Cary Clark61313f32018-10-08 14:57:48 -0400203#Method bool readS32(int32_t* i)
Cary Clarkd2ca79c2018-08-10 13:09:13 -0400204#In incomplete
205#Line # incomplete ##
206
207#Param i incomplete ##
208
209#Return incomplete ##
210
211#Example
212// incomplete
213##
214
215#SeeAlso incomplete
216
217#Method ##
218
219# ------------------------------------------------------------------------------
220
Cary Clark61313f32018-10-08 14:57:48 -0400221#Method bool readU8(uint8_t* i)
Cary Clarkd2ca79c2018-08-10 13:09:13 -0400222#In incomplete
223#Line # incomplete ##
224
225#Param i incomplete ##
226
227#Return incomplete ##
228
229#Example
230// incomplete
231##
232
233#SeeAlso incomplete
234
235#Method ##
236
237# ------------------------------------------------------------------------------
238
Cary Clark61313f32018-10-08 14:57:48 -0400239#Method bool readU16(uint16_t* i)
Cary Clarkd2ca79c2018-08-10 13:09:13 -0400240#In incomplete
241#Line # incomplete ##
242
243#Param i incomplete ##
244
245#Return incomplete ##
246
247#Example
248// incomplete
249##
250
251#SeeAlso incomplete
252
253#Method ##
254
255# ------------------------------------------------------------------------------
256
Cary Clark61313f32018-10-08 14:57:48 -0400257#Method bool readU32(uint32_t* i)
Cary Clarkd2ca79c2018-08-10 13:09:13 -0400258#In incomplete
259#Line # incomplete ##
260
261#Param i incomplete ##
262
263#Return incomplete ##
264
265#Example
266// incomplete
267##
268
269#SeeAlso incomplete
270
271#Method ##
272
273# ------------------------------------------------------------------------------
274
Cary Clark61313f32018-10-08 14:57:48 -0400275#Method bool readBool(bool* b)
Cary Clarkd2ca79c2018-08-10 13:09:13 -0400276#In incomplete
277#Line # incomplete ##
278
279#Param b incomplete ##
280
281#Return incomplete ##
282
283#Example
284// incomplete
285##
286
287#SeeAlso incomplete
288
289#Method ##
290
291# ------------------------------------------------------------------------------
292
Cary Clark61313f32018-10-08 14:57:48 -0400293#Method bool readScalar(SkScalar* s)
Cary Clarkd2ca79c2018-08-10 13:09:13 -0400294#In incomplete
295#Line # incomplete ##
296
297#Param s incomplete ##
298
299#Return incomplete ##
300
301#Example
302// incomplete
303##
304
305#SeeAlso incomplete
306
307#Method ##
308
309# ------------------------------------------------------------------------------
310
Cary Clark61313f32018-10-08 14:57:48 -0400311#Method bool readPackedUInt(size_t* u)
Cary Clarkd2ca79c2018-08-10 13:09:13 -0400312#In incomplete
313#Line # incomplete ##
314
315#Param u incomplete ##
316
317#Return incomplete ##
318
319#Example
320// incomplete
321##
322
323#SeeAlso incomplete
324
325#Method ##
326
327# ------------------------------------------------------------------------------
328
329#Method virtual bool rewind()
330#In incomplete
331#Line # incomplete ##
332
333Rewinds to the beginning of the stream. Returns true if the stream is known
334to be at the beginning after this call returns.
335
336#Return incomplete ##
337
338#Example
339// incomplete
340##
341
342#SeeAlso incomplete
343
344#Method ##
345
346# ------------------------------------------------------------------------------
347
348#Method std::unique_ptr<SkStream> duplicate() const
349#In incomplete
350#Line # incomplete ##
351
Cary Clark77b3f3a2018-11-07 14:59:03 -0500352Duplicates this stream. If this cannot be done, returns nullptr.
Cary Clarkd2ca79c2018-08-10 13:09:13 -0400353The returned stream will be positioned at the beginning of its data.
354
355#Return incomplete ##
356
357#Example
358// incomplete
359##
360
361#SeeAlso incomplete
362
363#Method ##
364
365# ------------------------------------------------------------------------------
366
367#Method std::unique_ptr<SkStream> fork() const
368#In incomplete
369#Line # incomplete ##
370
Cary Clark77b3f3a2018-11-07 14:59:03 -0500371Duplicates this stream. If this cannot be done, returns nullptr.
Cary Clarkd2ca79c2018-08-10 13:09:13 -0400372The returned stream will be positioned the same as this stream.
373
374#Return incomplete ##
375
376#Example
377// incomplete
378##
379
380#SeeAlso incomplete
381
382#Method ##
383
384# ------------------------------------------------------------------------------
385
386#Method virtual bool hasPosition() const
387#In incomplete
388#Line # incomplete ##
389
390Returns true if this stream can report its current position.
391
392#Return incomplete ##
393
394#Example
395// incomplete
396##
397
398#SeeAlso incomplete
399
400#Method ##
401
402# ------------------------------------------------------------------------------
403
404#Method virtual size_t getPosition() const
405#In incomplete
406#Line # incomplete ##
407
408Returns the current position in the stream. If this cannot be done, returns 0.
409
410#Return incomplete ##
411
412#Example
413// incomplete
414##
415
416#SeeAlso incomplete
417
418#Method ##
419
420# ------------------------------------------------------------------------------
421
422#Method virtual bool seek(size_t position)
423#In incomplete
424#Line # incomplete ##
425
426#Param position incomplete ##
427
428Seeks to an absolute position in the stream. If this cannot be done, returns false.
429If an attempt is made to seek past the end of the stream, the position will be set
430to the end of the stream.
431
432#Return incomplete ##
433
434#Example
435// incomplete
436##
437
438#SeeAlso incomplete
439
440#Method ##
441
442# ------------------------------------------------------------------------------
443
444#Method virtual bool move(long offset)
445#In incomplete
446#Line # incomplete ##
447
448#Param offset incomplete ##
449
450Seeks to an relative offset in the stream. If this cannot be done, returns false.
451If an attempt is made to move to a position outside the stream, the position will be set
452to the closest point within the stream (beginning or end).
453
454#Return incomplete ##
455
456#Example
457// incomplete
458##
459
460#SeeAlso incomplete
461
462#Method ##
463
464# ------------------------------------------------------------------------------
465
466#Method virtual bool hasLength() const
467#In incomplete
468#Line # incomplete ##
469
470Returns true if this stream can report its total length.
471
472#Return incomplete ##
473
474#Example
475// incomplete
476##
477
478#SeeAlso incomplete
479
480#Method ##
481
482# ------------------------------------------------------------------------------
483
484#Method virtual size_t getLength() const
485#In incomplete
486#Line # incomplete ##
487
488Returns the total length of the stream. If this cannot be done, returns 0.
489
490#Return incomplete ##
491
492#Example
493// incomplete
494##
495
496#SeeAlso incomplete
497
498#Method ##
499
500# ------------------------------------------------------------------------------
501
502#Method virtual const void* getMemoryBase()
503#In incomplete
504#Line # incomplete ##
505
Cary Clark77b3f3a2018-11-07 14:59:03 -0500506Returns the starting address for the data. If this cannot be done, returns nullptr.
507
508#Private
Cary Clarkd2ca79c2018-08-10 13:09:13 -0400509TODO: replace with virtual const SkData* getData()
Cary Clark77b3f3a2018-11-07 14:59:03 -0500510##
Cary Clarkd2ca79c2018-08-10 13:09:13 -0400511
512#Return incomplete ##
513
514#Example
515// incomplete
516##
517
518#SeeAlso incomplete
519
520#Method ##
521
522#Class SkStream ##
523
524#Topic Stream ##