From 5131752402178911b41c68f77197e8ad7fbea8c9 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Wed, 31 Jul 2013 09:43:22 -0700 Subject: [PATCH] Add return value to some InputStream methods --- .../beast_core/streams/beast_InputStream.h | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/modules/beast_core/streams/beast_InputStream.h b/modules/beast_core/streams/beast_InputStream.h index 081a7b037b..2b911bf180 100644 --- a/modules/beast_core/streams/beast_InputStream.h +++ b/modules/beast_core/streams/beast_InputStream.h @@ -239,14 +239,19 @@ public: /** Reads a type using a template specialization. The variable is passed as a parameter so that the template type - can be deduced. + can be deduced. The return value indicates whether or not there + was sufficient data in the stream to read the value. - This is useful when doing template meta-programming. */ template - void readTypeInto (T* p) + bool readTypeInto (T* p) { - *p = readType (); + if (getNumBytesRemaining () >= sizeof (T)) + { + *p = readType (); + return true; + } + return false; } /** Reads a type from a big endian stream using a template specialization. @@ -262,14 +267,18 @@ public: /** Reads a type using a template specialization. The variable is passed as a parameter so that the template type - can be deduced. - - This is useful when doing template meta-programming. + can be deduced. The return value indicates whether or not there + was sufficient data in the stream to read the value. */ template - void readTypeBigEndianInto (T* p) + bool readTypeBigEndianInto (T* p) { - *p = readTypeBigEndian (); + if (getNumBytesRemaining () >= sizeof (T)) + { + *p = readTypeBigEndian (); + return true; + } + return false; } //==============================================================================