From 9c9e4b1942b2bb7bb80d0317f40488a4cf1f9b9a Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 20 Feb 2014 19:51:04 +0100 Subject: Add SvStream::ReadCharAsBool Change-Id: I9dc0525e04de5ae79205872b779dcd0115a9cc14 --- tools/source/stream/stream.cxx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tools') diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx index ea34d30fedf9..acd48dd1e653 100644 --- a/tools/source/stream/stream.cxx +++ b/tools/source/stream/stream.cxx @@ -1004,6 +1004,30 @@ SvStream& SvStream::ReadUChar( unsigned char& r ) return *this; } +SvStream& SvStream::ReadCharAsBool( bool& r ) +{ + if( (bIoRead || !bIsConsistent) && + sizeof(char) <= nBufFree ) + { + SAL_WARN_IF( + *pBufPos > 1, "tools.stream", unsigned(*pBufPos) << " not 0/1"); + r = *pBufPos != 0; + nBufActualPos += sizeof(char); + pBufPos += sizeof(char); + nBufFree -= sizeof(char); + } + else + { + unsigned char c; + if (Read(&c, 1) == 1) + { + SAL_WARN_IF(c > 1, "tools.stream", unsigned(c) << " not 0/1"); + r = c != 0; + } + } + return *this; +} + SvStream& SvStream::ReadFloat(float& r) { float n = 0; -- cgit