Buffet: utility function tweaks

Various tweakes to helper functions and classes, split off from
a larger CL that required them.

1. Added Error::AddToPrintf to help add formatted error messages.
2. Added Error::GetFirstError to get the innermost error occurred.
3. Added string_utils::ToString and swept code using std::to_string
   in order to ensure we format doubles correctly (using %g instead
   of %f format specifier) and bool values (using "true"/"false"
   instead of 1/0).
4. Fixed C-style cast in http_utils.h and using static_cast now.
5. Fixed a few linter warnings. Also since the linter was updated
   there is no reason to have some NOLINT since many C++11 features
   are now recognized properly by cpplint.

BUG=None
TEST=All unit tests pass.

Change-Id: I208ffaa3f0ec0a5ff78bf9e8151e784ec8cd77e2
Reviewed-on: https://chromium-review.googlesource.com/202962
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Christopher Wiley <wiley@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/http_transport_fake.cc b/buffet/http_transport_fake.cc
index 0e7dfc5..471de11 100644
--- a/buffet/http_transport_fake.cc
+++ b/buffet/http_transport_fake.cc
@@ -14,6 +14,7 @@
 #include "buffet/http_connection_fake.h"
 #include "buffet/http_request.h"
 #include "buffet/mime_utils.h"
+#include "buffet/string_utils.h"
 #include "buffet/url_utils.h"
 
 namespace buffet {
@@ -128,7 +129,7 @@
 }
 
 void ServerRequestResponseBase::AddHeaders(const HeaderList& headers) {
-  for (auto&& pair : headers) {
+  for (const auto& pair : headers) {
     if (pair.second.empty())
       headers_.erase(pair.first);
     else
@@ -170,7 +171,7 @@
   status_code_ = status_code;
   AddData(data, data_size);
   AddHeaders({
-    {response_header::kContentLength, std::to_string(data_size)},
+    {response_header::kContentLength, string_utils::ToString(data_size)},
     {response_header::kContentType, mime_type}
   });
 }
@@ -194,7 +195,7 @@
 void ServerResponse::ReplyJson(int status_code,
                                const http::FormFieldList& fields) {
   base::DictionaryValue json;
-  for (auto&& pair : fields) {
+  for (const auto& pair : fields) {
     json.SetString(pair.first, pair.second);
   }
   ReplyJson(status_code, &json);
@@ -250,7 +251,7 @@
     {505, "HTTP Version Not Supported"},
   };
 
-  for (auto&& pair : status_text_map) {
+  for (const auto& pair : status_text_map) {
     if (pair.first == status_code_)
       return pair.second;
   }