summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-11-19 14:58:12 +0000
committerCaolán McNamara <caolanm@redhat.com>2011-11-19 21:11:03 +0000
commit445065d1131deda6cc56b2dddf0bbb07253e55f7 (patch)
tree33a42124ea10203c8e69ca3cc47483203c6106d3 /tools
parent4e7fff380a0b7cec8cc4bf5b4e43a6e91c97db6a (diff)
ByteString->rtl::OString[Buffer]
Diffstat (limited to 'tools')
-rw-r--r--tools/inc/tools/inetmime.hxx120
-rw-r--r--tools/source/inet/inetmime.cxx43
2 files changed, 55 insertions, 108 deletions
diff --git a/tools/inc/tools/inetmime.hxx b/tools/inc/tools/inetmime.hxx
index 4a3abe577101..6259c20a887e 100644
--- a/tools/inc/tools/inetmime.hxx
+++ b/tools/inc/tools/inetmime.hxx
@@ -32,8 +32,9 @@
#include "tools/toolsdllapi.h"
#include <rtl/alloc.h>
-#include <rtl/string.h>
-#include "rtl/tencinfo.h"
+#include <rtl/string.hxx>
+#include <rtl/strbuf.hxx>
+#include <rtl/tencinfo.h>
#include <tools/debug.hxx>
#include <tools/errcode.hxx>
#include <tools/string.hxx>
@@ -404,19 +405,6 @@ public:
const sal_Unicode * pEnd1,
const sal_Char * pString2);
- /** Check two US-ASCII strings for equality, ignoring case.
-
- @param rString1 The first string.
-
- @param sString2 Points to the start of the null terminated second
- string, must not be null.
-
- @return True if the two strings are equal, ignoring the case of US-
- ASCII alphabetic characters (US-ASCII 'A'--'Z' and 'a'--'z').
- */
- static inline bool equalIgnoreCase(const ByteString & rString1,
- const sal_Char * pString2);
-
static inline bool startsWithLineBreak(const sal_Char * pBegin,
const sal_Char * pEnd);
@@ -536,7 +524,7 @@ public:
sal_uInt32 & rCharacter);
static UniString decodeHeaderFieldBody(HeaderFieldType eType,
- const ByteString & rBody);
+ const rtl::OString& rBody);
// #i70651#: Prevent warnings on Mac OS X.
#ifdef MACOSX
@@ -712,14 +700,6 @@ inline sal_uInt32 INetMIME::toUTF32(sal_Unicode cHighSurrogate,
}
// static
-inline bool INetMIME::equalIgnoreCase(const ByteString & rString1,
- const sal_Char * pString2)
-{
- return equalIgnoreCase(rString1.GetBuffer(),
- rString1.GetBuffer() + rString1.Len(), pString2);
-}
-
-// static
inline bool INetMIME::startsWithLineBreak(const sal_Char * pBegin,
const sal_Char * pEnd)
{
@@ -973,14 +953,18 @@ public:
/** Write a sequence of octets.
- @param rOctets A ByteString, interpreted as a sequence of octets.
+ @param rOctets A rtl::OString, interpreted as a sequence of octets.
@param nBegin The offset of the first character to write.
@param nEnd The offset past the last character to write.
*/
- inline void write(const ByteString & rString, xub_StrLen nBegin,
- xub_StrLen nEnd);
+ void write(const rtl::OString& rOctets, xub_StrLen nBegin,
+ xub_StrLen nEnd)
+ {
+ writeSequence(rOctets.getStr() + nBegin, rOctets.getStr() + nEnd);
+ m_nColumn += nEnd - nBegin;
+ }
/** Write a single octet.
@@ -1002,11 +986,16 @@ public:
/** Write a sequence of octets.
- @param rOctets A ByteString, interpreted as a sequence of octets.
+ @param rOctets A rtl::OString, interpreted as a sequence of octets.
@return This instance.
*/
- inline INetMIMEOutputSink & operator <<(const ByteString & rOctets);
+ INetMIMEOutputSink & operator <<(const rtl::OString& rOctets)
+ {
+ writeSequence(rOctets.getStr(), rOctets.getStr() + rOctets.getLength());
+ m_nColumn += rOctets.getLength();
+ return *this;
+ }
/** Call a manipulator function.
@@ -1052,13 +1041,6 @@ inline void INetMIMEOutputSink::write(const sal_Unicode * pBegin,
m_nColumn += pEnd - pBegin;
}
-inline void INetMIMEOutputSink::write(const ByteString & rOctets,
- xub_StrLen nBegin, xub_StrLen nEnd)
-{
- writeSequence(rOctets.GetBuffer() + nBegin, rOctets.GetBuffer() + nEnd);
- m_nColumn += nEnd - nBegin;
-}
-
inline INetMIMEOutputSink & INetMIMEOutputSink::operator <<(sal_Char nOctet)
{
writeSequence(&nOctet, &nOctet + 1);
@@ -1073,14 +1055,6 @@ inline INetMIMEOutputSink & INetMIMEOutputSink::operator <<(const sal_Char *
return *this;
}
-inline INetMIMEOutputSink & INetMIMEOutputSink::operator <<(const ByteString &
- rOctets)
-{
- writeSequence(rOctets.GetBuffer(), rOctets.GetBuffer() + rOctets.Len());
- m_nColumn += rOctets.Len();
- return *this;
-}
-
// static
inline INetMIMEOutputSink & INetMIMEOutputSink::endl(INetMIMEOutputSink &
rSink)
@@ -1101,8 +1075,7 @@ inline void INetMIME::writeEscapeSequence(INetMIMEOutputSink & rSink,
//============================================================================
class INetMIMEStringOutputSink: public INetMIMEOutputSink
{
- ByteString m_aBuffer;
- bool m_bOverflow;
+ rtl::OStringBuffer m_aBuffer;
using INetMIMEOutputSink::writeSequence;
@@ -1113,21 +1086,16 @@ public:
inline INetMIMEStringOutputSink(sal_uInt32 nColumn = 0,
sal_uInt32 nLineLengthLimit
= INetMIME::SOFT_LINE_LENGTH_LIMIT):
- INetMIMEOutputSink(nColumn, nLineLengthLimit), m_bOverflow(false) {}
+ INetMIMEOutputSink(nColumn, nLineLengthLimit) {}
virtual ErrCode getError() const;
- inline ByteString takeBuffer();
+ rtl::OString takeBuffer()
+ {
+ return m_aBuffer.makeStringAndClear();
+ }
};
-inline ByteString INetMIMEStringOutputSink::takeBuffer()
-{
- ByteString aTheBuffer = m_aBuffer;
- m_aBuffer.Erase();
- m_bOverflow = false;
- return aTheBuffer;
-}
-
//============================================================================
class INetMIMEEncodedWordOutputSink
{
@@ -1240,17 +1208,17 @@ struct INetContentTypeParameter
will only be one item for the complete parameter, with the attribute
name lacking any section suffix.
*/
- const ByteString m_sAttribute;
+ const rtl::OString m_sAttribute;
/** The optional character set specification (see RFC 2231), in US-ASCII
encoding and converted to lower case.
*/
- const ByteString m_sCharset;
+ const rtl::OString m_sCharset;
/** The optional language specification (see RFC 2231), in US-ASCII
encoding and converted to lower case.
*/
- const ByteString m_sLanguage;
+ const rtl::OString m_sLanguage;
/** The attribute value. If the value is a quoted-string, it is
'unpacked.' If a character set is specified, and the value can be
@@ -1277,29 +1245,18 @@ struct INetContentTypeParameter
*/
const bool m_bConverted;
- inline INetContentTypeParameter(const ByteString & rTheAttribute,
- const ByteString & rTheCharset,
- const ByteString & rTheLanguage,
- const UniString & rTheValue,
- bool bTheConverted);
+ INetContentTypeParameter(const rtl::OString& rTheAttribute,
+ const rtl::OString& rTheCharset, const rtl::OString& rTheLanguage,
+ const UniString & rTheValue, bool bTheConverted)
+ : m_sAttribute(rTheAttribute)
+ , m_sCharset(rTheCharset)
+ , m_sLanguage(rTheLanguage)
+ , m_sValue(rTheValue)
+ , m_bConverted(bTheConverted)
+ {
+ }
};
-inline INetContentTypeParameter::INetContentTypeParameter(const ByteString &
- rTheAttribute,
- const ByteString &
- rTheCharset,
- const ByteString &
- rTheLanguage,
- const UniString &
- rTheValue,
- bool bTheConverted):
- m_sAttribute(rTheAttribute),
- m_sCharset(rTheCharset),
- m_sLanguage(rTheLanguage),
- m_sValue(rTheValue),
- m_bConverted(bTheConverted)
-{}
-
//============================================================================
class TOOLS_DLLPUBLIC INetContentTypeParameterList
{
@@ -1322,8 +1279,7 @@ public:
return &(maEntries[nIndex]);
}
- const INetContentTypeParameter * find(const ByteString & rAttribute)
- const;
+ const INetContentTypeParameter * find(const rtl::OString& rAttribute) const;
private:
diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx
index f54952e9bde6..e6b8db1836bd 100644
--- a/tools/source/inet/inetmime.cxx
+++ b/tools/source/inet/inetmime.cxx
@@ -2763,7 +2763,7 @@ bool INetMIME::translateUTF8Char(const sal_Char *& rBegin,
//============================================================================
// static
UniString INetMIME::decodeHeaderFieldBody(HeaderFieldType eType,
- const ByteString & rBody)
+ const rtl::OString& rBody)
{
// Due to a bug in INetCoreRFC822MessageStream::ConvertTo7Bit(), old
// versions of StarOffice send mails with header fields where encoded
@@ -2785,8 +2785,8 @@ UniString INetMIME::decodeHeaderFieldBody(HeaderFieldType eType,
//
// base64 = ALPHA / DIGIT / "+" / "/"
- const sal_Char * pBegin = rBody.GetBuffer();
- const sal_Char * pEnd = pBegin + rBody.Len();
+ const sal_Char * pBegin = rBody.getStr();
+ const sal_Char * pEnd = pBegin + rBody.getLength();
UniString sDecoded;
const sal_Char * pCopyBegin = pBegin;
@@ -2984,11 +2984,9 @@ UniString INetMIME::decodeHeaderFieldBody(HeaderFieldType eType,
bDone = true;
break;
}
- sText.append(rBody.Copy(
- static_cast< xub_StrLen >(
- pEncodedTextCopyBegin - pBegin),
- static_cast< xub_StrLen >(
- q - 1 - pEncodedTextCopyBegin)));
+ sText.append(rBody.copy(
+ (pEncodedTextCopyBegin - pBegin),
+ (q - 1 - pEncodedTextCopyBegin)));
sText.append(sal_Char(nDigit1 << 4 | nDigit2));
q += 2;
pEncodedTextCopyBegin = q;
@@ -2997,22 +2995,18 @@ UniString INetMIME::decodeHeaderFieldBody(HeaderFieldType eType,
case '?':
if (q - pEncodedTextBegin > 1)
- sText.append(rBody.Copy(
- static_cast< xub_StrLen >(
- pEncodedTextCopyBegin - pBegin),
- static_cast< xub_StrLen >(
- q - 1 - pEncodedTextCopyBegin)));
+ sText.append(rBody.copy(
+ (pEncodedTextCopyBegin - pBegin),
+ (q - 1 - pEncodedTextCopyBegin)));
else
bEncodedWord = false;
bDone = true;
break;
case '_':
- sText.append(rBody.Copy(
- static_cast< xub_StrLen >(
- pEncodedTextCopyBegin - pBegin),
- static_cast< xub_StrLen >(
- q - 1 - pEncodedTextCopyBegin)));
+ sText.append(rBody.copy(
+ (pEncodedTextCopyBegin - pBegin),
+ (q - 1 - pEncodedTextCopyBegin)));
sText.append(' ');
pEncodedTextCopyBegin = q;
break;
@@ -3284,20 +3278,17 @@ void INetMIMEOutputSink::writeLineEnd()
void INetMIMEStringOutputSink::writeSequence(const sal_Char * pBegin,
const sal_Char * pEnd)
{
- DBG_ASSERT(pBegin && pBegin <= pEnd,
+ OSL_ENSURE(pBegin && pBegin <= pEnd,
"INetMIMEStringOutputSink::writeSequence(): Bad sequence");
- m_bOverflow = m_bOverflow
- || pEnd - pBegin > STRING_MAXLEN - m_aBuffer.Len();
- if (!m_bOverflow)
- m_aBuffer.Append(pBegin, static_cast< xub_StrLen >(pEnd - pBegin));
+ m_aBuffer.append(pBegin, pEnd - pBegin);
}
//============================================================================
// virtual
ErrCode INetMIMEStringOutputSink::getError() const
{
- return m_bOverflow ? ERRCODE_IO_OUTOFMEMORY : ERRCODE_NONE;
+ return ERRCODE_NONE;
}
//============================================================================
@@ -4171,12 +4162,12 @@ void INetContentTypeParameterList::Clear()
//============================================================================
const INetContentTypeParameter *
-INetContentTypeParameterList::find(const ByteString & rAttribute) const
+INetContentTypeParameterList::find(const rtl::OString& rAttribute) const
{
boost::ptr_vector<INetContentTypeParameter>::const_iterator iter;
for (iter = maEntries.begin(); iter != maEntries.end(); ++iter)
{
- if (iter->m_sAttribute.EqualsIgnoreCaseAscii(rAttribute))
+ if (iter->m_sAttribute.equalsIgnoreAsciiCase(rAttribute))
return &(*iter);
}