camel_case.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_BINDINGS_GO_CAMEL_CASE_HPP
14 #define MLPACK_BINDINGS_GO_CAMEL_CASE_HPP
15 
16 namespace mlpack {
17 namespace bindings {
18 namespace go {
19 
28 inline std::string CamelCase(std::string s, bool lower)
29 {
30  if (!lower)
31  s[0] = std::toupper(s[0]);
32  else
33  s[0] = std::tolower(s[0]);
34  size_t n = s.length();
35  size_t resInd = 0;
36  for (size_t i = 0; i < n; i++)
37  {
38  // Check for spaces in the sentence.
39  if (s[i] == '_')
40  {
41  // Conversion into upper case.
42  s[i + 1] = toupper(s[i + 1]);
43  continue;
44  }
45  // If not space, copy character.
46  else
47  s[resInd++] = s[i];
48  }
49  // Return string to main.
50  return s.substr(0, resInd);
51 }
52 
53 } // namespace go
54 } // namespace bindings
55 } // namespace mlpack
56 
57 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: add_to_po.hpp:21
std::string CamelCase(std::string s, bool lower)
Given an snake_case like, e.g., "logistic_regression", return CamelCase(e.g.
Definition: camel_case.hpp:28