summaryrefslogtreecommitdiff
path: root/AK/StringView.cpp
AgeCommit message (Collapse)Author
2021-01-15StringView: Implement `find_first_of` in terms of `AK::find`Lenny Maiorani
Problem: - The implementation of `find_first_of` is coupled to the implementation of `StringView`. Solution: - Decouple the implementation of `find_first_of` from the class by using a generic `find` algorithm.
2021-01-12AK: Use StringView::find() in StringView::split_view()AnotherTest
This fixes #4926.
2021-01-12AK: Add String{View,}::find(StringView)AnotherTest
I personally mistook `find_first_of(StringView)` to be analogous to this so let's add a `find()` method that actually searches the string.
2021-01-11AK: Specialise convert_to_uint<T> and to_uint<T> for 'long' variantsAnotherTest
2020-12-21AK: Generalize AK::String::to_int() for more typesSahan Fernando
2020-10-29AK: Make String::matches() capable of reporting match positions tooAnotherTest
Also, rewrite StringUtils::match(), because the old implementation was fairly broken, e.g. "acdcxb" would *not* match "a*?b".
2020-10-22AK: Enhance String::contains to allow case-insensitive searchesTom
2020-09-21AK: Add StringView::substring_view(size_t) overload.asynts
2020-08-01AK: Add StringView::contains(StringView)AnotherTest
2020-07-21AK: Add case insensitive version of starts_withLuke
2020-06-12AK: Make string-to-number conversion helpers return OptionalAndreas Kling
Get rid of the weird old signature: - int StringType::to_int(bool& ok) const And replace it with sensible new signature: - Optional<int> StringType::to_int() const
2020-05-28AK: Add StringView::split_view() taking a StringViewAnotherTest
Since the task of splitting a string via another is pretty common, we might as well have this overload of split_view() as well.
2020-05-26AK: Unify FlyString/StringView::ends_with implementation on ↵Brian Gianforcaro
StringUtils::ends_with This creates a unified implementation of ends_with with case sensitivity across String/StringView/FlyString.
2020-05-13AK: Add StringView::equals_ignoring_case()Linus Groh
StringUtils::equals_ignoring_case() already operates on a StringView&, so StringView should have the method directly without having to go through a temporary String (which also has the method).
2020-05-06AK: Add to_string() method to StringViewEmanuel Sprung
This allows easy creation of a new string from an existing StringView. Can be used e.g. for output with printf(..., view.to_string().characters()) instead of writing printf(..., String{view}.characters()).
2020-05-04AK: Add StringView::find_first/last_ofAndrew Kaster
These methods search from the beginning or end of a string for the first character in the input StringView and returns the position in the string of the first match. Note that this is not a substring match. Each comes with single char overloads for efficiency.
2020-04-17AK: Add StringView::contains(char)Stephan Unverwerth
2020-03-23AK: Reduce header dependency graph of String.hAndreas Kling
String.h no longer pulls in StringView.h. We do this by moving a bunch of String functions out-of-line.
2020-03-22AK: Add FlyString, a simple flyweight string classAndreas Kling
FlyString is a flyweight string class that wraps a RefPtr<StringImpl> known to be unique among the set of FlyStrings. The class is very unoptimized at the moment. When to use FlyString: - When you want O(1) string comparison - When you want to deduplicate a lot of identical strings When not to use FlyString: - For strings that don't need either of the above features - For strings that are likely to be unique
2020-03-08AK: Move memory stuff (fast memcpy, etc) to a separate headerAndreas Kling
Move the "fast memcpy" stuff out of StdLibExtras.h and into Memory.h. This will break a ton of things that were relying on StdLibExtras.h to include a bunch of other headers. Fix will follow immediately after. This makes it possible to include StdLibExtras.h from Types.h, which is the main point of this exercise.
2020-03-02AK: Move to_int(), to_uint() implementations to StringUtils (#1338)howar6hill
Provide wrappers in String and StringView. Add some tests for the implementations.
2020-03-02AK: Move the wildcard-matching implementation to StringUtilshowar6hill
Provide wrappers in the String and StringView classes, and add some tests.
2020-03-01AK: Remove unnecessary casts to size_t, after Vector changesAndreas Kling
Now that Vector uses size_t, we can remove a whole bunch of redundant casts to size_t.
2020-02-22AK: Add StringView::starts_with(char) & StringView::ends_with(char)Shannon Booth
This is simply meant to be a more efficient implementation in the case that we only need to check a single character.
2020-02-14AK: Add a forward declaration headerAndreas Kling
You can now #include <AK/Forward.h> to get most of the AK types as forward declarations. Header dependency explosion is one of the main contributors to compile times at the moment, so this is a step towards smaller include graphs.
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2020-01-14AK: Fix String[View]::split_view() returning an extra empty partSergey Bugaev
If the last character was the separator and keep_empty is true, the previous if statement would have already appended the last empty part, so no need to do this again. This was even more problematic, because the result of split_view() is expected to consist of true substrings that are usable with the StringView::substring_view_starting_*_substring() methods, not of equal strings located elsewhere. Fixes https://github.com/SerenityOS/serenity/issues/970 See https://github.com/SerenityOS/serenity/pull/938
2020-01-14AK: Don't return null from String[View]::substring_view()Sergey Bugaev
We expect the result to be usable with the StringView::substring_view_starting_*_substring() methods. See https://github.com/SerenityOS/serenity/pull/938
2019-12-29AK: Add StringView::ends_with functionShannon Booth
2019-12-09AK: Use size_t for the length of stringsAndreas Kling
Using int was a mistake. This patch changes String, StringImpl, StringView and StringBuilder to use size_t instead of int for lengths. Obviously a lot of code needs to change as a result of this.
2019-12-02AK: StringView::lines() should keep empty linesAndreas Kling
2019-12-02LibMarkdown: Handle CRLF line endingsTommy Nguyen
Previously, MDDocument only split on Unix-style line endings. This adds a new function to StringView which handles LF, CR and CRLF.
2019-09-28AK: Add a keep_empty argument to String[View]::substring{_view}Sergey Bugaev
2019-09-13StringView: Add starts_with methodMinusGix
2019-09-06AK: Rename <AK/AKString.h> to <AK/String.h>Andreas Kling
This was a workaround to be able to build on case-insensitive file systems where it might get confused about <string.h> vs <String.h>. Let's just not support building that way, so String.h can have an objectively nicer name. :^)
2019-08-25AK: Add StringView::hash()Andreas Kling
This grabs the hash from the underlying StringImpl if there is one, otherwise it's computed on the fly.
2019-08-04AK: Add StringView::to_int()Andreas Kling
This is a shameless copy-paste of String::to_int(). We should find some way to share this code between String and StringView instead of having two duplicate copies like this.
2019-07-08StringView: Rename characters() to characters_without_null_termination().Andreas Kling
This should make you think twice before trying to use the const char* from a StringView as if it's a null-terminated string.
2019-06-29StringView: Make it easy to construct from a ByteBuffer.Andreas Kling
2019-06-14AK: Add more StringView utilities for making substrings.Sergey Bugaev
These two allow making a new substring view starting from, or starting after, an existing substring view. Also make use of one of them in the kernel.
2019-06-08StringView: Store a StringImpl* rather than a String*.Andreas Kling
2019-06-03StringView: Make construction of String from a StringView containing a ↵Robin Burchell
String cheaper ... at the cost of an additional pointer per view.
2019-06-02AK: Add implicit String -> StringView conversionRobin Burchell
And tidy up existing view() users.
2019-05-28Add clang-format fileRobin Burchell
Also run it across the whole tree to get everything using the One True Style. We don't yet run this in an automated fashion as it's a little slow, but there is a snippet to do so in makeall.sh.
2019-04-16AK: Try to use StringViews more for substrings and splitting.Andreas Kling