summaryrefslogtreecommitdiffstats
path: root/base/string_util.h
diff options
context:
space:
mode:
authorerikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-27 16:11:15 +0000
committererikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-27 16:11:15 +0000
commit5d0c17fe26c9ecc7887ae976f6ee1ca7a73642da (patch)
treeda57a5847f6d6ca51766969160ec4215308008c9 /base/string_util.h
parentd39d60d7205f47ae4e9bb4a6bf0081e54fe2a2e0 (diff)
downloadchromium_src-5d0c17fe26c9ecc7887ae976f6ee1ca7a73642da.zip
chromium_src-5d0c17fe26c9ecc7887ae976f6ee1ca7a73642da.tar.gz
chromium_src-5d0c17fe26c9ecc7887ae976f6ee1ca7a73642da.tar.bz2
Add HexStringToBytes which takes an arbitrary length hex string and creates a vector of bytes.
Review URL: http://codereview.chromium.org/18814 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8716 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_util.h')
-rw-r--r--base/string_util.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/base/string_util.h b/base/string_util.h
index 68142cb..28c5d35 100644
--- a/base/string_util.h
+++ b/base/string_util.h
@@ -377,6 +377,13 @@ bool StringToInt64(const std::wstring& input, int64* output);
bool HexStringToInt(const std::string& input, int* output);
bool HexStringToInt(const std::wstring& input, int* output);
+// Similar to the previous functions, except that output is a vector of bytes.
+// |*output| will contain as many bytes as were successfully parsed prior to the
+// error. There is no overflow, but input.size() must be evenly divisible by 2.
+// Leading 0x or +/- are not allowed.
+bool HexStringToBytes(const std::string& input, std::vector<uint8>* output);
+bool HexStringToBytes(const std::wstring& input, std::vector<uint8>* output);
+
// For floating-point conversions, only conversions of input strings in decimal
// form are defined to work. Behavior with strings representing floating-point
// numbers in hexadecimal, and strings representing non-fininte values (such as