diff options
Diffstat (limited to 'Swiften/Component')
-rw-r--r-- | Swiften/Component/ComponentXMLTracer.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Swiften/Component/ComponentXMLTracer.h b/Swiften/Component/ComponentXMLTracer.h new file mode 100644 index 0000000..512e69c --- /dev/null +++ b/Swiften/Component/ComponentXMLTracer.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2010 Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#pragma once + +#include <boost/bind.hpp> + +#include "Swiften/Component/Component.h" + +namespace Swift { + class ComponentXMLTracer { + public: + ComponentXMLTracer(Component* component) { + component->onDataRead.connect(boost::bind(&ComponentXMLTracer::printData, '<', _1)); + component->onDataWritten.connect(boost::bind(&ComponentXMLTracer::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; + } + }; +} |