certi-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[certi-cvs] certi RTIA/TimeManagement.cc RTIG/Federation.cc...


From: certi-cvs
Subject: [certi-cvs] certi RTIA/TimeManagement.cc RTIG/Federation.cc...
Date: Sun, 14 Mar 2010 14:38:28 +0000

CVSROOT:        /sources/certi
Module name:    certi
Changes by:     Petr Gotthard <gotthardp>       10/03/14 14:38:27

Modified files:
        RTIA           : TimeManagement.cc 
        RTIG           : Federation.cc 
        include        : certi.hh 
        libCERTI       : MessageBuffer.cc Object.cc ObjectSet.cc 
                         SocketHTTPProxy.cc SocketTCP.cc SocketUDP.cc 
                         SocketUN.cc 

Log message:
        Patch #7119: stringstream wrapper for error message construction

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/TimeManagement.cc?cvsroot=certi&r1=3.54&r2=3.55
http://cvs.savannah.gnu.org/viewcvs/certi/RTIG/Federation.cc?cvsroot=certi&r1=3.123&r2=3.124
http://cvs.savannah.gnu.org/viewcvs/certi/include/certi.hh?cvsroot=certi&r1=3.45&r2=3.46
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/MessageBuffer.cc?cvsroot=certi&r1=3.18&r2=3.19
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/Object.cc?cvsroot=certi&r1=3.26&r2=3.27
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/ObjectSet.cc?cvsroot=certi&r1=3.28&r2=3.29
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketHTTPProxy.cc?cvsroot=certi&r1=3.6&r2=3.7
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketTCP.cc?cvsroot=certi&r1=3.32&r2=3.33
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketUDP.cc?cvsroot=certi&r1=3.28&r2=3.29
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/SocketUN.cc?cvsroot=certi&r1=3.35&r2=3.36

Patches:
Index: RTIA/TimeManagement.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/TimeManagement.cc,v
retrieving revision 3.54
retrieving revision 3.55
diff -u -b -r3.54 -r3.55
--- RTIA/TimeManagement.cc      27 Feb 2010 16:53:36 -0000      3.54
+++ RTIA/TimeManagement.cc      14 Mar 2010 14:38:27 -0000      3.55
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: TimeManagement.cc,v 3.54 2010/02/27 16:53:36 erk Exp $
+// $Id: TimeManagement.cc,v 3.55 2010/03/14 14:38:27 gotthardp Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -369,10 +369,9 @@
         break;
 
       default:
-       std::stringstream errorMsg;
         D.Out(pdExcept, "Unknown message type in executeFederateService.");
-       errorMsg << "Unknown message <" <<  msg.getName() << " in 
executeFederateService.";
-        throw RTIinternalError(errorMsg.str());
+        throw RTIinternalError(stringize() <<
+            "Unknown message <" <<  msg.getName() << "> in 
executeFederateService.");
     }
     G.Out(pdGendoc,"exit  TimeManagement::executeFederateService");
     return true ;
@@ -994,4 +993,4 @@
 
 }} // namespaces
 
-// $Id: TimeManagement.cc,v 3.54 2010/02/27 16:53:36 erk Exp $
+// $Id: TimeManagement.cc,v 3.55 2010/03/14 14:38:27 gotthardp Exp $

Index: RTIG/Federation.cc
===================================================================
RCS file: /sources/certi/certi/RTIG/Federation.cc,v
retrieving revision 3.123
retrieving revision 3.124
diff -u -b -r3.123 -r3.124
--- RTIG/Federation.cc  7 Mar 2010 21:30:30 -0000       3.123
+++ RTIG/Federation.cc  14 Mar 2010 14:38:27 -0000      3.124
@@ -18,13 +18,12 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: Federation.cc,v 3.123 2010/03/07 21:30:30 erk Exp $
+// $Id: Federation.cc,v 3.124 2010/03/14 14:38:27 gotthardp Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
 #include "Federation.hh"
 #include "NM_Classes.hh"
-#include <sstream>
 #include <cstring>
 #include <cerrno>
 #include <memory>
@@ -1437,9 +1436,8 @@
             return i->second;
     }
 
-    std::stringstream msg;
-    msg << "Federate <"<<federate_name<<"> not [yet] member of Federation <" 
<< getName() <<">.";
-    throw FederateNotExecutionMember(msg.str());
+    throw FederateNotExecutionMember(stringize() <<
+        "Federate <"<<federate_name<<"> not [yet] member of Federation <" << 
getName() <<">.");
 }
 
 // ----------------------------------------------------------------------------
@@ -1589,9 +1587,7 @@
         strname = object_name;
     } else {
         // create a name if necessary
-        std::stringstream ss;
-        ss << "HLAObject_" << new_id;
-        strname = ss.str();
+        strname = stringize() << "HLAObject_" << new_id;
     }
 
     // Register Object.
@@ -2398,9 +2394,7 @@
         strname = object_name;
     } else {
         // create a name if necessary
-        std::stringstream ss;
-        ss << "HLAObject_" << object;
-        strname = ss.str();
+        strname = stringize() << "HLAObject_" << object;
     }
 
     root->registerObjectInstance(federate, class_handle, object, strname);
@@ -2582,5 +2576,5 @@
 
 }} // namespace certi/rtig
 
-// $Id: Federation.cc,v 3.123 2010/03/07 21:30:30 erk Exp $
+// $Id: Federation.cc,v 3.124 2010/03/14 14:38:27 gotthardp Exp $
 

Index: include/certi.hh
===================================================================
RCS file: /sources/certi/certi/include/certi.hh,v
retrieving revision 3.45
retrieving revision 3.46
diff -u -b -r3.45 -r3.46
--- include/certi.hh    7 Mar 2010 21:30:31 -0000       3.45
+++ include/certi.hh    14 Mar 2010 14:38:27 -0000      3.46
@@ -16,7 +16,7 @@
 // License along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: certi.hh,v 3.45 2010/03/07 21:30:31 erk Exp $
+// $Id: certi.hh,v 3.46 2010/03/14 14:38:27 gotthardp Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef CERTI_HH_INCLUDED
@@ -108,6 +108,7 @@
 #define CERTI_DECODE_DOUBLE_FROM_UINT64BE(val)  (CERTI_UINT64_FROM_BE 
(*(uint64_t*)(val)))
 
 #include <string>
+#include <sstream>
 
 /**
  * @defgroup libCERTI The CERTI library.
@@ -163,6 +164,36 @@
 // Constants
 const int MAX_BACKLOG = 256 ;
 
+/**
+ * Helper class to simplify string construction. Implemented as
+ * a stringstream wrapper.
+ *
+ * For example:
+ * throw AttributeNotDefined(stringize() << "value: " << number);
+ */
+template<typename C>
+struct basic_stringize
+{
+  template<typename T>
+  basic_stringize<C> & operator << (const T& t)
+  {
+    m_s << t;
+    return *this;
+  }
+
+  // note: must not return reference
+  operator const std::basic_string<C>() const
+  {
+    return m_s.str();
+  }
+
+private:
+  std::basic_stringstream<C> m_s;
+};
+
+typedef basic_stringize<char> stringize;
+typedef basic_stringize<wchar_t> wstringize;
+
 } // namespace certi
 
 // Define this if you want the complete object and interaction tree to
@@ -268,4 +299,4 @@
        (uint64_t) CERTI_INT64_CONSTANT(0xff00000000000000U)) >> 56)))
 #endif // CERTI_HH_INCLUDED
 
-// $Id: certi.hh,v 3.45 2010/03/07 21:30:31 erk Exp $
+// $Id: certi.hh,v 3.46 2010/03/14 14:38:27 gotthardp Exp $

Index: libCERTI/MessageBuffer.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/MessageBuffer.cc,v
retrieving revision 3.18
retrieving revision 3.19
diff -u -b -r3.18 -r3.19
--- libCERTI/MessageBuffer.cc   7 Mar 2010 18:23:39 -0000       3.18
+++ libCERTI/MessageBuffer.cc   14 Mar 2010 14:38:27 -0000      3.19
@@ -23,7 +23,6 @@
 #include "Exception.hh"
 #include "PrettyDebug.hh"
 #include <cassert>
-#include <sstream>
 #include <iomanip>
 #include <cstring>
 #include <cstdio>
@@ -205,12 +204,11 @@
 
 int32_t MessageBuffer::read_uint8s(uint8_t* data, uint32_t n) {
        if (n + readOffset > writeOffset) {
-               std::stringstream smsg;
-               smsg << "read_uint8s::invalid read of size <" << n
+               throw RTIinternalError(stringize()
+                       << "read_uint8s::invalid read of size <" << n
                                << "> inside a buffer of readable size <"
                                << (int32_t)writeOffset-readOffset << "> 
(writeOffset="
-                               <<writeOffset << ",readOffset="<<readOffset 
<<").";
-               throw RTIinternalError(smsg.str());
+                       << writeOffset << ",readOffset="<<readOffset <<").");
        }
 
        memcpy(data, buffer+readOffset, n);
@@ -249,12 +247,11 @@
        uint16_t an_uint16;
 
        if (2*n + readOffset > writeOffset) {
-               std::stringstream smsg;
-               smsg << "read_uint16s::invalid read of size <" << 2*n
+               throw RTIinternalError(stringize()
+                       << "read_uint16s::invalid read of size <" << 2*n
                                << "> inside a buffer of readable size <"
                                << (int32_t)writeOffset-readOffset << "> 
(writeOffset="
-                               <<writeOffset << ",readOffset="<<readOffset 
<<").";
-               throw RTIinternalError(smsg.str());
+                       << writeOffset << ",readOffset="<<readOffset <<").");
        }
 
        /* do not swap byte if it is not necessary */
@@ -303,12 +300,11 @@
        uint32_t an_uint32;
 
        if (4*n + readOffset > writeOffset) {
-               std::stringstream smsg;
-               smsg << "read_uint32s::invalid read of size <" << 4*n
+               throw RTIinternalError(stringize()
+                       << "read_uint32s::invalid read of size <" << 4*n
                                << "> inside a buffer of readable size <"
                                << (int32_t)writeOffset-readOffset << "> 
(writeOffset="
-                               <<writeOffset << ",readOffset="<<readOffset 
<<").";
-               throw RTIinternalError(smsg.str());
+                       << writeOffset << ",readOffset="<<readOffset <<").");
        }
 
        /* do not swap byte if it is not necessary */
@@ -370,12 +366,11 @@
         Debug(D, pdTrace) << "read_uint64s(" << data << " = [" << (n ? data[0] 
: 0) <<" ...], " << n << ")" << std::endl;
 
        if (8*n + readOffset > writeOffset) {
-               std::stringstream smsg;
-               smsg << "read_uint64s::invalid read of size <" << 4*n
+               throw RTIinternalError(stringize()
+                       << "read_uint64s::invalid read of size <" << 4*n
                                << "> inside a buffer of readable size <"
                                << (int32_t)writeOffset-readOffset << "> 
(writeOffset="
-                               <<writeOffset << ",readOffset="<<readOffset 
<<").";
-               throw RTIinternalError(smsg.str());
+                       << writeOffset << ",readOffset="<<readOffset <<").");
        }
 
        /* do not swap byte if it is not necessary */
@@ -445,12 +440,11 @@
     int32_t len = read_int32();
 
     if (len + readOffset > writeOffset) {
-        std::stringstream smsg;
-        smsg << "read_string::invalid read of size <" << len
+        throw RTIinternalError(stringize()
+            << "read_string::invalid read of size <" << len
              << "> inside a buffer of readable size <"
              << (int32_t)writeOffset-readOffset << "> (writeOffset="
-             <<writeOffset << ",readOffset="<<readOffset <<").";
-        throw RTIinternalError(smsg.str());
+            << writeOffset << ",readOffset="<<readOffset <<").");
     }
 
     s.assign(reinterpret_cast<const char*>(buffer + readOffset), len);

Index: libCERTI/Object.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/Object.cc,v
retrieving revision 3.26
retrieving revision 3.27
diff -u -b -r3.26 -r3.27
--- libCERTI/Object.cc  11 Oct 2009 17:04:17 -0000      3.26
+++ libCERTI/Object.cc  14 Mar 2010 14:38:27 -0000      3.27
@@ -19,7 +19,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: Object.cc,v 3.26 2009/10/11 17:04:17 erk Exp $
+// $Id: Object.cc,v 3.27 2010/03/14 14:38:27 gotthardp Exp $
 // ----------------------------------------------------------------------------
 
 
@@ -85,9 +85,8 @@
 {
     AttributeMap::const_iterator i = _attributeMap.find(attributeHandle);
     if (i == _attributeMap.end()) {
-        std::stringstream stream;
-        stream << "Unknown attribute handle " << attributeHandle;
-        throw AttributeNotDefined(stream.str());
+        throw AttributeNotDefined(stringize() <<
+            "Unknown attribute handle " << attributeHandle);
     }
     return i->second;
 }
@@ -129,4 +128,4 @@
 
 } // namespace certi
 
-// $Id: Object.cc,v 3.26 2009/10/11 17:04:17 erk Exp $
+// $Id: Object.cc,v 3.27 2010/03/14 14:38:27 gotthardp Exp $

Index: libCERTI/ObjectSet.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/ObjectSet.cc,v
retrieving revision 3.28
retrieving revision 3.29
diff -u -b -r3.28 -r3.29
--- libCERTI/ObjectSet.cc       7 Mar 2010 21:30:30 -0000       3.28
+++ libCERTI/ObjectSet.cc       14 Mar 2010 14:38:27 -0000      3.29
@@ -32,12 +32,10 @@
 
 // Standard
 #include <iostream>
-#include <sstream>
 
 using std::pair ;
 using std::cout ;
 using std::endl ;
-using std::ostringstream ;
 using std::string ;
 
 namespace certi {
@@ -103,9 +101,8 @@
             return i->second->getHandle();
     }
 
-    std::stringstream msg;
-    msg << "No object instance with name <" << the_name;
-    throw ObjectNotKnown(msg.str());
+    throw ObjectNotKnown(stringize() <<
+        "No object instance with name <" << the_name);
 }
 
 // ----------------------------------------------------------------------------
@@ -159,9 +156,7 @@
         object->setName(the_name);
     }
     else {
-        ostringstream tmp ;
-        tmp << "HLAobject_" << the_object ;
-        object->setName(tmp.str());
+        object->setName(stringize() << "HLAobject_" << the_object);
     }
 
     pair<ObjectHandle, Object *> tmp(the_object, object);
@@ -461,4 +456,4 @@
 }
 } // namespace certi
 
-// $Id: ObjectSet.cc,v 3.28 2010/03/07 21:30:30 erk Exp $
+// $Id: ObjectSet.cc,v 3.29 2010/03/14 14:38:27 gotthardp Exp $

Index: libCERTI/SocketHTTPProxy.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/SocketHTTPProxy.cc,v
retrieving revision 3.6
retrieving revision 3.7
diff -u -b -r3.6 -r3.7
--- libCERTI/SocketHTTPProxy.cc 7 Mar 2010 18:23:39 -0000       3.6
+++ libCERTI/SocketHTTPProxy.cc 14 Mar 2010 14:38:27 -0000      3.7
@@ -17,7 +17,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: SocketHTTPProxy.cc,v 3.6 2010/03/07 18:23:39 erk Exp $
+// $Id: SocketHTTPProxy.cc,v 3.7 2010/03/14 14:38:27 gotthardp Exp $
 // ----------------------------------------------------------------------------
 
 #include "SocketHTTPProxy.hh"
@@ -184,10 +184,8 @@
     int iCode = atoi(sCode);
     // the response code must be 2xx
     if (iCode < 200 || iCode >= 300) {
-        std::stringstream msg;
-        msg << "Proxy connection refused: " << response;
-        D.Out(pdDebug, "%s", msg.str().c_str());
-        throw NetworkError(msg.str().c_str());
+        throw NetworkError(stringize() <<
+            "Proxy connection refused: " << response);
     }
 
     // receive the rest of the HTTP response
@@ -253,4 +251,4 @@
 
 } // namespace
 
-// $Id: SocketHTTPProxy.cc,v 3.6 2010/03/07 18:23:39 erk Exp $
+// $Id: SocketHTTPProxy.cc,v 3.7 2010/03/14 14:38:27 gotthardp Exp $

Index: libCERTI/SocketTCP.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/SocketTCP.cc,v
retrieving revision 3.32
retrieving revision 3.33
diff -u -b -r3.32 -r3.33
--- libCERTI/SocketTCP.cc       7 Mar 2010 18:23:39 -0000       3.32
+++ libCERTI/SocketTCP.cc       14 Mar 2010 14:38:27 -0000      3.33
@@ -17,7 +17,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 // USA
 //
-// $Id: SocketTCP.cc,v 3.32 2010/03/07 18:23:39 erk Exp $
+// $Id: SocketTCP.cc,v 3.33 2010/03/14 14:38:27 gotthardp Exp $
 // ----------------------------------------------------------------------------
 
 #include "SocketTCP.hh"
@@ -189,10 +189,8 @@
 _socket_tcp = ::accept(serveur->_socket_tcp, (sockaddr*)&_sockIn, &l);
 if (_socket_tcp < 0)
        {
-          std::stringstream msg;
-         msg << "SocketTCP: Accept Failed"
-             << "<" << strerror(errno) <<">";
-         throw NetworkError(msg.str());
+        throw NetworkError(stringize() <<
+            "SocketTCP: Accept Failed" << "<" << strerror(errno) <<">");
        }
 
 // Set the TCP_NODELAY option(Server Side)
@@ -261,13 +259,10 @@
        struct hostent *hptr = gethostbyname(server_name);
        if (NULL == hptr)
        {
-                std::stringstream msg;
-               msg << "gethostbyname gave NULL answer for hostname <"
+               throw NetworkError(stringize()
+                       << "gethostbyname gave NULL answer for hostname <"
                << server_name
-               << "> with error <"
-               << strerror(errno)
-               << ">";
-               throw NetworkError(msg.str());
+                       << "> with error <" << strerror(errno) << ">");
        }
 
        in_addr_t addr = 0;
@@ -284,20 +279,18 @@
 assert(!_est_init_tcp);
 if (!open())
        {
-                std::stringstream msg;
-               msg << "Cannot open port <" << port
+               throw NetworkError(stringize()
+                       << "Cannot open port <" << port
                        << "> on addr <" << addr2string(addr)
-                       << "> : error =" << strerror(errno);
-               throw NetworkError(msg.str());
+                       << "> : error =" << strerror(errno));
        }
 
 if (!connect(port, addr))
        {
-                std::stringstream msg;
-               msg << "Cannot connect port <" << port
+               throw NetworkError(stringize()
+                       << "Cannot connect port <" << port
                    << "> on addr <" << addr2string(addr)
-                       << "> : error =" << strerror(errno);
-               throw NetworkError(msg.str());
+                       << "> : error =" << strerror(errno));
        }
 
 _est_init_tcp = true ;
@@ -313,29 +306,26 @@
 
 if (!open())
        {
-       std::stringstream msg;
-       msg << "Cannot open port <" << port
+               throw NetworkError(stringize()
+                       << "Cannot open port <" << port
                << "> on addr <" << addr2string(addr)
-               << "> : error =" << strerror(errno);
-       throw NetworkError(msg.str());
+                       << "> : error =" << strerror(errno));
        }
 
 if (!bind(port, addr))
        {
-       std::stringstream msg;
-       msg << "Cannot bind port <" << port
+               throw NetworkError(stringize()
+                       << "Cannot bind port <" << port
                << "> on addr <" << addr2string(addr)
-               << "> : error =" << strerror(errno);
-       throw NetworkError(msg.str());
+                       << "> : error =" << strerror(errno));
        }
 
 if (!listen(MAX_BACKLOG))
        {
-       std::stringstream msg;
-       msg << "Cannot listen port <" << port
+               throw NetworkError(stringize()
+                       << "Cannot listen port <" << port
                << "> on addr <" << addr2string(addr)
-               << "> : error =" << strerror(errno);
-       throw NetworkError(msg.str());
+                       << "> : error =" << strerror(errno));
        }
 
 _est_init_tcp = true ;
@@ -587,4 +577,4 @@
 
 } // namespace
 
-// $Id: SocketTCP.cc,v 3.32 2010/03/07 18:23:39 erk Exp $
+// $Id: SocketTCP.cc,v 3.33 2010/03/14 14:38:27 gotthardp Exp $

Index: libCERTI/SocketUDP.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/SocketUDP.cc,v
retrieving revision 3.28
retrieving revision 3.29
diff -u -b -r3.28 -r3.29
--- libCERTI/SocketUDP.cc       7 Mar 2010 18:23:40 -0000       3.28
+++ libCERTI/SocketUDP.cc       14 Mar 2010 14:38:27 -0000      3.29
@@ -86,7 +86,6 @@
 {
 struct sockaddr_in sock_temp ;
 char localhost[4096] ;
-std::stringstream msg;
 struct hostent * hp_local;
 
 #ifdef _WIN32                                                          //netDot
@@ -105,12 +104,10 @@
 
 if ((hp_local = gethostbyname(localhost)) == NULL)
        {
-               msg << "gethostbyname gave NULL answer for hostname <"
+        throw NetworkError(stringize()
+            << "gethostbyname gave NULL answer for hostname <"
                        << localhost
-                       << "> with error <"
-                       << strerror(errno)
-                       << ">";
-          throw NetworkError(msg.str());
+            << "> with error <" << strerror(errno) << ">");
        }
 
        memcpy((char*)&sock_local.sin_addr,(char *)hp_local->h_addr,    
hp_local->h_length);
@@ -119,20 +116,16 @@
 sock_local.sin_family = AF_INET;
 sock_local.sin_port = 0 ;
 
-if (!open())
+    if (!open())
        {
-       msg << "Cannot Open Socket open gave error < "
-           <<  strerror(errno)
-           << ">";
-       throw NetworkError(msg.str());
+        throw NetworkError(stringize()
+            << "Cannot Open Socket open gave error < " << strerror(errno) << 
">");
        }
 
-if (!bind())
+    if (!bind())
        {
-       msg << "Cannot Bind Socket bind gave error < "
-                   <<  strerror(errno)
-                   << ">";
-       throw NetworkError(msg.str());
+        throw NetworkError(stringize()
+            << "Cannot Bind Socket bind gave error < " << strerror(errno) << 
">");
        }
 
 // recuperation du port lie au socket _socket_udp
@@ -151,7 +144,6 @@
   assert(!_est_init_udp);
 
   char localhost[MAXHOSTNAMELEN+1] ;
-  std::stringstream msg;
   struct hostent * hp_local=NULL;
 
   // Building Local Address
@@ -162,13 +154,10 @@
   hp_local = (struct hostent *) gethostbyname(localhost);
   if (NULL == hp_local)
        {
-        msg << "gethostbyname gave NULL answer for hostname <"
+        throw NetworkError(stringize()
+            << "gethostbyname gave NULL answer for hostname <"
                                << localhost
-                               << "> with error <"
-                               << strerror(errno)
-                               << ">";
-                       //perror("SocketUDP: gethostbyname");
-                  throw NetworkError(msg.str());
+            << "> with error <" << strerror(errno) << ">");
        }
 
    memcpy((char *) &sock_local.sin_addr,(char *)hp_local->h_addr, 
hp_local->h_length);

Index: libCERTI/SocketUN.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/SocketUN.cc,v
retrieving revision 3.35
retrieving revision 3.36
diff -u -b -r3.35 -r3.36
--- libCERTI/SocketUN.cc        7 Mar 2010 18:23:39 -0000       3.35
+++ libCERTI/SocketUN.cc        14 Mar 2010 14:38:27 -0000      3.36
@@ -26,7 +26,6 @@
 #include <cstdio>
 #include <cassert>
 
-#include <sstream>
 #include <string>
 #include <iostream>
 
@@ -275,13 +274,8 @@
 //! error.
 void SocketUN::error(const char *msg) throw (NetworkError)
 {
- std::stringstream smsg;
-
- smsg << "SocketUN::error <"
-         << strerror(errno)
-         << "> msg = <"
-         << msg <<">";
- throw NetworkError(smsg.str());
+    throw NetworkError(stringize() <<
+        "SocketUN::error <" << strerror(errno) << "> msg = <" << msg <<">");
 }
 
 // ----------------------------------------------------------------------------




reply via email to

[Prev in Thread] Current Thread [Next in Thread]