Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hi,

I've started to replace ByteString with rtl::OString. You find what I did so far in the attached patches. It would be nice if someone could review the patches and give feedback. Then I'll continue and push.

Christina
From b090093772d7011b7508f32d749eca69e01adbd4 Mon Sep 17 00:00:00 2001
From: Christina Rossmanith <ChrRossmanith@web.de>
Date: Wed, 29 Jun 2011 22:52:41 +0200
Subject: [PATCH] Started to replace ByteString with rtl::OString

---
 automation/source/testtool/httprequest.cxx |   36 ++++++++++++++-------------
 automation/source/testtool/httprequest.hxx |   18 +++++++------
 2 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/automation/source/testtool/httprequest.cxx b/automation/source/testtool/httprequest.cxx
index 99d1aee..04c61ec 100644
--- a/automation/source/testtool/httprequest.cxx
+++ b/automation/source/testtool/httprequest.cxx
@@ -38,7 +38,7 @@
 void HttpRequest::Init()
 {
     nResultId = 0;
-    aHeader.Erase();
+    aHeader = rtl::OString();
     aContentType.Erase();
     delete pStream;
     pStream = NULL;
@@ -59,7 +59,7 @@ HttpRequest::~HttpRequest()
     pOutSocket = NULL;
 }
 
-void HttpRequest::SetRequest( ByteString aHost, ByteString aPath, sal_uInt16 nPort )
+void HttpRequest::SetRequest( rtl::OString aHost, rtl::OString aPath, sal_uInt16 nPort )
 {
     nStatus = HTTP_REQUEST_SET;
     Init();
@@ -68,7 +68,7 @@ void HttpRequest::SetRequest( ByteString aHost, ByteString aPath, sal_uInt16 nPo
     nRequestPort = nPort;
 }
 
-void HttpRequest::SetProxy( ByteString aHost, sal_uInt16 nPort )
+void HttpRequest::SetProxy( rtl::OString aHost, sal_uInt16 nPort )
 {
     nStatus = HTTP_REQUEST_SET;
     Init();
@@ -84,13 +84,13 @@ sal_Bool HttpRequest::Execute()
     // Open channel to standard redir host
     osl::SocketAddr aConnectAddr;
 
-    if ( aProxyHost.Len() )
+    if ( aProxyHost.getLength() )
     {
-        aConnectAddr = osl::SocketAddr( rtl::OUString( UniString( aProxyHost, 
RTL_TEXTENCODING_UTF8 ) ), nProxyPort );
+        aConnectAddr = osl::SocketAddr( rtl::OUString::createFromAscii( aProxyHost.getStr() ), 
nProxyPort );
     }
     else
     {
-        aConnectAddr = osl::SocketAddr( rtl::OUString( UniString( aRequestHost, 
RTL_TEXTENCODING_UTF8 ) ), nRequestPort );
+        aConnectAddr = osl::SocketAddr( rtl::OUString::createFromAscii( aRequestHost.getStr() ), 
nRequestPort );
     }
 
     TimeValue aTV;
@@ -98,7 +98,8 @@ sal_Bool HttpRequest::Execute()
     aTV.Nanosec = 0;
 
     pOutSocket = new osl::ConnectorSocket();
-    if ( pOutSocket->connect( aConnectAddr, &aTV ) != osl_Socket_Ok )
+    if
+ ( pOutSocket->connect( aConnectAddr, &aTV ) != osl_Socket_Ok )
     {
         delete pOutSocket;
         pOutSocket = NULL;
@@ -107,13 +108,13 @@ sal_Bool HttpRequest::Execute()
     }
 
     SendString( pOutSocket, "GET " );
-    if ( aProxyHost.Len() )
+    if ( aProxyHost.getLength() )
     {
         //GET http://staroffice-doc.germany.sun.com/cgi-bin/htdig/binarycopy.sh?CopyIt=++CopyIt++ 
HTTP/1.0
         SendString( pOutSocket, "http://"; );
         SendString( pOutSocket, aRequestHost );
         SendString( pOutSocket, ":" );
-        SendString( pOutSocket, ByteString::CreateFromInt32( nRequestPort ) );
+        SendString( pOutSocket, rtl::OString::valueOf( (sal_Int32) nRequestPort ) );
         SendString( pOutSocket, aRequestPath );
         SendString( pOutSocket, " HTTP/1.0\n" );
 
@@ -156,20 +157,21 @@ sal_Bool HttpRequest::Execute()
 
     pStream->Seek( 0 );
     
-    ByteString aLine;
+    rtl::OString aLine;
     sal_Bool bInsideHeader = sal_True;
+    sal_Int32 nIndex = 0;
     while ( bInsideHeader )
     {
         pStream->ReadLine( aLine );
-        if ( !aLine.Len() )
+        if ( !aLine.getLength() )
             bInsideHeader = sal_False;
         else
         {
             if ( IsItem( "HTTP/", aLine ) )
-                nResultId = (sal_uInt16)aLine.GetToken( 1, ' ' ).ToInt32();
+                nResultId = (sal_uInt16)aLine.getToken( (sal_Int32)1, ' ', nIndex ).toInt32();
             if ( IsItem( "Content-Type:", aLine ) )
             {
-                aContentType = aLine.Copy( 13 );
+                aContentType = aLine.copy( 13 );
                 aContentType.EraseLeadingAndTrailingChars();
             }
             aHeader += aLine;
@@ -200,15 +202,15 @@ Servlet-Engine: Tomcat Web Server/3.2.1 (JSP 1.1; Servlet 2.2; Java 1.3.0; 
Linux
 Connection: close
 Content-Type: text/xml; charset=ISO-8859-1
   */
-void HttpRequest::SendString( osl::StreamSocket* pSocket , ByteString aText )
+void HttpRequest::SendString( osl::StreamSocket* pSocket , rtl::OString aText )
 {
     if ( nStatus == HTTP_REQUEST_PENDING )
-        pSocket->write( aText.GetBuffer(), aText.Len() );
+        pSocket->write( aText.getStr(), aText.getLength() );
 }
 
-sal_Bool HttpRequest::IsItem( ByteString aItem, ByteString aLine )
+sal_Bool HttpRequest::IsItem( rtl::OString aItem, rtl::OString aLine )
 {
-    return aItem.Match( aLine ) == STRING_MATCH;
+    return aItem.match( aLine );
 }
 
 
diff --git a/automation/source/testtool/httprequest.hxx b/automation/source/testtool/httprequest.hxx
index 3996a9c..a36c81c 100644
--- a/automation/source/testtool/httprequest.hxx
+++ b/automation/source/testtool/httprequest.hxx
@@ -37,6 +37,7 @@
 
 #include <tools/string.hxx>
 #include <tools/stream.hxx>
+#include "rtl/string.hxx"
 
 namespace osl
 {
@@ -46,29 +48,29 @@ namespace osl
 
 class HttpRequest
 {
-    ByteString aRequestPath;
-    ByteString aRequestHost;
+    rtl::OString aRequestPath;
+    rtl::OString aRequestHost;
     sal_uInt16 nRequestPort;
-    ByteString aProxyHost;
+    rtl::OString aProxyHost;
     sal_uInt16 nProxyPort;
 
     sal_uInt16 nStatus;
     osl::ConnectorSocket *pOutSocket;
 
-    ByteString aHeader;
+    rtl::OString aHeader;
     sal_uInt16 nResultId;
     ByteString aContentType;
     SvMemoryStream* pStream;
 
-    void SendString( osl::StreamSocket* pSocket, ByteString aText );
-    sal_Bool IsItem( ByteString aItem, ByteString aLine );
+    void SendString( osl::StreamSocket* pSocket, ::rtl::OString aText );
+    sal_Bool IsItem( rtl::OString aItem, rtl::OString aLine );
     void Init();
 public:
     HttpRequest();
     ~HttpRequest();
 
-    void SetRequest( ByteString aHost, ByteString aPath, sal_uInt16 nPort );
-    void SetProxy( ByteString aHost, sal_uInt16 nPort );
+    void SetRequest( rtl::OString aHost, rtl::OString aPath, sal_uInt16 nPort );
+    void SetProxy( rtl::OString aHost, sal_uInt16 nPort );
 
     sal_Bool Execute();
     void Abort();
-- 
1.7.4.1

From 0579a8169b3a830f8a7f1300ce397851d7ff0693 Mon Sep 17 00:00:00 2001
From: Christina Rossmanith <ChrRossmanith@web.de>
Date: Wed, 29 Jun 2011 22:56:28 +0200
Subject: [PATCH] Added SvStream::ReadLine( rtl::OString& )

---
 tools/inc/tools/stream.hxx     |    2 ++
 tools/source/stream/stream.cxx |   10 ++++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/tools/inc/tools/stream.hxx b/tools/inc/tools/stream.hxx
index 4273583..b83b6f2 100644
--- a/tools/inc/tools/stream.hxx
+++ b/tools/inc/tools/stream.hxx
@@ -34,6 +34,7 @@
 #include <tools/errinf.hxx>
 #include <tools/ref.hxx>
 #include <tools/rtti.hxx>
+#include <rtl/string.hxx>
 
 class FileCopier;
 class StreamData;
@@ -445,6 +446,7 @@ public:
     sal_Bool           ReadCString( String& rStr ) { return ReadCString( rStr, 
GetStreamCharSet()); }
 
     sal_Bool           ReadLine( ByteString& rStr );
+    sal_Bool           ReadLine( rtl::OString& rStr );
     sal_Bool           WriteLine( const ByteString& rStr );
     sal_Bool           WriteLines( const ByteString& rStr );
 
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 11a1cb3..041c0b1 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -43,6 +43,7 @@
 
 #include <tools/solar.h>
 
+
 #define SWAPNIBBLES(c)      \
 unsigned char nSwapTmp=c;   \
 nSwapTmp <<= 4;             \
@@ -733,6 +734,15 @@ sal_Bool SvStream::ReadLine( ByteString& rStr )
     return bEnd;
 }
 
+sal_Bool SvStream::ReadLine( rtl::OString& rStr )
+{
+    ByteString aFoo;
+    sal_Bool   ret;
+    ret = ReadLine(aFoo);
+    rStr = aFoo;
+    return ret;
+}
+
 sal_Bool SvStream::ReadUniStringLine( String& rStr )
 {
     sal_Unicode buf[256+1];
-- 
1.7.4.1


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.