strip_type.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_BINDINGS_PYTHON_STRIP_TYPE_HPP
14 #define MLPACK_BINDINGS_PYTHON_STRIP_TYPE_HPP
15 
16 namespace mlpack {
17 namespace bindings {
18 namespace python {
19 
28 inline void StripType(const std::string& inputType,
29  std::string& strippedType,
30  std::string& printedType,
31  std::string& defaultsType)
32 {
33  // First, we have to parse the type. If we have something like, e.g.,
34  // 'LogisticRegression<>', we must convert this to 'LogisticRegression[T=*].'
35  printedType = inputType;
36  strippedType = inputType;
37  defaultsType = inputType;
38  if (printedType.find("<") != std::string::npos)
39  {
40  // Are there any template parameters? Or is it the default?
41  const size_t loc = printedType.find("<>");
42  if (loc != std::string::npos)
43  {
44  // Convert it from "<>".
45  strippedType.replace(loc, 2, "");
46  printedType.replace(loc, 2, "[]");
47  defaultsType.replace(loc, 2, "[T=*]");
48  }
49  }
50 }
51 
52 } // namespace python
53 } // namespace bindings
54 } // namespace mlpack
55 
56 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
python
Definition: CMakeLists.txt:7
void StripType(const std::string &inputType, std::string &strippedType, std::string &printedType, std::string &defaultsType)
Given an input type like, e.g., "LogisticRegression<>", return three types that can be used in Python...
Definition: strip_type.hpp:28