Repository navigation
EStreamCapability
Jay edited this page Oct 3, 2026
·
2 revisions
#include <certpp/io/stream.hpp> --- certpp
Stream capabilities.
| Enumerator | Value | Meaning |
|---|---|---|
ESTREAM_READ |
0x01 |
|
ESTREAM_WRITE |
0x02 |
|
ESTREAM_SEEK |
0x04 |
A bitmask of what a stream supports, not a single value: test the bit you are about to rely on. A memory stream reports all three, but a stream handed in from elsewhere may be read-only or unseekable, and the calls it cannot do fail at run time rather than at compile time.
// given: const IStreamPtr& stream
if (!stream) {
return;
}
const uint32_t caps = stream->capabilities();
if ((caps & ESTREAM_WRITE) == 0) {
return;
}
const uint8_t marker[] = { 0x30, 0x82 };
if (stream->write(marker, sizeof(marker)) != sizeof(marker)) {
return;
}
// Reading back what was just written needs both bits, not just ESTREAM_READ.
const uint32_t both = uint32_t(ESTREAM_READ | ESTREAM_SEEK);
if ((caps & both) == both && stream->seek(0, ESEEK_SET) != ERET_OK) {
return;
}Reference generated from certpp/io/stream.hpp at commit 0834b29 (v1.0.1). The header is authoritative --- if this page disagrees with it, the header is right and this page needs regenerating.