mlpack 3.4.2
strip_type.hpp
Go to the documentation of this file.
1
13#ifndef MLPACK_BINDINGS_GO_STRIP_TYPE_HPP
14#define MLPACK_BINDINGS_GO_STRIP_TYPE_HPP
15
16namespace mlpack {
17namespace bindings {
18namespace go {
19
30inline void StripType(const std::string& inputType,
31 std::string& goStrippedType,
32 std::string& strippedType,
33 std::string& printedType,
34 std::string& defaultsType)
35{
36 // First, we have to parse the type. If we have something like, e.g.,
37 // 'LogisticRegression<>', we must convert this to 'LogisticRegression<T>.'
38 goStrippedType = inputType;
39 printedType = inputType;
40 strippedType = inputType;
41 defaultsType = inputType;
42
43 // Lower the first letter of parameter name so it is
44 // of unexported type in GoDoc.
45 for (size_t i = 0; i < goStrippedType.size(); i++)
46 {
47 goStrippedType[i] = std::tolower(goStrippedType[i]);
48 if (std::isupper(goStrippedType[i+1]) && !std::isupper(goStrippedType[i+2]))
49 {
50 if (isalpha(goStrippedType[i+2]))
51 break;
52 }
53 }
54
55 if (printedType.find("<") != std::string::npos)
56 {
57 // Are there any template parameters? Or is it the default?
58 const size_t loc = printedType.find("<>");
59 if (loc != std::string::npos)
60 {
61 // Convert it from "<>".
62 goStrippedType.replace(loc, 2, "");
63 strippedType.replace(loc, 2, "");
64 printedType.replace(loc, 2, "<>");
65 defaultsType.replace(loc, 2, "<T>");
66 }
67 }
68}
69
70} // namespace go
71} // namespace bindings
72} // namespace mlpack
73
74#endif
go
Definition: CMakeLists.txt:6
void StripType(const std::string &inputType, std::string &goStrippedType, std::string &strippedType, std::string &printedType, std::string &defaultsType)
Given an input type like, e.g., "LogisticRegression<>", return four types that can be used in Go code...
Definition: strip_type.hpp:30
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1