-
Notifications
You must be signed in to change notification settings - Fork 389
/
Copy pathByteSource.h
30 lines (25 loc) · 929 Bytes
/
ByteSource.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once
namespace facebook { namespace wdt {
class ByteSource {
public:
/// @return true iff no more data to read
bool finished() const;
/// @return true iff there was an error reading
bool hasError() const;
/**
* Read chunk of data from the source and return a pointer to data and its
* size. Memory is owned by the source. Subsequent calls to read() might
* delete the previously read data so make sure to consume all data between
* calls to read().
*
* @param size will be set to number of bytes read (the source will
* decide how much data to read at once)
*
* @return pointer to the data read; in case of failure or EOF,
* nullptr will be returned and size will be set to 0;
* use finished() and hasError() members to distinguish
* the two cases
*/
char* read(size_t& size);
};
}}