25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
#ifdef OF_HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#import "OFStream.h"
OF_ASSUME_NONNULL_BEGIN
#if defined(OF_WINDOWS)
typedef __int64 OFStreamOffset;
#elif defined(OF_ANDROID)
typedef long long OFStreamOffset;
#elif defined(OF_MORPHOS)
typedef signed long long OFStreamOffset;
#elif defined(OF_HAVE_OFF64_T)
typedef off64_t OFStreamOffset;
#else
typedef off_t OFStreamOffset;
#endif
/**
* @class OFSeekableStream OFSeekableStream.h ObjFW/OFSeekableStream.h
*
* @brief A stream that supports seeking.
*
* @note If you want to subclass this, override
* @ref lowlevelSeekToOffset:whence:. OFSeekableStream uses this method
* and makes it work together with the caching of OFStream. If you
* override this methods without the `lowlevel` prefix, you *will* break
* caching, get broken results and seek to the wrong position!
*/
@interface OFSeekableStream: OFStream
{
OF_RESERVE_IVARS(OFSeekableStream, 4)
}
/**
* @brief Seeks to the specified offset.
*
* @param offset The offset in bytes
* @param whence From where to seek.@n
* Possible values are:
* Value | Description
* -----------|---------------------------------------
* `SEEK_SET` | Seek to the specified byte
* `SEEK_CUR` | Seek to the current location + offset
* `SEEK_END` | Seek to the end of the stream + offset
* @return The new offset form the start of the file
*/
- (OFStreamOffset)seekToOffset: (OFStreamOffset)offset whence: (int)whence;
/**
* @brief Seek the stream on the lowlevel.
*
* @warning Do not call this directly!
*
* @note Override this method with your actual seek implementation when
* subclassing!
*
* @param offset The offset to seek to
* @param whence From where to seek.@n
* Possible values are:
* Value | Description
* -----------|---------------------------------------
* `SEEK_SET` | Seek to the specified byte
* `SEEK_CUR` | Seek to the current location + offset
* `SEEK_END` | Seek to the end of the stream + offset
* @return The new offset from the start of the file
*/
- (OFStreamOffset)lowlevelSeekToOffset: (OFStreamOffset)offset
whence: (int)whence;
@end
OF_ASSUME_NONNULL_END
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
<
<
<
<
<
<
|
>
|
<
<
<
<
<
<
|
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#ifdef OF_HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#import "OFStream.h"
OF_ASSUME_NONNULL_BEGIN
/** @file */
#if defined(OF_WINDOWS)
typedef __int64 OFStreamOffset;
#elif defined(OF_ANDROID)
typedef long long OFStreamOffset;
#elif defined(OF_MORPHOS)
typedef signed long long OFStreamOffset;
#elif defined(OF_HAVE_OFF64_T)
typedef off64_t OFStreamOffset;
#else
typedef off_t OFStreamOffset;
#endif
/**
* @brief From where to seek.
*/
typedef enum {
/** Seek to the end of the stream + offset. */
OFSeekSet,
/** Seek to the current location + offset. */
OFSeekCurrent,
/** Seek to the specified byte. */
OFSeekEnd
} OFSeekWhence;
/**
* @class OFSeekableStream OFSeekableStream.h ObjFW/OFSeekableStream.h
*
* @brief A stream that supports seeking.
*
* @note If you want to subclass this, override
* @ref lowlevelSeekToOffset:whence:. OFSeekableStream uses this method
* and makes it work together with the caching of OFStream. If you
* override this methods without the `lowlevel` prefix, you *will* break
* caching, get broken results and seek to the wrong position!
*/
@interface OFSeekableStream: OFStream
{
OF_RESERVE_IVARS(OFSeekableStream, 4)
}
/**
* @brief Seeks to the specified offset.
*
* @param offset The offset in bytes
* @param whence From where to seek.
* @return The new offset form the start of the file
*/
- (OFStreamOffset)seekToOffset: (OFStreamOffset)offset
whence: (OFSeekWhence)whence;
/**
* @brief Seek the stream on the lowlevel.
*
* @warning Do not call this directly!
*
* @note Override this method with your actual seek implementation when
* subclassing!
*
* @param offset The offset to seek to
* @param whence From where to seek.
* @return The new offset from the start of the file
*/
- (OFStreamOffset)lowlevelSeekToOffset: (OFStreamOffset)offset
whence: (OFSeekWhence)whence;
@end
OF_ASSUME_NONNULL_END
|