Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:48

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2022-2024 UT-Battelle, LLC, and other Celeritas developers.
0003 // See the top-level COPYRIGHT file for details.
0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0005 //---------------------------------------------------------------------------//
0006 //! \file corecel/io/StringUtils.hh
0007 //! \brief Helper functions for string processing
0008 //---------------------------------------------------------------------------//
0009 #pragma once
0010 
0011 #include <cstdlib>  // IWYU pragma: keep
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 }  // namespace celeritas