summaryrefslogtreecommitdiff
path: root/AK
AgeCommit message (Collapse)Author
2020-09-23Applications+IRCClient: Use new format functions.asynts
2020-09-23AK: Add outf, warnf and dbgf.asynts
2020-09-23AK: Resolve format related circular dependencies properly.asynts
With this commit, <AK/Format.h> has a more supportive role and isn't used directly. Essentially, there now is a public 'vformat' function ('v' for vector) which takes already type erased parameters. The name is choosen to indicate that this function behaves similar to C-style functions taking a va_list equivalent. The interface for frontend users are now 'String::formatted' and 'StringBuilder::appendff'.
2020-09-23AK: Allow calling format without arguments.asynts
2020-09-22AK: Add missing overload to format.asynts
I had this in #3580 but I must have lost it during rebasing.
2020-09-22AK: Use format in String::number.asynts
2020-09-22AK: Consider long and unsigned long as integral types.asynts
Two things I hate about C++: 1. 'int', 'signed int' and 'unsigned int' are two distinct types while 'char, 'signed char' and 'unsigned char' are *three* distinct types. This is because 'signed int' is an alias for 'int' but 'signed char' can't be an alias for 'char' because on some weird systems 'char' is unsigned. One might think why not do it the other way around, make 'int' an alias for 'signed int' and 'char' an alias for whatever that is on the platform, or make 'char' signed on all platforms. But who am I to ask? 2. 'unsigned long' and 'unsigned long long' are always different types, even if both are 64 bit numbers. This commit fixes a few bugs that coming from this. See Also: 1b3169f405ac9250b65ee3608e2962f51d2d8e3c.
2020-09-22AK: Add StringBuilder::appendff using the new format.asynts
StringBuilder::appendf was already used, thus this name. If we some day replace all usages of printf, we could rename this method.
2020-09-22AK: Remove strtoull dependency from format.asynts
This function is not avaliable in the kernel. In the future it would be nice to have some sort of <charconv> header that does this for all integer types and then call it in strtoull and et cetera. The difference would be that this function say 'from_chars' would return an Optional and not just interpret anything invalid as zero.
2020-09-21AK: Add format function like std::format or fmt::format.asynts
2020-09-21AK: Add template deduction guides for Array.asynts
2020-09-21AK: Add StringView::substring_view(size_t) overload.asynts
2020-09-21AK: Remove BufferStream class.asynts
There are three classes avaliable that share the functionality of BufferStream: 1. InputMemoryStream is for reading from static buffers. Example: Bytes input = /* ... */; InputMemoryStream stream { input }; LittleEndian<u32> little_endian_value; input >> little_endian_value; u32 host_endian_value; input >> host_endian_value; SomeComplexStruct complex_struct; input >> Bytes { &complex_struct, sizeof(complex_struct) }; 2. OutputMemoryStream is for writing to static buffers. Example: Array<u8, 4096> buffer; OutputMemoryStream stream; stream << LittleEndian<u32> { 42 }; stream << ReadonlyBytes { &complex_struct, sizeof(complex_struct) }; foo(stream.bytes()); 3. DuplexMemoryStream for writing to dynamic buffers, can also be used as an intermediate buffer by reading from it directly. Example: DuplexMemoryStream stream; stream << NetworkOrdered<u32> { 13 }; stream << NetowkrOrdered<u64> { 22 }; NetworkOrdered<u32> value; stream >> value; ASSERT(value == 13); foo(stream.copy_into_contiguous_buffer()); Unlike BufferStream these streams do not use a fixed endianness (BufferStream used little endian) these have to be explicitly specified. There are helper types in <AK/Endian.h>.
2020-09-21LibAudio: Use InputMemoryStream instead of BufferStream.asynts
2020-09-21AK: Add missing const in Span::operator==.asynts
2020-09-21AK: Add OutputMemoryStream::is_end.asynts
2020-09-15AK: Add OutputMemoryStream::fill_to_end.asynts
2020-09-15AK: Re-add OutputMemoryStream for static buffers only.asynts
2020-09-15AK: Remove OutputMemoryStream for DuplexMemoryStream.asynts
OutputMemoryStream was originally a proxy for DuplexMemoryStream that did not expose any reading API. Now I need to add another class that is like OutputMemoryStream but only for static buffers. My first idea was to make OutputMemoryStream do that too, but I think it's much better to have a distinct class for that. I originally wanted to call that class FixedOutputMemoryStream but that name is really cumbersome and it's a bit unintuitive because InputMemoryStream is already reading from a fixed buffer. So let's just use DuplexMemoryStream instead of OutputMemoryStream for any dynamic stuff and create a new OutputMemoryStream for static buffers.
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-12AK: Fix PrintfImplementation "%x" handling for u32AnotherTest
This also fixes an issue with the color input value being messed up. oops :P
2020-09-12AK: Fix forward-declaration of ArrayBen Wiederhake
2020-09-12AK: Fix accidentally-recursive call in BitStreamBen Wiederhake
2020-09-11AK: Generalise 'PrintfImplementation'AnotherTest
This makes PrintfImplementation usable with any sequence, provided that a 'next element' function can be written for it. Does not affect the behaviour of printf() and co.
2020-09-11AK: Calculate the chunk index correctly in DuplexMemoryStream.asynts
2020-09-10AK: Replace LogStream operator for ReadonlyBytes with dump_bytes.asynts
It wasn't actually possible to call const LogStream& operator<<(const LogStream&, ReadonlyBytes); because it was shadowed by template<typename T> const LogStream& operator<<(const LogStream& stream, Span<T> span); not sure how I didn't find this when I added the overload. It would be possible to use SFINAE to disable the other overload, however, I think it is better to use a different method entirely because the output can be very verbose: void dump_bytes(ReadonlyBytes);
2020-09-09AK: Use TypedTransfer in Span::copy_to.asynts
2020-09-09AK: Moved TypedTransfer into it's own header.asynts
2020-09-09AK: Add Bitmap::find_one_anywhere and optimize Bitmap::find_firstTom
Leverage constexpr and __builtin_ffs for Bitmap::find_first. Also add a variant Bitmap::find_one_anywhere that can start scanning at a provided hint. Also, merge Bitmap::fill_range into the already existing Bitmap::set_range
2020-09-08AK: Remove empty destructor from JsonParser.asynts
2020-09-08AK: Remove FixedArray class.asynts
2020-09-08Refactor: Replace usages of FixedArray with Vector.asynts
2020-09-08Refactor: Replace usages of FixedArray with Array.asynts
2020-09-08AK: Add Array<T, Size> template.asynts
2020-09-08AK: Add generic SimpleIterator class to replace VectorIterator.asynts
2020-09-06AK: Vector use Traits<T>::equals in findMuhammad Zahalqa
Use Traits<T>::equals for equality checking in search functions instead of operator==
2020-09-06AK: SinglyLinkedList use Traits<T>::equals in findMuhammad Zahalqa
Use Traits<T>::equals for equality checking in search functions instead of operator==
2020-09-06AK: Add Bitmap::count_in_range and Bitmap::fill_rangeTom
2020-09-06AK: Add LogStream overload for ReadonlyBytes.asynts
This is extremely useful for debugging.
2020-09-06AK: Add JsonObject::remove()Andreas Kling
2020-09-06LibCompress: Simplify logic in deflate implementation.asynts
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-06AK: Add log stream operator overload for Span.asynts
2020-09-05AK: Make all DoublyLinkedList search methods use Traits<T>::equals (#3404)Muhammad Zahalqa
2020-09-01AK: Add OutputMemoryStream class.asynts
2020-09-01AK: Add DuplexMemoryStream::copy_into_contiguous_buffer.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