[PATCH] Started to replace ByteString with rtl::OString

Christina Rossmanith ChrRossmanith at web.de
Wed Jun 29 13:52:41 PDT 2011


---
 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


--------------030000040803000805020609
Content-Type: text/x-patch;
 name="0001-Added-SvStream-ReadLine-rtl-OString.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="0001-Added-SvStream-ReadLine-rtl-OString.patch"



More information about the LibreOffice mailing list