Skip to content

Commit 89d3fb0

Browse files
committed
common: take string_view for strict_tobool
Signed-off-by: Patrick Donnelly <[email protected]>
1 parent ce19a4e commit 89d3fb0

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/common/strtol.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@
2222
#include <strings.h>
2323
#include <string_view>
2424

25+
#include <boost/algorithm/string/predicate.hpp>
26+
2527
using std::ostringstream;
28+
using namespace std::literals::string_view_literals;
2629

27-
bool strict_strtob(const char* str, std::string *err)
30+
bool strict_strtob(std::string_view str, std::string *err)
2831
{
29-
if (strcasecmp(str, "false") == 0) {
32+
if (boost::iequals(str, "false"sv)) {
3033
return false;
31-
} else if (strcasecmp(str, "true") == 0) {
34+
} else if (boost::iequals(str, "true"sv)) {
3235
return true;
3336
} else {
3437
int b = strict_strtol(str, 10, err);

src/common/strtol.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ auto consume(std::string_view& s, int base = 10)
6969
}
7070
} // namespace ceph
7171

72-
bool strict_strtob(const char* str, std::string *err);
72+
bool strict_strtob(std::string_view str, std::string *err);
7373

7474
long long strict_strtoll(std::string_view str, int base, std::string *err);
7575

0 commit comments

Comments
 (0)