This is a generic wrapper for a time instant relative to the unix epoch,
and does not account for leap seconds. It should be used in place of
Duration in most current cases.
That's what this class really is; in fact that's what the first line of
the comment says it is.
This commit does not rename the main files, since those will contain
other time-related classes in a little bit.
While refactoring the IPC encoders and decoders for fallibility, the
inconsistency in which we transfer container sizes was a frequent thing
to trip over. We currently transfer sizes as any of i32, u32, and u64.
This adds a helper to transfer sizes in one consistent way.
Two special cases here are DeprecatedString and Vector, whose encoding
is depended upon by netdb, so that is also updated here.
In doing so, this removes all uses of the Encoder's stream operator,
except for where it is currently still used in the generated IPC code.
So the stream operator currently discards any errors, which is the
existing behavior. A subsequent commit will propagate the errors.
Currently, the stream operator overload hides most encoding errors. In
an effort to make IPC encoding fallible, this first replaces the Encoder
overloads with IPC::encode specializations. The return type is still a
boolean, a future commit will change it to ErrorOr.
Note that just like in the analogous decoder commit (9b48362), these
specializations must be defined at the namespace scope. Further, all
arithmetic specializations are now in one method.
The format is quite simply the type index followed by the type in its
own native encoding; just implementing the receive side with static
typing is a bit convoluted. The only limitation of this implementation
is that the variant type has to contain an Empty somewhere as it is not
default constructible otherwise.
Co-authored-by: Ali Mohammad Pur <mpfard@serenityos.org>
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
For the most part, we try to provide specializations of these functions
in various headers by including "LibIPC/Forward.h" and then declaring
encode() and decode() specializations. However, without any forward
declaration of these types, we aren't actually specializing anything.
Rather, we are just declaring overloads, which trips up the base encode
and decode template definitions.
The result is that LibIPC is very sensitive to include order, and the
DependentFalse<> static assertion would fail if the includes weren't
perfectly ordered.
By properly forward declaring these templates, we can make sure the
specializations receive precedence over the base templates.
This remained undetected for a long time as HeaderCheck is disabled by
default. This commit makes the following file compile again:
// file: compile_me.cpp
#include <LibDNS/Question.h>
// That's it, this was enough to cause a compilation error.
Likewise for most other files touched by this commit.
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 *
(...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.