2 * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @file string_helpers.h
19 * @ingroup COM_AI_RUNTIME
20 * @brief This file contains helper functions for std::string
31 template <typename Arg> void _str(std::ostream &os, Arg &&arg) { os << std::forward<Arg>(arg); }
33 template <typename Arg, typename... Args> void _str(std::ostream &os, Arg &&arg, Args &&... args)
35 _str(os, std::forward<Arg>(arg));
36 _str(os, std::forward<Args>(args)...);
46 inline std::vector<std::string> split(const std::string &s, char delim)
48 std::stringstream ss(s);
50 std::vector<std::string> elems;
51 while (std::getline(ss, item, delim))
53 elems.push_back(std::move(item));
58 template <typename... Args> std::string str(Args &&... args)
61 _str(ss, std::forward<Args>(args)...);
65 template <typename InputIt> std::string join(InputIt first, InputIt last, const std::string &concat)
72 for (++first; first != last; ++first)