Date: Tuesday, January 9, 2007 @ 20:28:26
Author: marc
Path: /cvsroot/carob/carob
Modified: include/ControllerInfo.hpp (1.6 -> 1.7) src/ControllerInfo.cpp
(1.11 -> 1.12)
Added pretty-printing operator<< for ControllerInfo and vector<ControllerInfo>
----------------------------+
include/ControllerInfo.hpp | 5 +++++
src/ControllerInfo.cpp | 23 ++++++++++++++++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)
Index: carob/include/ControllerInfo.hpp
diff -u carob/include/ControllerInfo.hpp:1.6
carob/include/ControllerInfo.hpp:1.7
--- carob/include/ControllerInfo.hpp:1.6 Fri Dec 22 11:21:07 2006
+++ carob/include/ControllerInfo.hpp Tue Jan 9 20:28:26 2007
@@ -97,6 +97,9 @@
* @return sql query as a string
*/
operator std::wstring () const;
+
+ friend std::wostream& CarobNS::operator<< (std::wostream& ostr, const
ControllerInfo& ci);
+
private:
/**
* Retrieves all socket addresses for the controller identified by the given
@@ -114,5 +117,7 @@
SocketAddress socket_address;
};
+std::wostream& operator<< (std::wostream& ostr, const
std::vector<ControllerInfo>& clist);
+
} //namespace CarobNS
#endif /*CONTROLLER_INFO_HPP_*/
Index: carob/src/ControllerInfo.cpp
diff -u carob/src/ControllerInfo.cpp:1.11 carob/src/ControllerInfo.cpp:1.12
--- carob/src/ControllerInfo.cpp:1.11 Thu Dec 21 23:23:17 2006
+++ carob/src/ControllerInfo.cpp Tue Jan 9 20:28:26 2007
@@ -27,6 +27,8 @@
#include "Common.hpp" //for logging
#include <sstream> //for wostringstream
+#include <vector>
+
using namespace CarobNS;
using std::wstring;
@@ -190,10 +192,29 @@
ControllerInfo::operator std::wstring() const
{
std::wostringstream msg;
- msg<<original_hostname<<L" ("<<*(socket_address.getAddressPtr())<<L")";
+ msg<< *this;
return msg.str();
}
+std::wostream& CarobNS::operator<< (std::wostream& ostr, const ControllerInfo&
ci)
+{
+ return ostr << ci.original_hostname<<L"
("<<*(ci.socket_address.getAddressPtr())<<L")";
+}
+
+std::wostream& CarobNS::operator<< (std::wostream& ostr, const
std::vector<ControllerInfo>& clist)
+{
+ ostr << L"[";
+ for (std::vector<ControllerInfo>::const_iterator iter = clist.begin();
+ iter != clist.end(); iter++)
+ {
+ ostr << *iter;
+ if (iter+1 != clist.end())
+ ostr << L", ";
+ }
+ ostr << L"]";
+ return ostr;
+}
+
/*
Typically used like this:
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits