Here is my solution of this problem and it works without _WIDE_XML.
I modified QxSerialize_QString.cpp and it supports cyrilic QString now:
- Code: Select all
/****************************************************************************
**
** http://www.qxorm.com/
** http://sourceforge.net/projects/qxorm/
** Original file by Lionel Marty
**
** This file is part of the QxOrm library
**
** This software is provided 'as-is', without any express or implied
** warranty. In no event will the authors be held liable for any
** damages arising from the use of this software.
**
** GNU Lesser General Public License Usage
** This file must be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file 'license.lgpl.txt' included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you have questions regarding the use of this file, please contact :
** contact@qxorm.com
**
****************************************************************************/
#include <QxPrecompiled.h>
#include <QxSerialize/Qt/QxSerialize_QString.h>
#include <QxTraits/archive_wide_traits.h>
#include <QxTraits/archive_printable.h>
#include <QxMemLeak.h>
#include <vector>
#include <QtCore/QString>
#include <QtCore/QVector>
#include <boost/serialization/nvp.hpp>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/serialization/vector.hpp>
namespace boost {
namespace serialization {
template <bool isPrintable = false>
struct qx_serialize_qstring
{
template <class Archive>
static inline void save(Archive & ar, const QString & t, const unsigned int /*file_version*/)
{
std::vector<uint> tmp = t.toUcs4().toStdVector();
ar << boost::serialization::make_nvp("QString2Usc4", tmp);
}
template <class Archive>
static inline void load(Archive & ar, QString & t, const unsigned int /*file_version*/)
{
std::vector<uint> tmp;
ar >> boost::serialization::make_nvp("QString2Usc4", tmp);
t = QString::fromUcs4(&tmp[0],tmp.size());
}
};
template <>
struct qx_serialize_qstring<true>
{
template <class Archive>
static inline void save(Archive & ar, const QString & t, const unsigned int /*file_version*/)
{
std::vector<uint> tmp = t.toUcs4().toStdVector();
ar << boost::serialization::make_nvp("QString2Usc4", tmp);
}
template <class Archive>
static inline void load(Archive & ar, QString & t, const unsigned int /*file_version*/)
{
std::vector<uint> tmp;
ar >> boost::serialization::make_nvp("QString2Usc4", tmp);
t = QString::fromUcs4(&tmp[0],tmp.size());
}
};
template <class Archive>
inline void qx_save(Archive & ar, const QString & t, const unsigned int file_version)
{
qx_serialize_qstring<qx::trait::is_archive_printable<Archive>::value>::save(ar, t, file_version);
}
template <class Archive>
inline void qx_load(Archive & ar, QString & t, const unsigned int file_version)
{
qx_serialize_qstring<qx::trait::is_archive_printable<Archive>::value>::load(ar, t, file_version);
}
} // namespace boost
} // namespace serialization
QX_SERIALIZE_FAST_COMPIL_SAVE_LOAD_CPP(QString)
I changed save and load methods. And it works perfect.