| QxOrm 1.1.7 C++ Object Relational Mapping library

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

QxArchive.h
Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** http://www.qxorm.com/
    00004 ** http://sourceforge.net/projects/qxorm/
    00005 ** Original file by Lionel Marty
    00006 **
    00007 ** This file is part of the QxOrm library
    00008 **
    00009 ** This software is provided 'as-is', without any express or implied
    00010 ** warranty. In no event will the authors be held liable for any
    00011 ** damages arising from the use of this software.
    00012 **
    00013 ** GNU Lesser General Public License Usage
    00014 ** This file must be used under the terms of the GNU Lesser
    00015 ** General Public License version 2.1 as published by the Free Software
    00016 ** Foundation and appearing in the file 'license.lgpl.txt' included in the
    00017 ** packaging of this file.  Please review the following information to
    00018 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00019 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00020 **
    00021 ** If you have questions regarding the use of this file, please contact :
    00022 ** contact@qxorm.com
    00023 **
    00024 ****************************************************************************/
    00025
    00026 #ifndef _QX_ARCHIVE_H_
    00027 #define _QX_ARCHIVE_H_
    00028
    00029 #ifdef _MSC_VER
    00030 #pragma once
    00031 #endif
    00032
    00040 #include <string>
    00041 #include <iostream>
    00042 #include <sstream>
    00043 #include <fstream>
    00044 #include <exception>
    00045
    00046 #include <boost/archive/archive_exception.hpp>
    00047 #include <boost/serialization/serialization.hpp>
    00048 #include <boost/serialization/nvp.hpp>
    00049
    00050 #include <QxTraits/archive_wide_traits.h>
    00051 #include <QxTraits/get_class_name.h>
    00052 #include <QxTraits/is_qx_registered.h>
    00053
    00054 #include <QxCommon/QxConfig.h>
    00055 #include <QxCommon/QxBool.h>
    00056
    00057 #include <QxRegister/QxClass.h>
    00058 #include <QxRegister/QxClassName.h>
    00059
    00060 #include <QxSerialize/QxSerializeMacro.h>
    00061 #include <QxSerialize/boost/QxSerializeInclude.h>
    00062 #include <QxSerialize/QxBoostSerializeHelper/QxBoostSerializeRegisterHelperX.h>
    00063
    00064 #define QX_STR_SERIALIZATION_ERROR "Serialization error : '%ERR%'"
    00065 #define QX_STR_DESERIALIZATION_ERROR "Deserialization error : '%ERR%'"
    00066
    00067 namespace qx {
    00068
    00073 template <class T, class ArchiveInput = QX_DEFAULT_ARCHIVE_INPUT, class ArchiveOutput = QX_DEFAULT_ARCHIVE_OUTPUT>
    00074 class QxArchive
    00075 {
    00076
    00077 public:
    00078
    00079    typedef typename qx::trait::archive_wide_traits<ArchiveInput>::type_string type_string;
    00080
    00081    static qx_bool toFile(const T & obj, const QString & sFileName, unsigned int flags = boost::archive::no_header);
    00082    static qx_bool fromFile(T & obj, const QString & sFileName, unsigned int flags = boost::archive::no_header);
    00083
    00084    static qx_bool toFileCompressed(const T & obj, const QString & sFileName, unsigned int flags = boost::archive::no_header, int iCompressionLevel = -1);
    00085    static qx_bool fromFileCompressed(T & obj, const QString & sFileName, unsigned int flags = boost::archive::no_header);
    00086
    00087    static QString toString(const T & obj, unsigned int flags = boost::archive::no_header);
    00088    static qx_bool fromString(T & obj, const QString & sString, unsigned int flags = boost::archive::no_header);
    00089
    00090    static QByteArray toByteArray(const T & obj, type_string * owner = NULL, unsigned int flags = boost::archive::no_header);
    00091    static qx_bool fromByteArray(T & obj, const QByteArray & data, unsigned int flags = boost::archive::no_header);
    00092
    00093 };
    00094
    00095 } // namespace qx
    00096
    00097 #include "../../inl/QxSerialize/QxArchive.inl"
    00098
    00099 namespace qx {
    00100 namespace serialization {
    00101
    00102 QX_ARCHIVE_NAMESPACE_FCT_IMPL(T, QX_DEFAULT_ARCHIVE_INPUT, QX_DEFAULT_ARCHIVE_OUTPUT)
    00103
    00104 #if _QX_SERIALIZE_POLYMORPHIC
    00105
    00110 namespace polymorphic_binary {      QX_ARCHIVE_NAMESPACE_FCT_IMPL(T, boost::archive::polymorphic_binary_iarchive, boost::archive::polymorphic_binary_oarchive)
    00111 } // namespace polymorphic_binary
    00112
    00117 namespace polymorphic_text {        QX_ARCHIVE_NAMESPACE_FCT_IMPL(T, boost::archive::polymorphic_text_iarchive, boost::archive::polymorphic_text_oarchive)
    00118 } // namespace polymorphic_text
    00119
    00124 namespace polymorphic_xml {         QX_ARCHIVE_NAMESPACE_FCT_IMPL(T, boost::archive::polymorphic_xml_iarchive, boost::archive::polymorphic_xml_oarchive)
    00125 } // namespace polymorphic_xml
    00126
    00127 #endif // _QX_SERIALIZE_POLYMORPHIC
    00128
    00129 #if _QX_SERIALIZE_BINARY
    00130
    00135 namespace binary {            QX_ARCHIVE_NAMESPACE_FCT_IMPL(T, boost::archive::binary_iarchive, boost::archive::binary_oarchive)
    00136 } // namespace binary
    00137
    00138 #endif // _QX_SERIALIZE_BINARY
    00139
    00140 #if _QX_SERIALIZE_TEXT
    00141
    00146 namespace text {              QX_ARCHIVE_NAMESPACE_FCT_IMPL(T, boost::archive::text_iarchive, boost::archive::text_oarchive)
    00147 } // namespace text
    00148
    00149 #endif // _QX_SERIALIZE_TEXT
    00150
    00151 #if _QX_SERIALIZE_XML
    00152
    00157 namespace xml {               QX_ARCHIVE_NAMESPACE_FCT_IMPL(T, boost::archive::xml_iarchive, boost::archive::xml_oarchive)
    00158 } // namespace xml
    00159
    00160 #endif // _QX_SERIALIZE_XML
    00161
    00162 #if _QX_SERIALIZE_PORTABLE_BINARY
    00163
    00168 namespace portable_binary {   QX_ARCHIVE_NAMESPACE_FCT_IMPL(T, eos::portable_iarchive, eos::portable_oarchive)
    00169 } // namespace portable_binary
    00170
    00171 #endif // _QX_SERIALIZE_PORTABLE_BINARY
    00172
    00173 namespace wide {
    00174
    00175 #if _QX_SERIALIZE_WIDE_BINARY
    00176
    00181 namespace binary {            QX_ARCHIVE_NAMESPACE_FCT_IMPL(T, boost::archive::binary_wiarchive, boost::archive::binary_woarchive)
    00182 } // namespace binary
    00183
    00184 #endif // _QX_SERIALIZE_WIDE_BINARY
    00185
    00186 #if _QX_SERIALIZE_WIDE_TEXT
    00187
    00192 namespace text {              QX_ARCHIVE_NAMESPACE_FCT_IMPL(T, boost::archive::text_wiarchive, boost::archive::text_woarchive)
    00193 } // namespace text
    00194
    00195 #endif // _QX_SERIALIZE_WIDE_TEXT
    00196
    00197 #if _QX_SERIALIZE_WIDE_XML
    00198
    00203 namespace xml {               QX_ARCHIVE_NAMESPACE_FCT_IMPL(T, boost::archive::xml_wiarchive, boost::archive::xml_woarchive)
    00204 } // namespace xml
    00205
    00206 #endif // _QX_SERIALIZE_WIDE_XML
    00207
    00208 } // namespace wide
    00209 } // namespace serialization
    00210 } // namespace qx
    00211
    00212 #endif // _QX_ARCHIVE_H_

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines