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/string_utils.h b/buffet/string_utils.h
index 95da72d..e29675b 100644
--- a/buffet/string_utils.h
+++ b/buffet/string_utils.h
@@ -36,6 +36,20 @@
 std::string Join(const std::string& delimiter,
                  const std::string& str1, const std::string& str2);
 
+// string_utils::ToString() is a helper function to convert any scalar type
+// to a string. In most cases, it redirects the call to std::to_string with
+// two exceptions: for std::string itself and for double and bool.
+template<typename T>
+inline std::string ToString(T value) { return std::to_string(value); }
+// Having the following overload is handy for templates where the type
+// of template parameter isn't known and could be a string itself.
+inline std::string ToString(std::string value) { return value; }
+// We overload this for double because std::to_string(double) uses %f to
+// format the value and I would like to use a shorter %g format instead.
+std::string ToString(double value);
+// And the bool to be converted as true/false instead of 1/0.
+std::string ToString(bool value);
+
 }  // namespace string_utils
 }  // namespace buffet