summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-07-11 14:30:31 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-07-11 14:30:31 (GMT)
commitd0313aeb934c66da8e51de804b1183b88d736d33 (patch)
treef4e32dc6eb44a755161a88ea8c56efa83ce6c9d2 /Swiften/Client
parent2298c1327c745d89f9128a68af9eb506b09f10e4 (diff)
downloadswift-d0313aeb934c66da8e51de804b1183b88d736d33.zip
swift-d0313aeb934c66da8e51de804b1183b88d736d33.tar.bz2
Added ClientXMLTracer.
This is a utility class that can be used to easily trace incoming and outgoing XML in bots etc.
Diffstat (limited to 'Swiften/Client')
-rw-r--r--Swiften/Client/ClientXMLTracer.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/Swiften/Client/ClientXMLTracer.h b/Swiften/Client/ClientXMLTracer.h
new file mode 100644
index 0000000..85224c8
--- /dev/null
+++ b/Swiften/Client/ClientXMLTracer.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#include "Swiften/Client/Client.h"
+
+namespace Swift {
+ class ClientXMLTracer {
+ public:
+ ClientXMLTracer(Client* client) {
+ client->onDataRead.connect(boost::bind(&ClientXMLTracer::printData, '<', _1));
+ client->onDataWritten.connect(boost::bind(&ClientXMLTracer::printData, '>', _1));
+ }
+
+ private:
+ static void printData(char direction, const String& data) {
+ printLine(direction);
+ std::cerr << data << std::endl;
+ }
+
+ static void printLine(char c) {
+ for (unsigned int i = 0; i < 80; ++i) {
+ std::cerr << c;
+ }
+ std::cerr << std::endl;
+ }
+ };
+}