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, 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"
26 using namespace Barry
;
28 #ifdef __BARRY_BOOST_MODE__
30 template <class RecordT
>
31 bool DoLoadBoostFile(const std::string
&filename
,
32 std::vector
<RecordT
> &container
,
37 std::ifstream
ifs(filename
.c_str());
38 std::getline(ifs
, dbName
);
39 boost::archive::text_iarchive
ia(ifs
);
43 catch( boost::archive::archive_exception
&ae
) {
44 errmsg
= "Archive exception in DoLoadBoostFile(): ";
50 template <class RecordT
>
51 bool DoSaveBoostFile(const std::string
&filename
,
52 const std::vector
<RecordT
> &container
,
56 std::ofstream
ofs(filename
.c_str());
57 ofs
<< RecordT::GetDBName() << endl
;
58 boost::archive::text_oarchive
oa(ofs
);
62 catch( boost::archive::archive_exception
&ae
) {
63 errmsg
= "Archive exception in DoSaveBoostFile(): ";
70 #define HANDLE_PARSER(tname) \
71 bool LoadBoostFile(const std::string &filename, \
72 std::vector<tname> &container, \
73 std::string &dbName, \
74 std::string &errmsg) \
76 return DoLoadBoostFile<tname>(filename, container, dbName, errmsg); \
78 bool SaveBoostFile(const std::string &filename, \
79 const std::vector<tname> &container, \
80 std::string &errmsg) \
82 return DoSaveBoostFile<tname>(filename, container, errmsg); \
84 ALL_KNOWN_PARSER_TYPES