Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: base/string_number_conversions.cc

Issue 11293078: Integrating Online Wallet into Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes from latest code review Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/string_number_conversions.cc
diff --git a/base/string_number_conversions.cc b/base/string_number_conversions.cc
index e80b6499f2e04c0787a48d08f87b306e9fc3e468..c55bbafff34ae70137167283e41146fd8da50597 100644
--- a/base/string_number_conversions.cc
+++ b/base/string_number_conversions.cc
@@ -302,9 +302,22 @@ class BaseHexIteratorRangeToIntTraits
}
};
+template<typename ITERATOR>
+class BaseHexIteratorRangeToInt64Traits
+ : public BaseIteratorRangeToNumberTraits<ITERATOR, int64, 16> {
+ public:
+ // Allow parsing of 0xFFFFFFFFFFFFFFFF, which is technically an overflow
+ static uint64 max() {
+ return std::numeric_limits<uint64>::max();
+ }
+};
+
typedef BaseHexIteratorRangeToIntTraits<StringPiece::const_iterator>
HexIteratorRangeToIntTraits;
+typedef BaseHexIteratorRangeToInt64Traits<StringPiece::const_iterator>
+ HexIteratorRangeToInt64Traits;
+
template<typename STR>
bool HexStringToBytesT(const STR& input, std::vector<uint8>* output) {
DCHECK_EQ(output->size(), 0u);
@@ -481,6 +494,11 @@ bool HexStringToInt(const StringPiece& input, int* output) {
input.begin(), input.end(), output);
}
+bool HexStringToInt64(const StringPiece& input, int64* output) {
+ return IteratorRangeToNumber<HexIteratorRangeToInt64Traits>::Invoke(
+ input.begin(), input.end(), output);
+}
+
bool HexStringToBytes(const std::string& input, std::vector<uint8>* output) {
return HexStringToBytesT(input, output);
}

Powered by Google App Engine
This is Rietveld 408576698