diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-12-14 22:52:07 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-12-15 12:22:49 +0000 |
commit | 66c3655a07e109d88183002192410bcc9866c0f2 (patch) | |
tree | 019188e9165edc40641dd5a6836e94a64529c5d7 /tools/inc | |
parent | ace8398c5782caf6c5d9066b8e67afa652448954 (diff) |
convert ReadCString from ByteString to OString
Nobody ever checked the return value anyway, so just return the string
and use the stream state bits if necessary to find failures.
Doesn't need to be a member, make a standalone function
Rename it to read_zeroTerminated_uInt8s_AsO[U]String, stupid perhaps,
but *shrug*, unambiguous.
Drop misleading overloaded String variants use:
read_zeroTerminated_uInt8s_AsOString or
read_zeroTerminated_uInt8s_AsOUString
added a unit test, valgrinded it, found and fixed invalid read
in original implementation.
Diffstat (limited to 'tools/inc')
-rw-r--r-- | tools/inc/tools/stream.hxx | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx index bf884a13ddbd..5dca30fdb264 100644 --- a/tools/inc/tools/stream.hxx +++ b/tools/inc/tools/stream.hxx @@ -385,12 +385,6 @@ public: // next Tell() <= nSize sal_Bool SetStreamSize( sal_Size nSize ); - /// Read in the stream to a zero character and put all - /// read chracters in the Bytestring. The String interface - /// convert the BytString with the given encoding to a String - sal_Bool ReadCString( ByteString& rStr ); - sal_Bool ReadCString( String& rStr, rtl_TextEncoding eToEncode ); - sal_Bool ReadLine( ByteString& rStr ); sal_Bool ReadLine( rtl::OString& rStr ); sal_Bool WriteLine( const ByteString& rStr ); @@ -559,6 +553,13 @@ TOOLS_DLLPUBLIC rtl::OString read_uInt8s_AsOString(SvStream& rStr, sal_Size nLen //rtl::OUString's length is number of units successfully read TOOLS_DLLPUBLIC rtl::OUString read_LEuInt16s_AsOUString(SvStream& rStr, sal_Size nLen); +//Attempt to read 8bit units to an OString until a zero terminator is encountered +TOOLS_DLLPUBLIC rtl::OString read_zeroTerminated_uInt8s_AsOString(SvStream& rStr); + +//Attempt to read 8bit units assuming source encoding eEnc to an OUString until +//a zero terminator is encountered +TOOLS_DLLPUBLIC rtl::OUString read_zeroTerminated_uInt8s_AsOUString(SvStream& rStr, rtl_TextEncoding eEnc); + // -------------- // - FileStream - // -------------- |