blockfactory  0.8
A framework for wrapping algorithms for dataflow programming
ConvertStdVector.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * GNU Lesser General Public License v2.1 or any later version.
7  */
8 
9 #ifndef BLOCKFACTORY_CORE_CONVERTSTDVECTOR_H
10 #define BLOCKFACTORY_CORE_CONVERTSTDVECTOR_H
11 
12 #include <string>
13 #include <vector>
14 
15 // Details about templates in http://drake.mit.edu/cxx_inl.html
16 
17 // Template declaration
18 // ====================
19 
20 // Its definition will be in the cpp file. This is allowed because all the allowed variant are
21 // either explicitly declared or explicitly specialized.
22 namespace blockfactory {
23  namespace core {
24  template <typename Tin, typename Tout>
25  void convertStdVector(const std::vector<Tin>& input, std::vector<Tout>& output);
26  } // namespace core
27 } // namespace blockfactory
28 
29 // Explicit declaration for all the other supported types
30 // ========================================================
31 
32 // Int to other numeric types
33 extern template void blockfactory::core::convertStdVector<int, int>(const std::vector<int>& input,
34  std::vector<int>& output);
35 extern template void blockfactory::core::convertStdVector<int, bool>(const std::vector<int>& input,
36  std::vector<bool>& output);
37 extern template void
38 blockfactory::core::convertStdVector<int, double>(const std::vector<int>& input,
39  std::vector<double>& output);
40 // Bool to other numeric types
41 extern template void
42 blockfactory::core::convertStdVector<bool, bool>(const std::vector<bool>& input,
43  std::vector<bool>& output);
44 extern template void blockfactory::core::convertStdVector<bool, int>(const std::vector<bool>& input,
45  std::vector<int>& output);
46 extern template void
47 blockfactory::core::convertStdVector<bool, double>(const std::vector<bool>& input,
48  std::vector<double>& output);
49 // Double to other numeric types
50 extern template void
51 blockfactory::core::convertStdVector<double, double>(const std::vector<double>& input,
52  std::vector<double>& output);
53 extern template void
54 blockfactory::core::convertStdVector<double, int>(const std::vector<double>& input,
55  std::vector<int>& output);
56 extern template void
57 blockfactory::core::convertStdVector<double, bool>(const std::vector<double>& input,
58  std::vector<bool>& output);
59 // String to string
60 extern template void blockfactory::core::convertStdVector<std::string, std::string>(
61  const std::vector<std::string>& input,
62  std::vector<std::string>& output);
63 
64 // Explicit specialization for std::string type
65 // ============================================
66 
67 namespace blockfactory {
68  namespace core {
69  // String to numeric
70  template <>
71  void convertStdVector<std::string, int>(const std::vector<std::string>& input,
72  std::vector<int>& output);
73  template <>
74  void convertStdVector<std::string, bool>(const std::vector<std::string>& input,
75  std::vector<bool>& output);
76  template <>
77  void convertStdVector<std::string, double>(const std::vector<std::string>& input,
78  std::vector<double>& output);
79  // Numeric to string
80  template <>
81  void convertStdVector<int, std::string>(const std::vector<int>& input,
82  std::vector<std::string>& output);
83  template <>
84  void convertStdVector<bool, std::string>(const std::vector<bool>& input,
85  std::vector<std::string>& output);
86  template <>
87  void convertStdVector<double, std::string>(const std::vector<double>& input,
88  std::vector<std::string>& output);
89  } // namespace core
90 } // namespace blockfactory
91 
92 #endif // BLOCKFACTORY_CORE_CONVERTSTDVECTOR_H
Definition: Block.h:17
void convertStdVector(const std::vector< Tin > &input, std::vector< Tout > &output)