aboutsummaryrefslogtreecommitdiff
path: root/source/Utility/StringExtractor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Utility/StringExtractor.cpp')
-rw-r--r--source/Utility/StringExtractor.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/source/Utility/StringExtractor.cpp b/source/Utility/StringExtractor.cpp
index 6302c033c0c1..ae92704668fc 100644
--- a/source/Utility/StringExtractor.cpp
+++ b/source/Utility/StringExtractor.cpp
@@ -120,19 +120,30 @@ StringExtractor::DecodeHexU8()
//----------------------------------------------------------------------
// Extract an unsigned character from two hex ASCII chars in the packet
-// string
+// string, or return fail_value on failure
//----------------------------------------------------------------------
uint8_t
StringExtractor::GetHexU8 (uint8_t fail_value, bool set_eof_on_fail)
{
+ // On success, fail_value will be overwritten with the next
+ // character in the stream
+ GetHexU8Ex(fail_value, set_eof_on_fail);
+ return fail_value;
+}
+
+bool
+StringExtractor::GetHexU8Ex (uint8_t& ch, bool set_eof_on_fail)
+{
int byte = DecodeHexU8();
if (byte == -1)
{
if (set_eof_on_fail || m_index >= m_packet.size())
m_index = UINT64_MAX;
- return fail_value;
+ // ch should not be changed in case of failure
+ return false;
}
- return (uint8_t)byte;
+ ch = (uint8_t)byte;
+ return true;
}
uint32_t