ONE - On-device Neural Engine
Loading...
Searching...
No Matches
String.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17#ifndef __ENCO_STRING_H__
18#define __ENCO_STRING_H__
19
20//
21// String-manipulating routines
22//
23#include <ostream>
24#include <sstream>
25
26#include <string>
27
28namespace enco
29{
30
31template <typename It> void concat(std::ostream &os, const std::string &sep, It beg, It end)
32{
33 uint32_t count = 0;
34
35 for (auto it = beg; it != end; ++it, ++count)
36 {
37 if (count == 0)
38 {
39 os << *it;
40 }
41 else
42 {
43 os << sep << *it;
44 }
45 }
46}
47
48template <typename It> std::string concat(const std::string &sep, It beg, It end)
49{
50 std::stringstream ss;
51 concat(ss, sep, beg, end);
52 return ss.str();
53}
54
55} // namespace enco
56
57#endif // __ENCO_STRING_H__
Definition Bundle.h:26
void concat(std::ostream &os, const std::string &sep, It beg, It end)
Definition String.h:31