diff options
author | Noel Grandin <noel@peralex.com> | 2014-01-08 08:48:26 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-01-10 13:26:15 +0000 |
commit | de84529b55f5b295b089043a7119d6b0d8b92408 (patch) | |
tree | cb6f17ce4d431f3811b60deb99763225b3d93ed4 /include/tools | |
parent | 14c8638a82624bafaa4d16fc41d7c2c1984ecad3 (diff) |
Clang plugin to re-write SvStream operator<< to non-overloaded methods
Use a clang rewriter to rewrite SvStream::operator<< to methods
like WriteUInt32.
Note that the rewriter is not perfect, and hand-tweaking the output
is necessary.
Change-Id: I0291c8192ca74d6334ed3cf8cb713212b2f0c67d
Reviewed-on: https://gerrit.libreoffice.org/7307
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'include/tools')
-rw-r--r-- | include/tools/stream.hxx | 91 |
1 files changed, 76 insertions, 15 deletions
diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx index e390407a274e..7551a59d0dc0 100644 --- a/include/tools/stream.hxx +++ b/include/tools/stream.hxx @@ -315,24 +315,57 @@ public: SvStream& operator>>( double& rDouble ); SvStream& operator>>( SvStream& rStream ); - SvStream& operator<<( sal_uInt16 nUInt16 ); - SvStream& operator<<( sal_uInt32 nUInt32 ); - SvStream& operator<<( sal_uInt64 nuInt64 ); - SvStream& operator<<( sal_Int16 nInt16 ); - SvStream& operator<<( sal_Int32 nInt32 ); + SvStream& operator<<( sal_uInt16 nUInt16 ) + { return WriteUInt16(nUInt16); } + SvStream& operator<<( sal_uInt32 nUInt32 ) + { return WriteUInt32(nUInt32); } + SvStream& operator<<( sal_uInt64 nuInt64 ) + { return WriteUInt64(nuInt64); } + SvStream& operator<<( sal_Int16 nInt16 ) + { return WriteInt16(nInt16); } + SvStream& operator<<( sal_Int32 nInt32 ) + { return WriteInt32(nInt32); } SvStream& operator<<( sal_Int64 nInt64 ) SAL_DELETED_FUNCTION; - SvStream& WriteInt64(sal_Int64 nInt64); - SvStream& operator<<( bool b ) { return operator<<(static_cast< sal_Bool >(b)); } - SvStream& operator<<( signed char nChar ); - SvStream& operator<<( char nChar ); - SvStream& operator<<( unsigned char nChar ); - SvStream& operator<<( float nFloat ); - SvStream& operator<<( const double& rDouble ); - SvStream& operator<<( const char* pBuf ); - SvStream& operator<<( const unsigned char* pBuf ); - SvStream& operator<<( SvStream& rStream ); + SvStream& operator<<( signed char nChar ) + { return WriteSChar(nChar); } + SvStream& operator<<( char nChar ) + { return WriteChar(nChar); } + SvStream& operator<<( unsigned char nChar ) + { return WriteUChar(nChar); } + SvStream& operator<<( float nFloat ) + { return WriteFloat(nFloat); } + SvStream& operator<<( const double& rDouble ) + { return WriteDouble(rDouble); } + SvStream& operator<<( const char* pBuf ) + { return WriteCharPtr(pBuf); } + SvStream& operator<<( const unsigned char* pBuf ) + { return WriteUCharPtr(pBuf); } + SvStream& operator<<( SvStream& rStream ) + { return WriteStream(rStream); } + + SvStream& WriteUInt16( sal_uInt16 nUInt16 ); + SvStream& WriteUInt32( sal_uInt32 nUInt32 ); + SvStream& WriteUInt64( sal_uInt64 nuInt64 ); + SvStream& WriteInt16( sal_Int16 nInt16 ); + SvStream& WriteInt32( sal_Int32 nInt32 ); + SvStream& WriteInt64( sal_Int64 nInt64 ); + SvStream& WriteUInt8( sal_uInt8 nuInt8 ); + SvStream& WriteUnicode( sal_Unicode ); + SvStream& WriteOString(const OString& rStr) + { return WriteCharPtr(rStr.getStr()); } + SvStream& WriteStream( SvStream& rStream ); + + SvStream& WriteBool( bool b ) + { return WriteUChar(static_cast< sal_Bool >(b)); } + SvStream& WriteSChar( signed char nChar ); + SvStream& WriteChar( char nChar ); + SvStream& WriteUChar( unsigned char nChar ); + SvStream& WriteFloat( float nFloat ); + SvStream& WriteDouble( const double& rDouble ); + SvStream& WriteCharPtr( const char* pBuf ); + SvStream& WriteUCharPtr( const unsigned char* pBuf ); SvStream& WriteNumber( sal_uInt32 nUInt32 ); SvStream& WriteNumber( sal_Int32 nInt32 ); @@ -585,6 +618,18 @@ sal_Size write_lenPrefixed_uInt16s_FromOUString(SvStream& rStrm, return streamdetail::write_lenPrefixed_seq_From_str<prefix, OUString, write_uInt16s_FromOUString>(rStrm, rStr); } +/// Attempt to write a pascal-style length (of type prefix) prefixed sequence +/// of 16bit units from an OUString, returned value is number of bytes written +/// (including byte-count of prefix) +TOOLS_DLLPUBLIC sal_Size write_uInt32_lenPrefixed_uInt16s_FromOUString(SvStream& rStrm, + const OUString &rStr); + +/// Attempt to write a pascal-style length (of type prefix) prefixed sequence +/// of 16bit units from an OUString, returned value is number of bytes written +/// (including byte-count of prefix) +TOOLS_DLLPUBLIC sal_Size write_uInt16_lenPrefixed_uInt16s_FromOUString(SvStream& rStrm, + const OUString &rStr); + /// Attempt to read 8bit units to an OString until a zero terminator is /// encountered, returned OString's length is number of units *definitely* /// successfully read, check SvStream::good() to see if null terminator was @@ -650,6 +695,22 @@ sal_Size write_lenPrefixed_uInt8s_FromOUString(SvStream& rStrm, return write_lenPrefixed_uInt8s_FromOString<prefix>(rStrm, OUStringToOString(rStr, eEnc)); } +/// Attempt to write a pascal-style length (of type prefix) prefixed +/// sequence of units from a string-type, returned value is number of bytes +/// written (including byte-count of prefix) +TOOLS_DLLPUBLIC sal_Size write_uInt16_lenPrefixed_uInt8s_FromOString(SvStream& rStrm, + const OString &rStr); + +/// Attempt to write a pascal-style length (of type prefix) prefixed sequence +/// of 8bit units from an OUString, returned value is number of bytes written +/// (including byte-count of prefix) +TOOLS_DLLPUBLIC inline sal_Size write_uInt16_lenPrefixed_uInt8s_FromOUString(SvStream& rStrm, + const OUString &rStr, + rtl_TextEncoding eEnc) +{ + return write_uInt16_lenPrefixed_uInt8s_FromOString(rStrm, OUStringToOString(rStr, eEnc)); +} + // FileStream class TOOLS_DLLPUBLIC SvFileStream : public SvStream |