Commit graph

13 commits

Author SHA1 Message Date
Elliott Hughes
908e0dfda5 Add absl-like StringReplace.
Needed for cli-test.

Test: treehugger
Change-Id: Ib1fd01ef7f3e54e5778cc548dd789b5fcfcb7bd9
2019-11-18 16:02:31 -08:00
Elliott Hughes
b4dc7be6c5 libbase: add ConsumePrefix/ConsumeSuffix.
adb was already using ConsumePrefix, and now we have another would-be
user in cutils. (There appears to be one place in adb that should use
ConsumeSuffix, so I'm assuming we'll want that sooner or later.)

I've kept these inline because adb and google3's versions both were, and
I'm easily led.

Test: treehugger
Change-Id: I29d99032f6f6ccbfaefece59725db8afb02a4c87
2019-05-03 12:49:31 -07:00
Yabin Cui
a656b98634 libbase: support char parameter in StartsWith/EndsWith.
Bug: 117568547
Test: run libbase_test.
Change-Id: I5a6a412733c594f5a116f333b8e091d2d9f60e06
2018-10-30 17:20:50 -07:00
Elliott Hughes
579e682628 Add std::string StartsWith*/EndsWith* overloads.
We should have done this from the beginning. Thanks to Windows, we're not
going to be able to switch libbase over to std::string_view any time soon.

Bug: N/A
Test: ran tests
Change-Id: Iff2f56986e39de53f3ac484415378af17dacf26b
2017-12-20 09:42:22 -08:00
Tom Cherry
fbbf27da02 Add test for android::base::Split with a trailing empty part.
Test: this new unit test
Change-Id: Ia14ba878f2866e333a69f1e6f7f56b66a7e657a5
2017-10-26 10:50:20 -07:00
Elliott Hughes
bf0dd7cb03 Fix ubsan failure in android::base::Split.
ubsan doesn't like us incrementing std::string::npos, even if we won't use
the result.

Bug: http://b/28729303
Test: ran tests
Change-Id: I8227eca57dc6f3e49626c7025514caa04ef18f0a
2017-02-13 14:13:24 -08:00
Elliott Hughes
2140782d24 bootable/recovery wants EqualsIgnoreCase.
Bug: N/A
Test: ran tests
Change-Id: I4a6ee9eba0514b8bb8fb0489f4d370964ce9c1c2
2017-01-13 18:51:32 -08:00
Elliott Hughes
42937492c8 Add StartsWithIgnoreCase/EndsWithIgnoreCase.
This has come up a couple of times now.

Bug: wanted as part of http://b/32094640
Test: ran tests
Change-Id: I51b67074b7ddeedd771d7be9651ba33e05491b33
2016-10-25 14:56:04 -07:00
Elliott Hughes
4f71319df0 Track rename of base/ to android-base/.
Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
2015-12-04 22:00:26 -08:00
Dan Albert
e0da8a1d37 Generalize Join to work for any container/element.
This is more scalable than explicitly instantiating templates for the
cross product of containers and element types.

Specifically I'm adding this so I can join an unordered_set in adb.

Change-Id: I0055f3390a0ff26a886a0d41bbf0d4fe3d210f9c
2015-05-22 10:07:06 -07:00
Elliott Hughes
8d5fa6da44 Remove strtok from adb.
Also fix android::base::Split to behave like Java, Python, and google3.

Change-Id: Ifbffd4e92950a79e7aea5d153c95fe0980648417
2015-04-27 19:42:20 -07:00
Dan Albert
47328c96d9 Update string Split API.
Return a new vector rather than appending to the parameter.

Delimiters are also a string rather than a character. Split on any
character in the string.

Change-Id: I039b332ace5578590df9e7ca0e8fa3db28db30a3
2015-03-23 10:23:11 -07:00
Dan Albert
0f1e54491c Add common string utilities to libbase.
These are useful outside of ART. Nothing changed (aside from fixing
Trim to not segfault on empty strings), so ART should be able to move
to using these.

Change-Id: Id026ebffe8d31f784a91834786ab189680b13a0f
2015-03-16 20:03:03 -07:00