goo/GooString.cc | 17 ++++++++++++++--- goo/GooString.h | 6 +++++- 2 files changed, 19 insertions(+), 4 deletions(-)
New commits: commit 6e1fe42a6a3c3f7b7cfb259f7de3d8a1de279016 Author: Albert Astals Cid <[email protected]> Date: Mon Mar 7 16:24:06 2022 +0100 GooString: Add lowercase helpers for std::string diff --git a/goo/GooString.cc b/goo/GooString.cc index 54e8bc52..42436234 100644 --- a/goo/GooString.cc +++ b/goo/GooString.cc @@ -18,7 +18,7 @@ // Copyright (C) 2006 Kristian Høgsberg <[email protected]> // Copyright (C) 2006 Krzysztof Kowalczyk <[email protected]> // Copyright (C) 2007 Jeff Muizelaar <[email protected]> -// Copyright (C) 2008-2011, 2016-2018, 2021 Albert Astals Cid <[email protected]> +// Copyright (C) 2008-2011, 2016-2018, 2022 Albert Astals Cid <[email protected]> // Copyright (C) 2011 Kenji Uno <[email protected]> // Copyright (C) 2012, 2013 Fabio D'Urso <[email protected]> // Copyright (C) 2012, 2017 Adrian Johnson <[email protected]> @@ -589,13 +589,24 @@ void formatDoubleSmallAware(double x, char *buf, int bufSize, int prec, bool tri GooString *GooString::lowerCase() { - for (auto &c : *this) { + lowerCase(*this); + return this; +} + +void GooString::lowerCase(std::string &s) +{ + for (auto &c : s) { if (std::isupper(c)) { c = std::tolower(c); } } +} - return this; +std::string GooString::toLowerCase(const std::string &s) +{ + std::string newString = s; + lowerCase(newString); + return s; } void GooString::prependUnicodeMarker() diff --git a/goo/GooString.h b/goo/GooString.h index aa68635c..d6747f90 100644 --- a/goo/GooString.h +++ b/goo/GooString.h @@ -17,7 +17,7 @@ // // Copyright (C) 2006 Kristian Høgsberg <[email protected]> // Copyright (C) 2006 Krzysztof Kowalczyk <[email protected]> -// Copyright (C) 2008-2010, 2012, 2014, 2017-2021 Albert Astals Cid <[email protected]> +// Copyright (C) 2008-2010, 2012, 2014, 2017-2022 Albert Astals Cid <[email protected]> // Copyright (C) 2012-2014 Fabio D'Urso <[email protected]> // Copyright (C) 2013 Jason Crain <[email protected]> // Copyright (C) 2015, 2018 Adam Reichold <[email protected]> @@ -222,6 +222,10 @@ public: // Convert string to all-lower case. GooString *lowerCase(); + static void lowerCase(std::string &s); + + // Returns a new string converted to all-lower case. + static std::string toLowerCase(const std::string &s); // Compare two strings: -1:< 0:= +1:> int cmp(const GooString *str) const { return compare(*str); }
