summaryrefslogtreecommitdiff
path: root/AK/Stream.h
AgeCommit message (Collapse)Author
2021-11-28LibIPC+IPCCompiler+AK: Make IPC value decoders return ErrorOr<void>Andreas Kling
This allows us to use TRY() in decoding helpers, leading to a nice reduction in line count.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-10AK+Everywhere: Make StdLibExtras templates less wrapper-yAnotherTest
This commit makes the user-facing StdLibExtras templates and utilities arguably more nice-looking by removing the need to reach into the wrapper structs generated by them to get the value/type needed. The C++ standard library had to invent `_v` and `_t` variants (likely because of backwards compat), but we don't need to cater to any codebase except our own, so might as well have good things for free. :^)
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2020-12-30AK: Replace some SFINAE with requires clauses, clean up existing onesAndrew Kaster
Add requires clauses to constraints on InputStream and OutputStream operator<< / operator>>. Make the constraint on String::number a requires clause instead of SFINAE. Also, fix some unecessary IsSame in Trie where specialized traits exist for the given use cases.
2020-10-03Everywhere: Fix more typosLinus Groh
2020-09-14AK: Lower the requirements for InputStream::eof and rename it.asynts
Consider the following snippet: void foo(InputStream& stream) { if(!stream.eof()) { u8 byte; stream >> byte; } } There is a very subtle bug in this snippet, for some input streams eof() might return false even if no more data can be read. In this case an error flag would be set on the stream. Until now I've always ensured that this is not the case, but this made the implementation of eof() unnecessarily complicated. InputFileStream::eof had to keep a ByteBuffer around just to make this possible. That meant a ton of unnecessary copies just to get a reliable eof(). In most cases it isn't actually necessary to have a reliable eof() implementation. In most other cases a reliable eof() is avaliable anyways because in some cases like InputMemoryStream it is very easy to implement.
2020-09-06Streams: Consistent behaviour when reading from stream with error.asynts
The streaming operator doesn't short-circuit, consider the following snippet: void foo(InputStream& stream) { int a, b; stream >> a >> b; } If the first read fails, the second is called regardless. It should be well defined what happens in this case: nothing.
2020-09-06AK: Add Buffered<T> which wraps a stream, adding input buffering.asynts
2020-09-01AK: Move memory streams into their own header.asynts
2020-09-01AK: Remove history from DuplexMemoryStream.asynts
That feature was really only useful for Compress::DeflateDecompressor but that is now using CircularDuplexBuffer instead.
2020-09-01Streams: Distinguish recoverable and fatal errors.asynts
2020-08-30AK: Stream operators for String for generic streams.asynts
I think this should really be a member function of InputStream instead, but I don't want to include String in Stream.h. This will do for now...
2020-08-29AK: Don't swap endianness when writing endian wrappers to stream.asynts
2020-08-26AK: Add stream operators for Optional.asynts
2020-08-25AK: Add Endian.h header to replace NetworkOrdered.h.asynts
2020-08-21AK: Add Stream::offset_of(ReadonlyBytes)AnotherTest
2020-08-20LibCompress: Turn the DEFLATE implementation into a stream.asynts
Previously, the implementation would produce one Vector<u8> which would contain the whole decompressed data. That can be a lot and even exhaust memory. With these changes it is still necessary to store the whole input data in one piece (I am working on this next,) but the output can be read block by block. (That's not optimal either because blocks can be arbitrarily large, but it's good for now.)
2020-08-20AK: Add DuplexMemoryStream class.asynts
This class is similar to BufferStream because it is possible to both read and write to it. However, it differs in the following ways: - DuplexMemoryStream keeps a history of 64KiB and discards the rest, BufferStream always keeps everything around. - DuplexMemoryStream tracks reading and writing seperately, the following is valid: DuplexMemoryStream stream; stream << 42; int value; stream >> value; For BufferStream it would read: BufferStream stream; stream << 42; int value; stream.seek(0); stream >> value; In the future I would like to replace all usages of BufferStream with InputMemoryStream, OutputMemoryStream (doesn't exist yet) and DuplexMemoryStream. For now I just add DuplexMemoryStream though.
2020-08-20AK: Remove unnecessary FIXME comments from Stream.h.asynts
2020-08-20AK: Rename error() to has_error() for streams.asynts
2020-08-20AK: Remove fatal() from InputStream.asynts
Fatal errors can not be handeled and lead to an assertion error when the stream is destroyed. It makes no sense to delay the assertion failure, instead of setting m_fatal, an assertion should be done directly.
2020-08-17AK: Add SFINAE fallback for AK C++ concepts use, for Coverity compilerBrian Gianforcaro
The Coverity compiler doesn't support C++2a yet, and thus doesn't even recognize concept keywords. To allow serenity to be built and analyzed on such compilers, add a fallback underdef to perform the same template restriction based on AK::EnableIf<..> meta programming. Note: Coverity does seem to (annoyingly) define __cpp_concepts, even though it doesn't support them, so we need to further check for __COVERITY__ explicitly.
2020-08-07AK: Remove unnecessary clang-format off comments.asynts
2020-08-06AK: Remove Stream::operator bool()Andreas Kling
This was only used in one place, and that caused a bug, so I'm removing this for now since there are no more uses.
2020-08-06LibDebug: Use InputMemoryStream instead of BufferStream.asynts
This removes another call to ByteBuffer::wrap(const void*, size_t).
2020-08-06AK: Add InputStream abstraction and InputMemoryStream implementation.asynts