Fiber-local context
[folly.git] / folly / Conv.cpp
index 4f825829cc46fae7e3bdc629b925c5f876a75b9e..57b1aeef718e2d0d00ccc87e43c92e791f9ba5f8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2015 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -46,8 +46,7 @@ static_assert(sizeof(unsigned long long) >= 8,
               "Wrong value for MaxString<unsigned long long>::value"
               ", please update.");
 
-/* Test for GCC >= 3.6.0 */
-#if __GNUC__ > 3 || (__GNUC__ == 3 && (__GNUC_MINOR__ >= 6))
+#ifdef FOLLY_HAVE_INT128_T
 template <> const char *const MaxString<__uint128_t>::value =
   "340282366920938463463374607431768211455";
 #endif
@@ -72,8 +71,8 @@ inline bool bool_str_cmp(const char** b, size_t len, const char* value) {
 bool str_to_bool(StringPiece* src) {
   auto b = src->begin(), e = src->end();
   for (;; ++b) {
-    FOLLY_RANGE_CHECK(b < e,
-                      "No non-whitespace characters found in input string");
+    FOLLY_RANGE_CHECK_STRINGPIECE(
+      b < e, "No non-whitespace characters found in input string", *src);
     if (!isspace(*b)) break;
   }
 
@@ -86,8 +85,8 @@ bool str_to_bool(StringPiece* src) {
       StringPiece tmp(*src);
       uint8_t value = to<uint8_t>(&tmp);
       // Only accept 0 or 1
-      FOLLY_RANGE_CHECK(value <= 1,
-                        "Integer overflow when parsing bool: must be 0 or 1");
+      FOLLY_RANGE_CHECK_STRINGPIECE(
+        value <= 1, "Integer overflow when parsing bool: must be 0 or 1", *src);
       b = tmp.begin();
       result = (value == 1);
       break;
@@ -127,11 +126,11 @@ bool str_to_bool(StringPiece* src) {
       } else if (bool_str_cmp(&b, len, "off")) {
         result = false;
       } else {
-        FOLLY_RANGE_CHECK(false, "Invalid value for bool");
+        FOLLY_RANGE_CHECK_STRINGPIECE(false, "Invalid value for bool", *src);
       }
       break;
     default:
-      FOLLY_RANGE_CHECK(false, "Invalid value for bool");
+      FOLLY_RANGE_CHECK_STRINGPIECE(false, "Invalid value for bool", *src);
   }
 
   src->assign(b, e);