Move over to upstream c++ style

This patchset moves bmcweb over to the upstream style naming
conventions for variables, classes, and functions, as well as imposes
the latest clang-format file.

This changeset was mostly built automatically by the included
.clang-tidy file, which has the ability to autoformat and auto rename
variables.  At some point in the future I would like to see this in
greater use, but for now, we will impose it on bmcweb, and see how it
goes.

Tested: Code still compiles, and appears to run, although other issues
are possible and likely.

Change-Id: If422a2e36df924e897736b3feffa89f411d9dac1
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
diff --git a/crow/include/crow/query_string.h b/crow/include/crow/query_string.h
index 5e28e18..0606994 100644
--- a/crow/include/crow/query_string.h
+++ b/crow/include/crow/query_string.h
@@ -12,45 +12,45 @@
 // https://github.com/bartgrantham/qs_parse
 // ----------------------------------------------------------------------------
 /*  Similar to strncmp, but handles URL-encoding for either string  */
-int qs_strncmp(const char* s, const char* qs, size_t n);
+int qsStrncmp(const char* s, const char* qs, size_t n);
 
 /*  Finds the beginning of each key/value pair and stores a pointer in qs_kv.
  *  Also decodes the value portion of the k/v pair *in-place*.  In a future
  *  enhancement it will also have a compile-time option of sorting qs_kv
  *  alphabetically by key.  */
-int qs_parse(char* qs, char* qs_kv[], int qs_kv_size);
+int qsParse(char* qs, char* qs_kv[], int qs_kv_size);
 
 /*  Used by qs_parse to decode the value portion of a k/v pair  */
-int qs_decode(char* qs);
+int qsDecode(char* qs);
 
 /*  Looks up the value according to the key on a pre-processed query string
  *  A future enhancement will be a compile-time option to look up the key
  *  in a pre-sorted qs_kv array via a binary search.  */
 // char * qs_k2v(const char * key, char * qs_kv[], int qs_kv_size);
-char* qs_k2v(const char* key, char* const* qs_kv, int qs_kv_size, int nth);
+char* qsK2v(const char* key, char* const* qs_kv, int qs_kv_size, int nth);
 
 /*  Non-destructive lookup of value, based on key.  User provides the
  *  destinaton string and length.  */
-char* qs_scanvalue(const char* key, const char* qs, char* val, size_t val_len);
+char* qsScanvalue(const char* key, const char* qs, char* val, size_t val_len);
 
 // TODO: implement sorting of the qs_kv array; for now ensure it's not compiled
 #undef _qsSORTING
 
 // isxdigit _is_ available in <ctype.h>, but let's avoid another header instead
-#define CROW_QS_ISHEX(x)                                        \
+#define BMCWEB_QS_ISHEX(x)                                      \
   ((((x) >= '0' && (x) <= '9') || ((x) >= 'A' && (x) <= 'F') || \
     ((x) >= 'a' && (x) <= 'f'))                                 \
        ? 1                                                      \
        : 0)
-#define CROW_QS_HEX2DEC(x)                   \
+#define BMCWEB_QS_HEX2DEC(x)                 \
   (((x) >= '0' && (x) <= '9')                \
        ? (x)-48                              \
        : ((x) >= 'A' && (x) <= 'F') ? (x)-55 \
                                     : ((x) >= 'a' && (x) <= 'f') ? (x)-87 : 0)
-#define CROW_QS_ISQSCHR(x) \
+#define BMCWEB_QS_ISQSCHR(x) \
   ((((x) == '=') || ((x) == '#') || ((x) == '&') || ((x) == '\0')) ? 0 : 1)
 
-inline int qs_strncmp(const char* s, const char* qs, size_t n) {
+inline int qsStrncmp(const char* s, const char* qs, size_t n) {
   int i = 0;
   unsigned char u1, u2, unyb, lnyb;
 
@@ -58,10 +58,10 @@
     u1 = static_cast<unsigned char>(*s++);
     u2 = static_cast<unsigned char>(*qs++);
 
-    if (!CROW_QS_ISQSCHR(u1)) {
+    if (!BMCWEB_QS_ISQSCHR(u1)) {
       u1 = '\0';
     }
-    if (!CROW_QS_ISQSCHR(u2)) {
+    if (!BMCWEB_QS_ISQSCHR(u2)) {
       u2 = '\0';
     }
 
@@ -72,8 +72,8 @@
     {
       unyb = static_cast<unsigned char>(*s++);
       lnyb = static_cast<unsigned char>(*s++);
-      if (CROW_QS_ISHEX(unyb) && CROW_QS_ISHEX(lnyb)) {
-        u1 = (CROW_QS_HEX2DEC(unyb) * 16) + CROW_QS_HEX2DEC(lnyb);
+      if (BMCWEB_QS_ISHEX(unyb) && BMCWEB_QS_ISHEX(lnyb)) {
+        u1 = (BMCWEB_QS_HEX2DEC(unyb) * 16) + BMCWEB_QS_HEX2DEC(lnyb);
       } else {
         u1 = '\0';
       }
@@ -86,8 +86,8 @@
     {
       unyb = static_cast<unsigned char>(*qs++);
       lnyb = static_cast<unsigned char>(*qs++);
-      if (CROW_QS_ISHEX(unyb) && CROW_QS_ISHEX(lnyb)) {
-        u2 = (CROW_QS_HEX2DEC(unyb) * 16) + CROW_QS_HEX2DEC(lnyb);
+      if (BMCWEB_QS_ISHEX(unyb) && BMCWEB_QS_ISHEX(lnyb)) {
+        u2 = (BMCWEB_QS_HEX2DEC(unyb) * 16) + BMCWEB_QS_HEX2DEC(lnyb);
       } else {
         u2 = '\0';
       }
@@ -101,37 +101,37 @@
     }
     i++;
   }
-  if (CROW_QS_ISQSCHR(*qs)) {
+  if (BMCWEB_QS_ISQSCHR(*qs)) {
     return -1;
   } else {
     return 0;
   }
 }
 
-inline int qs_parse(char* qs, char* qs_kv[], int qs_kv_size) {
+inline int qsParse(char* qs, char* qs_kv[], int qs_kv_size) {
   int i, j;
-  char* substr_ptr;
+  char* substrPtr;
 
   for (i = 0; i < qs_kv_size; i++) {
     qs_kv[i] = NULL;
   }
 
   // find the beginning of the k/v substrings or the fragment
-  substr_ptr = qs + strcspn(qs, "?#");
-  if (substr_ptr[0] != '\0') {
-    substr_ptr++;
+  substrPtr = qs + strcspn(qs, "?#");
+  if (substrPtr[0] != '\0') {
+    substrPtr++;
   } else {
     return 0;  // no query or fragment
   }
 
   i = 0;
   while (i < qs_kv_size) {
-    qs_kv[i] = substr_ptr;
-    j = strcspn(substr_ptr, "&");
-    if (substr_ptr[j] == '\0') {
+    qs_kv[i] = substrPtr;
+    j = strcspn(substrPtr, "&");
+    if (substrPtr[j] == '\0') {
       break;
     }
-    substr_ptr += j + 1;
+    substrPtr += j + 1;
     i++;
   }
   i++;  // x &'s -> means x iterations of this loop -> means *x+1* k/v pairs
@@ -139,12 +139,12 @@
   // we only decode the values in place, the keys could have '='s in them
   // which will hose our ability to distinguish keys from values later
   for (j = 0; j < i; j++) {
-    substr_ptr = qs_kv[j] + strcspn(qs_kv[j], "=&#");
-    if (substr_ptr[0] == '&' ||
-        substr_ptr[0] == '\0') {  // blank value: skip decoding
-      substr_ptr[0] = '\0';
+    substrPtr = qs_kv[j] + strcspn(qs_kv[j], "=&#");
+    if (substrPtr[0] == '&' ||
+        substrPtr[0] == '\0') {  // blank value: skip decoding
+      substrPtr[0] = '\0';
     } else {
-      qs_decode(++substr_ptr);
+      qsDecode(++substrPtr);
     }
   }
 
@@ -155,19 +155,20 @@
   return i;
 }
 
-inline int qs_decode(char* qs) {
+inline int qsDecode(char* qs) {
   int i = 0, j = 0;
 
-  while (CROW_QS_ISQSCHR(qs[j])) {
+  while (BMCWEB_QS_ISQSCHR(qs[j])) {
     if (qs[j] == '+') {
       qs[i] = ' ';
     } else if (qs[j] == '%')  // easier/safer than scanf
     {
-      if (!CROW_QS_ISHEX(qs[j + 1]) || !CROW_QS_ISHEX(qs[j + 2])) {
+      if (!BMCWEB_QS_ISHEX(qs[j + 1]) || !BMCWEB_QS_ISHEX(qs[j + 2])) {
         qs[i] = '\0';
         return i;
       }
-      qs[i] = (CROW_QS_HEX2DEC(qs[j + 1]) * 16) + CROW_QS_HEX2DEC(qs[j + 2]);
+      qs[i] =
+          (BMCWEB_QS_HEX2DEC(qs[j + 1]) * 16) + BMCWEB_QS_HEX2DEC(qs[j + 2]);
       j += 2;
     } else {
       qs[i] = qs[j];
@@ -180,19 +181,19 @@
   return i;
 }
 
-inline char* qs_k2v(const char* key, char* const* qs_kv, int qs_kv_size,
-                    int nth = 0) {
+inline char* qsK2v(const char* key, char* const* qs_kv, int qs_kv_size,
+                   int nth = 0) {
   int i;
-  size_t key_len, skip;
+  size_t keyLen, skip;
 
-  key_len = strlen(key);
+  keyLen = strlen(key);
 
 #ifdef _qsSORTING
 // TODO: binary search for key in the sorted qs_kv
 #else   // _qsSORTING
   for (i = 0; i < qs_kv_size; i++) {
     // we rely on the unambiguous '=' to find the value in our k/v pair
-    if (qs_strncmp(key, qs_kv[i], key_len) == 0) {
+    if (qsStrncmp(key, qs_kv[i], keyLen) == 0) {
       skip = strcspn(qs_kv[i], "=");
       if (qs_kv[i][skip] == '=') {
         skip++;
@@ -210,9 +211,9 @@
   return NULL;
 }
 
-inline char* qs_scanvalue(const char* key, const char* qs, char* val,
-                          size_t val_len) {
-  size_t i, key_len;
+inline char* qsScanvalue(const char* key, const char* qs, char* val,
+                         size_t val_len) {
+  size_t i, keyLen;
   const char* tmp;
 
   // find the beginning of the k/v substrings
@@ -220,9 +221,9 @@
     qs = tmp + 1;
   }
 
-  key_len = strlen(key);
+  keyLen = strlen(key);
   while (qs[0] != '#' && qs[0] != '\0') {
-    if (qs_strncmp(key, qs, key_len) == 0) {
+    if (qsStrncmp(key, qs, keyLen) == 0) {
       break;
     }
     qs += strcspn(qs, "&") + 1;
@@ -237,7 +238,7 @@
     qs++;
     i = strcspn(qs, "&=#");
     strncpy(val, qs, (val_len - 1) < (i + 1) ? (val_len - 1) : (i + 1));
-    qs_decode(val);
+    qsDecode(val);
   } else {
     if (val_len > 0) {
       val[0] = '\0';
@@ -250,83 +251,81 @@
 // ----------------------------------------------------------------------------
 
 namespace crow {
-class query_string {
+class QueryString {
  public:
-  static const int MAX_KEY_VALUE_PAIRS_COUNT = 256;
+  static const int maxKeyValuePairsCount = 256;
 
-  query_string() = default;
+  QueryString() = default;
 
-  query_string(const query_string& qs) : url_(qs.url_) {
-    for (auto p : qs.key_value_pairs_) {
-      key_value_pairs_.push_back(
-          const_cast<char*>(p - qs.url_.c_str() + url_.c_str()));
+  QueryString(const QueryString& qs) : url(qs.url) {
+    for (auto p : qs.keyValuePairs) {
+      keyValuePairs.push_back(
+          const_cast<char*>(p - qs.url.c_str() + url.c_str()));
     }
   }
 
-  query_string& operator=(const query_string& qs) {
-    url_ = qs.url_;
-    key_value_pairs_.clear();
-    for (auto p : qs.key_value_pairs_) {
-      key_value_pairs_.push_back(
-          const_cast<char*>(p - qs.url_.c_str() + url_.c_str()));
+  QueryString& operator=(const QueryString& qs) {
+    url = qs.url;
+    keyValuePairs.clear();
+    for (auto p : qs.keyValuePairs) {
+      keyValuePairs.push_back(
+          const_cast<char*>(p - qs.url.c_str() + url.c_str()));
     }
     return *this;
   }
 
-  query_string& operator=(query_string&& qs) {
-    key_value_pairs_ = std::move(qs.key_value_pairs_);
-    auto* old_data = const_cast<char*>(qs.url_.c_str());
-    url_ = std::move(qs.url_);
-    for (auto& p : key_value_pairs_) {
-      p += const_cast<char*>(url_.c_str()) - old_data;
+  QueryString& operator=(QueryString&& qs) {
+    keyValuePairs = std::move(qs.keyValuePairs);
+    auto* oldData = const_cast<char*>(qs.url.c_str());
+    url = std::move(qs.url);
+    for (auto& p : keyValuePairs) {
+      p += const_cast<char*>(url.c_str()) - oldData;
     }
     return *this;
   }
 
-  explicit query_string(std::string url) : url_(std::move(url)) {
-    if (url_.empty()) {
+  explicit QueryString(std::string url) : url(std::move(url)) {
+    if (url.empty()) {
       return;
     }
 
-    key_value_pairs_.resize(MAX_KEY_VALUE_PAIRS_COUNT);
+    keyValuePairs.resize(maxKeyValuePairsCount);
 
-    int count =
-        qs_parse(&url_[0], &key_value_pairs_[0], MAX_KEY_VALUE_PAIRS_COUNT);
-    key_value_pairs_.resize(count);
+    int count = qsParse(&url[0], &keyValuePairs[0], maxKeyValuePairsCount);
+    keyValuePairs.resize(count);
   }
 
   void clear() {
-    key_value_pairs_.clear();
-    url_.clear();
+    keyValuePairs.clear();
+    url.clear();
   }
 
-  friend std::ostream& operator<<(std::ostream& os, const query_string& qs) {
+  friend std::ostream& operator<<(std::ostream& os, const QueryString& qs) {
     os << "[ ";
-    for (size_t i = 0; i < qs.key_value_pairs_.size(); ++i) {
+    for (size_t i = 0; i < qs.keyValuePairs.size(); ++i) {
       if (i != 0u) {
         os << ", ";
       }
-      os << qs.key_value_pairs_[i];
+      os << qs.keyValuePairs[i];
     }
     os << " ]";
     return os;
   }
 
   char* get(const std::string& name) const {
-    char* ret =
-        qs_k2v(name.c_str(), key_value_pairs_.data(), key_value_pairs_.size());
+    char* ret = qsK2v(name.c_str(), keyValuePairs.data(), keyValuePairs.size());
     return ret;
   }
 
-  std::vector<char*> get_list(const std::string& name) const {
+  std::vector<char*> getList(const std::string& name) const {
     std::vector<char*> ret;
     std::string plus = name + "[]";
     char* element = nullptr;
 
     int count = 0;
     while (1) {
-      element = qs_k2v(plus.c_str(), key_value_pairs_.data(),
-                       key_value_pairs_.size(), count++);
+      element = qsK2v(plus.c_str(), keyValuePairs.data(), keyValuePairs.size(),
+                      count++);
       if (element == nullptr) {
         break;
       }
@@ -336,8 +335,8 @@
   }
 
  private:
-  std::string url_;
-  std::vector<char*> key_value_pairs_;
+  std::string url;
+  std::vector<char*> keyValuePairs;
 };
 
 }  // namespace crow