2022-10-13 20:00:59 +00:00
|
|
|
set(AK_SOURCES
|
|
|
|
Assertions.cpp
|
|
|
|
Base64.cpp
|
2022-12-08 21:44:46 +00:00
|
|
|
CircularBuffer.cpp
|
2023-03-10 15:37:52 +00:00
|
|
|
ConstrainedStream.cpp
|
2023-03-16 09:23:24 +00:00
|
|
|
CountingStream.cpp
|
2023-02-21 11:44:41 +00:00
|
|
|
DOSPackedTime.cpp
|
2023-01-09 00:23:00 +00:00
|
|
|
DeprecatedFlyString.cpp
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString.cpp
|
2023-02-05 10:27:38 +00:00
|
|
|
Error.cpp
|
2022-10-13 00:18:56 +00:00
|
|
|
FloatingPointStringConversions.cpp
|
2023-01-11 13:26:49 +00:00
|
|
|
FlyString.cpp
|
2022-10-13 20:00:59 +00:00
|
|
|
Format.cpp
|
|
|
|
FuzzyMatch.cpp
|
|
|
|
GenericLexer.cpp
|
|
|
|
Hex.cpp
|
2023-01-04 17:38:01 +00:00
|
|
|
JsonObject.cpp
|
2022-10-13 20:00:59 +00:00
|
|
|
JsonParser.cpp
|
|
|
|
JsonPath.cpp
|
|
|
|
JsonValue.cpp
|
|
|
|
LexicalPath.cpp
|
2023-01-25 19:19:05 +00:00
|
|
|
MemoryStream.cpp
|
2022-12-10 08:52:46 +00:00
|
|
|
NumberFormat.cpp
|
2023-02-21 11:44:41 +00:00
|
|
|
OptionParser.cpp
|
2022-10-13 20:00:59 +00:00
|
|
|
Random.cpp
|
|
|
|
StackInfo.cpp
|
2023-01-22 04:09:11 +00: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 12:27:43 +00:00
|
|
|
String.cpp
|
2022-10-13 20:00:59 +00:00
|
|
|
StringBuilder.cpp
|
2022-10-25 18:00:49 +00:00
|
|
|
StringFloatingPointConversions.cpp
|
2022-10-13 20:00:59 +00:00
|
|
|
StringImpl.cpp
|
|
|
|
StringUtils.cpp
|
|
|
|
StringView.cpp
|
|
|
|
Time.cpp
|
|
|
|
URL.cpp
|
|
|
|
URLParser.cpp
|
2023-02-21 11:44:41 +00:00
|
|
|
UUID.cpp
|
2022-10-13 20:00:59 +00:00
|
|
|
Utf16View.cpp
|
2023-02-20 13:08:40 +00:00
|
|
|
Utf32View.cpp
|
2022-10-13 20:00:59 +00:00
|
|
|
Utf8View.cpp
|
2023-02-21 11:44:41 +00:00
|
|
|
kmalloc.cpp
|
2022-10-13 20:00:59 +00: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 18:20:24 +00:00
|
|
|
serenity_install_headers(AK)
|
2020-08-15 12:11:10 +00:00
|
|
|
serenity_install_sources(AK)
|