Add interface for enumerating over sequences.
This commit is contained in:
parent
7876efc4f5
commit
57d94ef8b9
@ -495,6 +495,35 @@ export namespace coral {
|
|||||||
*/
|
*/
|
||||||
virtual expected<usize, io_error> write(slice<u8 const> const & data) = 0;
|
virtual expected<usize, io_error> write(slice<u8 const> const & data) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sequence enumeration interface.
|
||||||
|
*/
|
||||||
|
template<typename type> struct enumerator {
|
||||||
|
virtual ~enumerator() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the last-enumerated value.
|
||||||
|
*
|
||||||
|
* *Note*: calling this function before first having recieved a `true` value from [enumerate] will result in
|
||||||
|
* implementation-defined behaviour.
|
||||||
|
*/
|
||||||
|
virtual type value() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to retrieve the next file path in the file tree, returning true if another value was retrieved or
|
||||||
|
* `false` if there are no more values to be enumerated over.
|
||||||
|
*
|
||||||
|
* ```cpp
|
||||||
|
* while (sequence.enumerate()) {
|
||||||
|
* do_thing(sequence.value());
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The enumerated value may be accessed through [value].
|
||||||
|
*/
|
||||||
|
virtual bool enumerate() = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Input/output operations.
|
// Input/output operations.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user