forked from celeritas-project/celeritas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
StringUtils.hh
33 lines (27 loc) · 1.46 KB
/
StringUtils.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//----------------------------------*-C++-*----------------------------------//
// Copyright 2022-2024 UT-Battelle, LLC, and other Celeritas developers.
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
//---------------------------------------------------------------------------//
//! \file corecel/io/StringUtils.hh
//! \brief Helper functions for string processing
//---------------------------------------------------------------------------//
#pragma once
#include <cstdlib> // IWYU pragma: keep
#include <string_view>
namespace celeritas
{
//---------------------------------------------------------------------------//
// Whether the string starts with another string.
bool starts_with(std::string_view main_string, std::string_view prefix);
//---------------------------------------------------------------------------//
// Whether the string ends with another string.
bool ends_with(std::string_view main_string, std::string_view suffix);
//---------------------------------------------------------------------------//
// Whether the character is whitespace or unprintable
bool is_ignored_trailing(unsigned char c);
//---------------------------------------------------------------------------//
// Return a string view with leading and trailing whitespace removed
[[nodiscard]] std::string_view trim(std::string_view input);
//---------------------------------------------------------------------------//
} // namespace celeritas