summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-02-20 19:51:04 +0100
committerStephan Bergmann <sbergman@redhat.com>2014-02-20 19:51:43 +0100
commit9c9e4b1942b2bb7bb80d0317f40488a4cf1f9b9a (patch)
treef4bc483482c92573c53d86e7cd53b033e0c87253 /tools
parent5dcb634dcbc5816e4b61e14ce2f05395e52ac5bf (diff)
Add SvStream::ReadCharAsBool
Change-Id: I9dc0525e04de5ae79205872b779dcd0115a9cc14
Diffstat (limited to 'tools')
-rw-r--r--tools/source/stream/stream.cxx24
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;