[Libreoffice] [LibreOffice] [39428] Remove SvStream operator>>/<<

Keith McRae keithcoder at gmail.com
Thu Jan 26 03:40:54 PST 2012


Hello all

I've removed all the operator>>/<< from SvStream and replaced with
Read/Write[sal_type] functions. While fixing up the references I noticed
the template'd functions below:

template<typename prefix>
rtl::OString read_lenPrefixed_uInt8s_ToOString(SvStream& rStrm)
{
    prefix nUnits = 0;
    rStrm >> nUnits;
    return read_uInt8s_ToOString(rStrm, nUnits);
}

and the corresponding write function:

template<typename prefix> sal_Size
write_lenPrefixed_uInt8s_FromOString(SvStream& rStrm,
    const rtl::OString &rStr)
{
    SAL_WARN_IF(rStr.getLength() > std::numeric_limits<prefix>::max(),
        "tools.stream",
        "string too long for prefix count to fit in output type");

    sal_Size nWritten = 0;
    prefix nUnits = std::min<sal_Size>(rStr.getLength(),
std::numeric_limits<prefix>::max());
    rStrm << nUnits;
    if (rStrm.good())
    {
        nWritten += sizeof(prefix);
        nWritten += rStrm.Write(rStr.getStr(), nUnits);
    }
    return nWritten;
}

So I have a dilemma which I would appreciate advice on. In no particular
order of preference here are my ideas:

a) Specialize the templates and call the appropriate Read/Write[sal_type]
functions.
b) Change SvStream to have overloaded Read/WriteNumber functions of all the
sal_ types.
c) Add the above mentioned functions along with the Read/Write[sal_type]
functions to SvStream.

Thanks in advance
Keith
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20120126/cf92d83d/attachment-0001.html>


More information about the LibreOffice mailing list