File "SF/include/QString.hpp"
Code: Select all
#ifndef INCLUDE_SF_QSTRING_HPP
#define INCLUDE_SF_QSTRING_HPP
#include <QByteArray>
#include <QString>
#include <boost/config.hpp>
#include <SF/Archive.hpp>
#include <SF/Stream.hpp>
namespace SF {
// QString
inline void serialize_vc6(SF::Archive & ar, QString & qs, const unsigned int)
{
if (ar.isRead())
{
boost::uint32_t count = 0;
ar & count;
qs.resize(0);
if (count)
{
SF::IStream &is = *ar.getIstream();
QByteArray qba(count, 0); // init buffer and fill zero
// Size field is verified, so read everything in one go.
RCF_VERIFY(
is.read(qba.data(), count) == count,
RCF::Exception(RCF::_SfError_ReadFailure()))
(count);
// Appends the byte array (qba) to this string.
// The given byte array is converted to Unicode using the fromUtf8() function.
qs.append(qba);
}
}
else if (ar.isWrite())
{
QByteArray qba(qs.toUtf8());
boost::uint32_t count = static_cast<boost::uint32_t >(qba.size());
ar & count;
ar.getOstream()->writeRaw(qba.data(), count);
}
}
} // namespace SF
#endif // ! INCLUDE_SF_QSTRING_HPP
Code: Select all
#ifndef INCLUDE_SF_QLIST_HPP
#define INCLUDE_SF_QLIST_HPP
#include <QList>
#include <SF/SerializeStl.hpp>
namespace SF {
// QList
template<typename T>
inline void serialize_vc6(SF::Archive &ar, QList<T> &t, const unsigned int)
{
serializeStlContainer<PushBackSemantics, NoReserveSemantics>(ar, t);
}
} // namespace SF
#endif // ! INCLUDE_SF_QLIST_HPP
Code: Select all
#ifndef INCLUDE_SF_QSTRINGLIST_HPP
#define INCLUDE_SF_QSTRINGLIST_HPP
#include <QStringList>
#include <SF/SerializeStl.hpp>
namespace SF {
// QStringList
inline void serialize_vc6(SF::Archive &ar, QStringList &t, const unsigned int)
{
serializeStlContainer<PushBackSemantics, NoReserveSemantics>(ar, t);
}
} // namespace SF
#endif // ! INCLUDE_SF_QSTRINGLIST_HPP