qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject svn commit: r1163275 - in /qpid/trunk/qpid/cpp: include/qpid/Msg.h src/Makefile.am src/qpid/Msg.cpp src/qpid/log/Statement.cpp
Date Tue, 30 Aug 2011 16:21:00 GMT
Author: aconway
Date: Tue Aug 30 16:21:00 2011
New Revision: 1163275

URL: http://svn.apache.org/viewvc?rev=1163275&view=rev
Log:
NO-JIRA: Revert change to Msg.h introduced in r1162273

The change did not compile on windows due to EXTERN declaration issues.
Changes has been backed out as it is not critical and can be addressed elsewhere.

Modified:
    qpid/trunk/qpid/cpp/include/qpid/Msg.h
    qpid/trunk/qpid/cpp/src/Makefile.am
    qpid/trunk/qpid/cpp/src/qpid/Msg.cpp
    qpid/trunk/qpid/cpp/src/qpid/log/Statement.cpp

Modified: qpid/trunk/qpid/cpp/include/qpid/Msg.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qpid/Msg.h?rev=1163275&r1=1163274&r2=1163275&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/include/qpid/Msg.h (original)
+++ qpid/trunk/qpid/cpp/include/qpid/Msg.h Tue Aug 30 16:21:00 2011
@@ -42,7 +42,7 @@ struct Msg {
     std::ostringstream os;
     Msg() {}
     Msg(const Msg& m) : os(m.str()) {}
-    QPID_TYPES_EXTERN std::string str() const;
+    std::string str() const { return os.str(); }
     operator std::string() const { return str(); }
 
     Msg& operator<<(long n) { os << n; return *this; }

Modified: qpid/trunk/qpid/cpp/src/Makefile.am
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/Makefile.am?rev=1163275&r1=1163274&r2=1163275&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/Makefile.am (original)
+++ qpid/trunk/qpid/cpp/src/Makefile.am Tue Aug 30 16:21:00 2011
@@ -744,7 +744,6 @@ libqpidclient_la_LDFLAGS = -version-info
 
 libqpidtypes_la_LIBADD= -luuid
 libqpidtypes_la_SOURCES=			\
-  qpid/Msg.cpp					\
   qpid/types/Exception.cpp			\
   qpid/types/Uuid.cpp				\
   qpid/types/Variant.cpp			\

Modified: qpid/trunk/qpid/cpp/src/qpid/log/Statement.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/log/Statement.cpp?rev=1163275&r1=1163274&r2=1163275&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/log/Statement.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/log/Statement.cpp Tue Aug 30 16:21:00 2011
@@ -24,9 +24,32 @@
 #include <ctype.h>
 
 namespace qpid {
-std::string quote(const std::string& str); // Defined in Msg.cpp
 namespace log {
 
+namespace {
+struct NonPrint { bool operator()(unsigned char c) { return !isprint(c) && !isspace(c);
} };
+
+const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D',
'E', 'F' };
+
+std::string quote(const std::string& str) {
+    NonPrint nonPrint;
+    size_t n = std::count_if(str.begin(), str.end(), nonPrint);
+    if (n==0) return str;
+    std::string ret;
+    ret.reserve(str.size()+2*n); // Avoid extra allocations.
+    for (std::string::const_iterator i = str.begin(); i != str.end(); ++i) {
+        if (nonPrint(*i)) {
+            ret.push_back('\\');
+            ret.push_back('x');
+            ret.push_back(hex[((*i) >> 4)&0xf]);
+            ret.push_back(hex[(*i) & 0xf]);
+        }
+        else ret.push_back(*i);
+    }
+    return ret;
+}
+}
+
 void Statement::log(const std::string& message) {
     Logger::instance().log(*this, quote(message));
 }



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message