mlpack  3.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
camel_case.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_BINDINGS_UTIL_CAMEL_CASE_HPP
13 #define MLPACK_BINDINGS_UTIL_CAMEL_CASE_HPP
14 
15 namespace mlpack {
16 namespace util {
17 
26 inline std::string CamelCase(std::string s, bool lower)
27 {
28  if (!lower)
29  s[0] = std::toupper(s[0]);
30  else
31  s[0] = std::tolower(s[0]);
32  size_t n = s.length();
33  size_t resInd = 0;
34  for (size_t i = 0; i < n; i++)
35  {
36  // Check for spaces in the sentence.
37  if (s[i] == '_')
38  {
39  // Conversion into upper case.
40  s[i + 1] = toupper(s[i + 1]);
41  continue;
42  }
43  // If not space, copy character.
44  else
45  s[resInd++] = s[i];
46  }
47  // Return string to main.
48  return s.substr(0, resInd);
49 }
50 
51 } // namespace util
52 } // namespace mlpack
53 
54 #endif
std::string CamelCase(std::string s, bool lower)
Given an snake_case like, e.g., &quot;logistic_regression&quot;, return CamelCase(e.g.
Definition: camel_case.hpp:26
src mlpack core util version hpp VERSION_HPP_CONTENTS string(REGEX REPLACE".*#define MLPACK_VERSION_MAJOR ([0-9]+).*""\\1"MLPACK_VERSION_MAJOR"${VERSION_HPP_CONTENTS}") string(REGEX REPLACE".* MLPACK_VERSION_MINOR "$
Definition: CMakeLists.txt:79