Publishing 2019 R1.1 content and Myriad plugin sources (#162)
[platform/upstream/dldt.git] / inference-engine / src / vpu / graph_transformer / include / vpu / utils / string.hpp
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #pragma once
6
7 #include <string>
8 #include <vector>
9 #include <set>
10 #include <unordered_set>
11 #include <sstream>
12 #include <utility>
13
14 #include <details/caseless.hpp>
15
16 #include <vpu/utils/containers.hpp>
17
18 namespace vpu {
19
20 namespace ie = InferenceEngine;
21
22 namespace impl {
23
24 inline void insertToContainer(std::vector<std::string>& cont, std::string&& val) {
25     cont.emplace_back(val);
26 }
27
28 template <int Capacity>
29 void insertToContainer(SmallVector<std::string, Capacity>& cont, std::string&& val) {
30     cont.emplace_back(val);
31 }
32
33 inline void insertToContainer(std::set<std::string>& cont, std::string&& val) {
34     cont.emplace(val);
35 }
36
37 inline void insertToContainer(std::unordered_set<std::string>& cont, std::string&& val) {
38     cont.emplace(val);
39 }
40
41 inline void insertToContainer(ie::details::caseless_set<std::string>& cont, std::string&& val) {
42     cont.emplace(val);
43 }
44
45 }  // namespace impl
46
47 template <class Cont>
48 void splitStringList(const std::string& str, Cont& out, char delim) {
49     out.clear();
50
51     if (str.empty())
52         return;
53
54     std::istringstream istr(str);
55
56     std::string elem;
57     while (std::getline(istr, elem, delim)) {
58         if (elem.empty()) {
59             continue;
60         }
61
62         impl::insertToContainer(out, std::move(elem));
63     }
64 }
65
66 }  // namespace vpu