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/include/web_kvm.hpp b/include/web_kvm.hpp
index 82cb488..ad4b352 100644
--- a/include/web_kvm.hpp
+++ b/include/web_kvm.hpp
@@ -8,9 +8,9 @@
 namespace crow {
 namespace kvm {
 
-static const std::string rfb_3_3_version_string = "RFB 003.003\n";
-static const std::string rfb_3_7_version_string = "RFB 003.007\n";
-static const std::string rfb_3_8_version_string = "RFB 003.008\n";
+static const std::string rfb33VersionString = "RFB 003.003\n";
+static const std::string rfb37VersionString = "RFB 003.007\n";
+static const std::string rfb38VersionString = "RFB 003.008\n";
 
 enum class RfbAuthScheme : uint8_t {
   connection_failed = 0,
@@ -18,27 +18,27 @@
   vnc_authentication = 2
 };
 
-struct pixel_format_struct {
-  boost::endian::big_uint8_t bits_per_pixel;
+struct PixelFormatStruct {
+  boost::endian::big_uint8_t bitsPerPixel;
   boost::endian::big_uint8_t depth;
-  boost::endian::big_uint8_t is_big_endian;
-  boost::endian::big_uint8_t is_true_color;
-  boost::endian::big_uint16_t red_max;
-  boost::endian::big_uint16_t green_max;
-  boost::endian::big_uint16_t blue_max;
-  boost::endian::big_uint8_t red_shift;
-  boost::endian::big_uint8_t green_shift;
-  boost::endian::big_uint8_t blue_shift;
+  boost::endian::big_uint8_t isBigEndian;
+  boost::endian::big_uint8_t isTrueColor;
+  boost::endian::big_uint16_t redMax;
+  boost::endian::big_uint16_t greenMax;
+  boost::endian::big_uint16_t blueMax;
+  boost::endian::big_uint8_t redShift;
+  boost::endian::big_uint8_t greenShift;
+  boost::endian::big_uint8_t blueShift;
   boost::endian::big_uint8_t pad1;
   boost::endian::big_uint8_t pad2;
   boost::endian::big_uint8_t pad3;
 };
 
-struct server_initialization_msg {
-  boost::endian::big_uint16_t framebuffer_width;
-  boost::endian::big_uint16_t framebuffer_height;
-  pixel_format_struct pixel_format;
-  boost::endian::big_uint32_t name_length;
+struct ServerInitializationMsg {
+  boost::endian::big_uint16_t framebufferWidth;
+  boost::endian::big_uint16_t framebufferHeight;
+  PixelFormatStruct pixelFormat;
+  boost::endian::big_uint32_t nameLength;
 };
 
 enum class client_to_server_msg_type : uint8_t {
@@ -58,35 +58,35 @@
   server_cut_text = 3
 };
 
-struct set_pixel_format_msg {
+struct SetPixelFormatMsg {
   boost::endian::big_uint8_t pad1;
   boost::endian::big_uint8_t pad2;
   boost::endian::big_uint8_t pad3;
-  pixel_format_struct pixel_format;
+  PixelFormatStruct pixelFormat;
 };
 
-struct frame_buffer_update_req {
+struct FrameBufferUpdateReq {
   boost::endian::big_uint8_t incremental;
-  boost::endian::big_uint16_t x_position;
-  boost::endian::big_uint16_t y_position;
+  boost::endian::big_uint16_t xPosition;
+  boost::endian::big_uint16_t yPosition;
   boost::endian::big_uint16_t width;
   boost::endian::big_uint16_t height;
 };
 
-struct key_event_msg {
-  boost::endian::big_uint8_t down_flag;
+struct KeyEventMsg {
+  boost::endian::big_uint8_t downFlag;
   boost::endian::big_uint8_t pad1;
   boost::endian::big_uint8_t pad2;
   boost::endian::big_uint32_t key;
 };
 
-struct pointer_event_msg {
-  boost::endian::big_uint8_t button_mask;
-  boost::endian::big_uint16_t x_position;
-  boost::endian::big_uint16_t y_position;
+struct PointerEventMsg {
+  boost::endian::big_uint8_t buttonMask;
+  boost::endian::big_uint16_t xPosition;
+  boost::endian::big_uint16_t yPosition;
 };
 
-struct client_cut_text_msg {
+struct ClientCutTextMsg {
   std::vector<uint8_t> data;
 };
 
@@ -105,7 +105,7 @@
   cache_enable = 0xFFFF0001,
   xor_enable = 0xFFFF0006,
   server_state_ultranvc = 0xFFFF8000,
-  enable_keep_alive = 0xFFFF8001,
+  enable_keepAlive = 0xFFFF8001,
   enableftp_protocol_version = 0xFFFF8002,
   tight_compress_level_0 = 0xFFFFFF00,
   tight_compress_level_9 = 0xFFFFFF09,
@@ -118,7 +118,7 @@
   tight_quality_level_9 = 0xFFFFFFE9
 };
 
-struct framebuffer_rectangle {
+struct FramebufferRectangle {
   boost::endian::big_uint16_t x{};
   boost::endian::big_uint16_t y{};
   boost::endian::big_uint16_t width{};
@@ -127,35 +127,34 @@
   std::vector<uint8_t> data;
 };
 
-struct framebuffer_update_msg {
-  boost::endian::big_uint8_t message_type{};
-  std::vector<framebuffer_rectangle> rectangles;
+struct FramebufferUpdateMsg {
+  boost::endian::big_uint8_t messageType{};
+  std::vector<FramebufferRectangle> rectangles;
 };
 
-inline std::string serialize(const framebuffer_update_msg& msg) {
+inline std::string serialize(const FramebufferUpdateMsg& msg) {
   // calculate the size of the needed vector for serialization
-  size_t vector_size = 4;
+  size_t vectorSize = 4;
   for (const auto& rect : msg.rectangles) {
-    vector_size += 12 + rect.data.size();
+    vectorSize += 12 + rect.data.size();
   }
 
-  std::string serialized(vector_size, 0);
+  std::string serialized(vectorSize, 0);
 
   size_t i = 0;
   serialized[i++] = static_cast<char>(
       server_to_client_message_type::framebuffer_update);  // Type
   serialized[i++] = 0;                                     // Pad byte
-  boost::endian::big_uint16_t number_of_rectangles = msg.rectangles.size();
-  std::memcpy(&serialized[i], &number_of_rectangles,
-              sizeof(number_of_rectangles));
-  i += sizeof(number_of_rectangles);
+  boost::endian::big_uint16_t numberOfRectangles = msg.rectangles.size();
+  std::memcpy(&serialized[i], &numberOfRectangles, sizeof(numberOfRectangles));
+  i += sizeof(numberOfRectangles);
 
   for (const auto& rect : msg.rectangles) {
     // copy the first part of the struct
-    size_t buffer_size =
-        sizeof(framebuffer_rectangle) - sizeof(std::vector<uint8_t>);
-    std::memcpy(&serialized[i], &rect, buffer_size);
-    i += buffer_size;
+    size_t bufferSize =
+        sizeof(FramebufferRectangle) - sizeof(std::vector<uint8_t>);
+    std::memcpy(&serialized[i], &rect, bufferSize);
+    i += bufferSize;
 
     std::memcpy(&serialized[i], rect.data.data(), rect.data.size());
     i += rect.data.size();
@@ -172,91 +171,90 @@
   MAIN_LOOP
 };
 
-class connection_metadata {
+class ConnectionMetadata {
  public:
-  connection_metadata() {};
+  ConnectionMetadata(){};
 
-  VncState vnc_state{VncState::UNSTARTED};
+  VncState vncState{VncState::UNSTARTED};
 };
 
-using meta_list = std::vector<connection_metadata>;
-meta_list connection_states(10);
+using meta_list = std::vector<ConnectionMetadata>;
+meta_list connectionStates(10);
 
-connection_metadata meta;
+ConnectionMetadata meta;
 
 template <typename... Middlewares>
-void request_routes(Crow<Middlewares...>& app) {
-  CROW_ROUTE(app, "/kvmws")
+void requestRoutes(Crow<Middlewares...>& app) {
+  BMCWEB_ROUTE(app, "/kvmws")
       .websocket()
-      .onopen([&](crow::websocket::connection& conn) {
-        if (meta.vnc_state == VncState::UNSTARTED) {
-          meta.vnc_state = VncState::AWAITING_CLIENT_VERSION;
-          conn.send_binary(rfb_3_8_version_string);
+      .onopen([&](crow::websocket::Connection& conn) {
+        if (meta.vncState == VncState::UNSTARTED) {
+          meta.vncState = VncState::AWAITING_CLIENT_VERSION;
+          conn.sendBinary(rfb38VersionString);
         } else {  // SHould never happen
           conn.close();
         }
 
       })
       .onclose(
-          [&](crow::websocket::connection& conn, const std::string& reason) {
-            meta.vnc_state = VncState::UNSTARTED;
+          [&](crow::websocket::Connection& conn, const std::string& reason) {
+            meta.vncState = VncState::UNSTARTED;
           })
-      .onmessage([&](crow::websocket::connection& conn, const std::string& data,
+      .onmessage([&](crow::websocket::Connection& conn, const std::string& data,
                      bool is_binary) {
-        switch (meta.vnc_state) {
+        switch (meta.vncState) {
           case VncState::AWAITING_CLIENT_VERSION: {
             std::cout << "Client sent: " << data;
-            if (data == rfb_3_8_version_string ||
-                data == rfb_3_7_version_string) {
-              std::string auth_types{1,
-                                     (uint8_t)RfbAuthScheme::no_authentication};
-              conn.send_binary(auth_types);
-              meta.vnc_state = VncState::AWAITING_CLIENT_AUTH_METHOD;
-            } else if (data == rfb_3_3_version_string) {
+            if (data == rfb38VersionString || data == rfb37VersionString) {
+              std::string authTypes{1,
+                                    (uint8_t)RfbAuthScheme::no_authentication};
+              conn.sendBinary(authTypes);
+              meta.vncState = VncState::AWAITING_CLIENT_AUTH_METHOD;
+            } else if (data == rfb33VersionString) {
               // TODO(ed)  Support older protocols
-              meta.vnc_state = VncState::UNSTARTED;
+              meta.vncState = VncState::UNSTARTED;
               conn.close();
             } else {
               // TODO(ed)  Support older protocols
-              meta.vnc_state = VncState::UNSTARTED;
+              meta.vncState = VncState::UNSTARTED;
               conn.close();
             }
           } break;
           case VncState::AWAITING_CLIENT_AUTH_METHOD: {
-            std::string security_result{{0, 0, 0, 0}};
+            std::string securityResult{{0, 0, 0, 0}};
             if (data[0] == (uint8_t)RfbAuthScheme::no_authentication) {
-              meta.vnc_state = VncState::AWAITING_CLIENT_INIT_msg;
+              meta.vncState = VncState::AWAITING_CLIENT_INIT_msg;
             } else {
               // Mark auth as failed
-              security_result[3] = 1;
-              meta.vnc_state = VncState::UNSTARTED;
+              securityResult[3] = 1;
+              meta.vncState = VncState::UNSTARTED;
             }
-            conn.send_binary(security_result);
+            conn.sendBinary(securityResult);
           } break;
           case VncState::AWAITING_CLIENT_INIT_msg: {
             // Now send the server initialization
-            server_initialization_msg server_init_msg{};
-            server_init_msg.framebuffer_width = 800;
-            server_init_msg.framebuffer_height = 600;
-            server_init_msg.pixel_format.bits_per_pixel = 32;
-            server_init_msg.pixel_format.is_big_endian = 0;
-            server_init_msg.pixel_format.is_true_color = 1;
-            server_init_msg.pixel_format.red_max = 255;
-            server_init_msg.pixel_format.green_max = 255;
-            server_init_msg.pixel_format.blue_max = 255;
-            server_init_msg.pixel_format.red_shift = 16;
-            server_init_msg.pixel_format.green_shift = 8;
-            server_init_msg.pixel_format.blue_shift = 0;
-            server_init_msg.name_length = 0;
-            std::cout << "size: " << sizeof(server_init_msg);
+            ServerInitializationMsg serverInitMsg{};
+            serverInitMsg.framebufferWidth = 800;
+            serverInitMsg.framebufferHeight = 600;
+            serverInitMsg.pixelFormat.bitsPerPixel = 32;
+            serverInitMsg.pixelFormat.isBigEndian = 0;
+            serverInitMsg.pixelFormat.isTrueColor = 1;
+            serverInitMsg.pixelFormat.redMax = 255;
+            serverInitMsg.pixelFormat.greenMax = 255;
+            serverInitMsg.pixelFormat.blueMax = 255;
+            serverInitMsg.pixelFormat.redShift = 16;
+            serverInitMsg.pixelFormat.greenShift = 8;
+            serverInitMsg.pixelFormat.blueShift = 0;
+            serverInitMsg.nameLength = 0;
+            std::cout << "size: " << sizeof(serverInitMsg);
             // TODO(ed) this is ugly.  Crow should really have a span type
             // interface
             // to avoid the copy, but alas, today it does not.
-            std::string s(reinterpret_cast<char*>(&server_init_msg),
-                          sizeof(server_init_msg));
+            std::string s(reinterpret_cast<char*>(&serverInitMsg),
+                          sizeof(serverInitMsg));
             std::cout << "s.size() " << s.size();
-            conn.send_binary(s);
-            meta.vnc_state = VncState::MAIN_LOOP;
+            conn.sendBinary(s);
+            meta.vncState = VncState::MAIN_LOOP;
           } break;
           case VncState::MAIN_LOOP: {
             if (data.size() >= sizeof(client_to_server_msg_type)) {
@@ -274,55 +272,54 @@
                 case client_to_server_msg_type::framebuffer_update_request: {
                   // Make sure the buffer is long enough to handle what we're
                   // about to do
-                  if (data.size() >= sizeof(frame_buffer_update_req) +
+                  if (data.size() >= sizeof(FrameBufferUpdateReq) +
                                          sizeof(client_to_server_msg_type)) {
-                    auto msg = reinterpret_cast<const frame_buffer_update_req*>(
-                        data.data() +   // NOLINT
+                    auto msg = reinterpret_cast<const FrameBufferUpdateReq*>(
+                        data.data() +  // NOLINT
                         sizeof(client_to_server_msg_type));
                     // TODO(ed) find a better way to do this deserialization
 
                     // Todo(ed) lifecycle of the video puller and decoder
                     // should be
                     // with the websocket, not recreated every time
-                    AstVideo::SimpleVideoPuller p;
+                    ast_video::SimpleVideoPuller p;
                     p.initialize();
-                    auto out = p.read_video();
-                    AstVideo::AstJpegDecoder d;
+                    auto out = p.readVideo();
+                    ast_video::AstJpegDecoder d;
                     d.decode(out.buffer, out.width, out.height, out.mode,
-                             out.y_selector, out.uv_selector);
+                             out.ySelector, out.uvSelector);
 
-                    framebuffer_update_msg buffer_update_msg;
+                    FramebufferUpdateMsg bufferUpdateMsg;
 
                     // If the viewer is requesting a full update, force write
                     // of all pixels
 
-                    framebuffer_rectangle this_rect;
-                    this_rect.x = msg->x_position;
-                    this_rect.y = msg->y_position;
-                    this_rect.width = out.width;
-                    this_rect.height = out.height;
-                    this_rect.encoding =
+                    FramebufferRectangle thisRect;
+                    thisRect.x = msg->xPosition;
+                    thisRect.y = msg->yPosition;
+                    thisRect.width = out.width;
+                    thisRect.height = out.height;
+                    thisRect.encoding =
                         static_cast<uint8_t>(encoding_type::raw);
-                    std::cout << "Encoding is " << this_rect.encoding;
-                    this_rect.data.reserve(
-                        static_cast<std::size_t>(this_rect.width) *
-                        static_cast<std::size_t>(this_rect.height) * 4);
+                    std::cout << "Encoding is " << thisRect.encoding;
+                    thisRect.data.reserve(
+                        static_cast<std::size_t>(thisRect.width) *
+                        static_cast<std::size_t>(thisRect.height) * 4);
                     std::cout << "Width " << out.width << " Height "
                               << out.height;
 
                     for (int i = 0; i < out.width * out.height; i++) {
-                      auto& pixel = d.OutBuffer[i];
-                      this_rect.data.push_back(pixel.B);
-                      this_rect.data.push_back(pixel.G);
-                      this_rect.data.push_back(pixel.R);
-                      this_rect.data.push_back(0);
+                      auto& pixel = d.outBuffer[i];
+                      thisRect.data.push_back(pixel.b);
+                      thisRect.data.push_back(pixel.g);
+                      thisRect.data.push_back(pixel.r);
+                      thisRect.data.push_back(0);
                     }
 
-                    buffer_update_msg.rectangles.push_back(
-                        std::move(this_rect));
-                    auto serialized = serialize(buffer_update_msg);
+                    bufferUpdateMsg.rectangles.push_back(std::move(thisRect));
+                    auto serialized = serialize(bufferUpdateMsg);
 
-                    conn.send_binary(serialized);
+                    conn.sendBinary(serialized);
 
                   }  // TODO(Ed) handle error