2022-10-13 23:00:59 +03:00
|
|
|
set(AK_SOURCES
|
|
|
|
Assertions.cpp
|
|
|
|
Base64.cpp
|
2022-12-09 00:44:46 +03:00
|
|
|
CircularBuffer.cpp
|
2023-03-10 18:37:52 +03:00
|
|
|
ConstrainedStream.cpp
|
2023-03-16 12:23:24 +03:00
|
|
|
CountingStream.cpp
|
2023-02-21 14:44:41 +03:00
|
|
|
DOSPackedTime.cpp
|
2023-01-09 03:23:00 +03:00
|
|
|
DeprecatedFlyString.cpp
|
2023-12-16 17:19:34 +03:00
|
|
|
ByteString.cpp
|
2023-02-05 13:27:38 +03:00
|
|
|
Error.cpp
|
2022-10-13 03:18:56 +03:00
|
|
|
FloatingPointStringConversions.cpp
|
2023-01-11 16:26:49 +03:00
|
|
|
FlyString.cpp
|
2022-10-13 23:00:59 +03:00
|
|
|
Format.cpp
|
|
|
|
FuzzyMatch.cpp
|
|
|
|
GenericLexer.cpp
|
|
|
|
Hex.cpp
|
2023-01-04 20:38:01 +03:00
|
|
|
JsonObject.cpp
|
2022-10-13 23:00:59 +03:00
|
|
|
JsonParser.cpp
|
|
|
|
JsonPath.cpp
|
|
|
|
JsonValue.cpp
|
|
|
|
LexicalPath.cpp
|
2023-01-25 22:19:05 +03:00
|
|
|
MemoryStream.cpp
|
2022-12-10 11:52:46 +03:00
|
|
|
NumberFormat.cpp
|
2023-02-21 14:44:41 +03:00
|
|
|
OptionParser.cpp
|
2022-10-13 23:00:59 +03:00
|
|
|
Random.cpp
|
2023-09-21 01:14:35 +03:00
|
|
|
SipHash.cpp
|
2023-09-27 20:11:57 +03:00
|
|
|
Slugify.cpp
|
2022-10-13 23:00:59 +03:00
|
|
|
StackInfo.cpp
|
2023-01-22 07:09:11 +03:00
|
|
|
Stream.cpp
|
AK: Introduce the new String, replacement for DeprecatedString
DeprecatedString (formerly String) has been with us since the start,
and it has served us well. However, it has a number of shortcomings
that I'd like to address.
Some of these issues are hard if not impossible to solve incrementally
inside of DeprecatedString, so instead of doing that, let's build a new
String class and then incrementally move over to it instead.
Problems in DeprecatedString:
- It assumes string allocation never fails. This makes it impossible
to use in allocation-sensitive contexts, and is the reason we had to
ban DeprecatedString from the kernel entirely.
- The awkward null state. DeprecatedString can be null. It's different
from the empty state, although null strings are considered empty.
All code is immediately nicer when using Optional<DeprecatedString>
but DeprecatedString came before Optional, which is how we ended up
like this.
- The encoding of the underlying data is ambiguous. For the most part,
we use it as if it's always UTF-8, but there have been cases where
we pass around strings in other encodings (e.g ISO8859-1)
- operator[] and length() are used to iterate over DeprecatedString one
byte at a time. This is done all over the codebase, and will *not*
give the right results unless the string is all ASCII.
How we solve these issues in the new String:
- Functions that may allocate now return ErrorOr<String> so that ENOMEM
errors can be passed to the caller.
- String has no null state. Use Optional<String> when needed.
- String is always UTF-8. This is validated when constructing a String.
We may need to add a bypass for this in the future, for cases where
you have a known-good string, but for now: validate all the things!
- There is no operator[] or length(). You can get the underlying data
with bytes(), but for iterating over code points, you should be using
an UTF-8 iterator.
Furthermore, it has two nifty new features:
- String implements a small string optimization (SSO) for strings that
can fit entirely within a pointer. This means up to 3 bytes on 32-bit
platforms, and 7 bytes on 64-bit platforms. Such small strings will
not be heap-allocated.
- String can create substrings without making a deep copy of the
substring. Instead, the superstring gets +1 refcount from the
substring, and it acts like a view into the superstring. To make
substrings like this, use the substring_with_shared_superstring() API.
One caveat:
- String does not guarantee that the underlying data is null-terminated
like DeprecatedString does today. While this was nifty in a handful of
places where we were calling C functions, it did stand in the way of
shared-superstring substrings.
2022-12-01 15:27:43 +03:00
|
|
|
String.cpp
|
2023-10-28 22:17:06 +03:00
|
|
|
StringBase.cpp
|
2022-10-13 23:00:59 +03:00
|
|
|
StringBuilder.cpp
|
2022-10-25 21:00:49 +03:00
|
|
|
StringFloatingPointConversions.cpp
|
2022-10-13 23:00:59 +03:00
|
|
|
StringImpl.cpp
|
|
|
|
StringUtils.cpp
|
|
|
|
StringView.cpp
|
|
|
|
Time.cpp
|
2023-02-21 14:44:41 +03:00
|
|
|
UUID.cpp
|
2022-10-13 23:00:59 +03:00
|
|
|
Utf16View.cpp
|
2023-02-20 16:08:40 +03:00
|
|
|
Utf32View.cpp
|
2022-10-13 23:00:59 +03:00
|
|
|
Utf8View.cpp
|
2023-02-21 14:44:41 +03:00
|
|
|
kmalloc.cpp
|
2022-10-13 23:00:59 +03:00
|
|
|
)
|
|
|
|
# AK sources are included from many different places, such as the Kernel, LibC, and Loader
|
|
|
|
list(TRANSFORM AK_SOURCES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/")
|
|
|
|
|
|
|
|
set(AK_SOURCES ${AK_SOURCES} PARENT_SCOPE)
|
|
|
|
|
2020-05-26 21:20:24 +03:00
|
|
|
serenity_install_headers(AK)
|
2020-08-15 15:11:10 +03:00
|
|
|
serenity_install_sources(AK)
|