strip_type.hpp
Go to the documentation of this file.
1 
8 #ifndef MLPACK_BINDINGS_JULIA_STRIP_TYPE_HPP
9 #define MLPACK_BINDINGS_JULIA_STRIP_TYPE_HPP
10 
11 namespace mlpack {
12 namespace bindings {
13 namespace julia {
14 
23 inline std::string StripType(std::string cppType)
24 {
25  // Basically what we need to do is strip any '<' (template bits) from the
26  // type. We'll try first by removing any instances of <>.
27  const size_t loc = cppType.find("<>");
28  if (loc != std::string::npos)
29  cppType.replace(loc, 2, "");
30 
31  // Let's just replace any invalid characters with valid '_' characters.
32  std::replace(cppType.begin(), cppType.end(), '<', '_');
33  std::replace(cppType.begin(), cppType.end(), '>', '_');
34  std::replace(cppType.begin(), cppType.end(), ' ', '_');
35  std::replace(cppType.begin(), cppType.end(), ',', '_');
36 
37  return cppType;
38 }
39 
40 } // namespace julia
41 } // namespace bindings
42 } // namespace mlpack
43 
44 #endif
strip_type.hpp
Definition: add_to_po.hpp:21
std::string StripType(std::string cppType)
Given a C++ type name, turn it into something that has no special characters that can simply be print...
Definition: strip_type.hpp:23