3 /// Wrap Boost serialization into its own lib, so each usage
4 /// in the tools doesn't cause a compile speed meltdown.
8 Copyright (C) 2012-2013, Net Direct Inc. (http://www.netdirect.ca/)
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 See the GNU General Public License in the COPYING file at the
20 root directory of this project for more details.
23 #include "boostwrap.h"
27 using namespace Barry
;
29 #ifdef __BARRY_BOOST_MODE__
31 template <class RecordT
>
32 bool DoLoadBoostFile(const std::string
&filename
,
33 std::vector
<RecordT
> &container
,
38 std::ifstream
ifs(filename
.c_str());
39 std::getline(ifs
, dbName
);
40 boost::archive::text_iarchive
ia(ifs
);
44 catch( boost::archive::archive_exception
&ae
) {
45 errmsg
= _("Archive exception in DoLoadBoostFile(): ");
51 template <class RecordT
>
52 bool DoSaveBoostFile(const std::string
&filename
,
53 const std::vector
<RecordT
> &container
,
57 std::ofstream
ofs(filename
.c_str());
58 ofs
<< RecordT::GetDBName() << endl
;
59 boost::archive::text_oarchive
oa(ofs
);
63 catch( boost::archive::archive_exception
&ae
) {
64 errmsg
= _("Archive exception in DoSaveBoostFile(): ");
71 #define HANDLE_PARSER(tname) \
72 bool LoadBoostFile(const std::string &filename, \
73 std::vector<tname> &container, \
74 std::string &dbName, \
75 std::string &errmsg) \
77 return DoLoadBoostFile<tname>(filename, container, dbName, errmsg); \
79 bool SaveBoostFile(const std::string &filename, \
80 const std::vector<tname> &container, \
81 std::string &errmsg) \
83 return DoSaveBoostFile<tname>(filename, container, errmsg); \
85 ALL_KNOWN_PARSER_TYPES