diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-02-20 19:51:04 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-02-20 19:51:43 +0100 |
commit | 9c9e4b1942b2bb7bb80d0317f40488a4cf1f9b9a (patch) | |
tree | f4bc483482c92573c53d86e7cd53b033e0c87253 /tools | |
parent | 5dcb634dcbc5816e4b61e14ce2f05395e52ac5bf (diff) |
Add SvStream::ReadCharAsBool
Change-Id: I9dc0525e04de5ae79205872b779dcd0115a9cc14
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/stream/stream.cxx | 24 |
1 files changed, 24 insertions, 0 deletions
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; |