00001 #ifndef QPID_AMQP_0_10_SERIALIZABLESTRING_H
00002 #define QPID_AMQP_0_10_SERIALIZABLESTRING_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 namespace qpid {
00025 namespace amqp_0_10 {
00026
00031 template <class T, class SizeType, int Unique=0>
00032 struct SerializableString : public std::basic_string<T> {
00033 SerializableString() {}
00034 template <class U> SerializableString(const U& u) : std::basic_string<T>(u) {}
00035 template <class I> SerializableString(const I& i, const I& j) : std::basic_string<T>(i,j) {}
00036
00037 using std::basic_string<T>::operator=;
00038
00039 template <class S> void serialize(S& s) { s.split(*this); }
00040
00041 template <class S> void encode(S& s) const {
00042 s(SizeType(this->size()))(this->begin(), this->end());
00043 }
00044
00045 template <class S> void decode(S& s) {
00046 SizeType newSize;
00047 s(newSize);
00048 this->resize(newSize);
00049 s(this->begin(), this->end());
00050 }
00051 };
00052
00053
00054 template <class T, class SizeType>
00055 std::ostream& operator<<(std::ostream& o, const SerializableString<T,SizeType>& s) {
00056 const std::basic_string<T> str(s);
00057 return o << str.c_str();
00058 }
00059
00060 }}
00061
00062 #endif