Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:09:40

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file corecel/io/StringUtils.hh
0006 //! \brief Helper functions for string processing
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <cstdlib>  // IWYU pragma: keep
0011 #include <string>
0012 #include <string_view>
0013 
0014 namespace celeritas
0015 {
0016 //---------------------------------------------------------------------------//
0017 // Whether the string starts with another string.
0018 bool starts_with(std::string_view main_string, std::string_view prefix);
0019 
0020 //---------------------------------------------------------------------------//
0021 // Whether the string ends with another string.
0022 bool ends_with(std::string_view main_string, std::string_view suffix);
0023 
0024 //---------------------------------------------------------------------------//
0025 // Whether the character is whitespace or unprintable
0026 bool is_ignored_trailing(unsigned char c);
0027 
0028 //---------------------------------------------------------------------------//
0029 // Compare two C strings for equality, allowing null for one
0030 bool cstring_equal(char const* lhs, char const* rhs);
0031 
0032 //---------------------------------------------------------------------------//
0033 // Return a string view with leading and trailing whitespace removed
0034 [[nodiscard]] std::string_view trim(std::string_view input);
0035 
0036 //---------------------------------------------------------------------------//
0037 // Return a lower-cased copy of the input string
0038 [[nodiscard]] std::string tolower(std::string_view input);
0039 
0040 //---------------------------------------------------------------------------//
0041 }  // namespace celeritas