|
||||
File indexing completed on 2025-01-30 10:22:42
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 0023 namespace ROOT { 0024 0025 std::vector<std::string> Split(std::string_view str, std::string_view delims, bool skipEmpty = false); 0026 0027 /** 0028 * \brief Concatenate a list of strings with a separator 0029 * \tparam StringCollection_t Any container of strings (vector, initializer_list, ...) 0030 * \param[in] sep Separator inbetween the strings. 0031 * \param[in] strings container of strings 0032 * \return the sep-delimited concatenation of strings 0033 */ 0034 template <class StringCollection_t> 0035 std::string Join(const std::string &sep, StringCollection_t &&strings) 0036 { 0037 if (strings.empty()) 0038 return ""; 0039 return std::accumulate(std::next(std::begin(strings)), std::end(strings), strings[0], 0040 [&sep](auto const &a, auto const &b) { return a + sep + b; }); 0041 } 0042 0043 } // namespace ROOT 0044 0045 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |