![]() |
|
|||
File indexing completed on 2025-09-16 09:08:38
0001 /// \file ROOT/StringUtils.hxx 0002 /// \ingroup Base StdExt 0003 /// \author Jonas Rembser <jonas.rembser@cern.ch> 0004 /// \date 2021-08-09 0005 0006 /************************************************************************* 0007 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. * 0008 * All rights reserved. * 0009 * * 0010 * For the licensing terms see $ROOTSYS/LICENSE. * 0011 * For the list of contributors see $ROOTSYS/README/CREDITS. * 0012 *************************************************************************/ 0013 0014 #ifndef ROOT_StringUtils 0015 #define ROOT_StringUtils 0016 0017 #include <string_view> 0018 0019 #include <string> 0020 #include <vector> 0021 #include <numeric> 0022 #include <iterator> 0023 0024 namespace ROOT { 0025 0026 std::vector<std::string> Split(std::string_view str, std::string_view delims, bool skipEmpty = false); 0027 0028 /** 0029 * \brief Concatenate a list of strings with a separator 0030 * \tparam StringCollection_t Any container of strings (vector, initializer_list, ...) 0031 * \param[in] sep Separator inbetween the strings. 0032 * \param[in] strings container of strings 0033 * \return the sep-delimited concatenation of strings 0034 */ 0035 template <class StringCollection_t> 0036 std::string Join(const std::string &sep, StringCollection_t &&strings) 0037 { 0038 if (strings.empty()) 0039 return ""; 0040 return std::accumulate(std::next(std::begin(strings)), std::end(strings), strings[0], 0041 [&sep](auto const &a, auto const &b) { return a + sep + b; }); 0042 } 0043 0044 } // namespace ROOT 0045 0046 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |