Exemplo n.º 1
0
void IQmol::saveData(QString const& filePath, Data::Bank& data)
{
   std::ofstream ofs(filePath.toStdString().data(), std::ios_base::binary);
   if (ofs.is_open()) {
      boost::iostreams::filtering_ostream filter;
      filter.push(boost::iostreams::gzip_compressor());
      filter.push(ofs);
      boost::archive::text_oarchive outputArchive(filter);
      data.serialize(outputArchive, 0);
   }else {
      QString msg("Failed to open file for write: ");
      msg += filePath;
      m_errors.append(msg);
    }
}
Exemplo n.º 2
0
// Note the Bank should be a const&, but the serialize functions are declared
// non-const for some Boost-related reason.
bool IQmol::save(QString const& filePath, Data::Bank& data)
{
   std::ofstream ofs(filePath.toStdString().data(), std::ios_base::binary);
   if (ofs.is_open()) {
      boost::iostreams::filtering_ostream filter;
#ifdef Q_OS_MAC
      // Can't get this working on Windows
      filter.push(boost::iostreams::gzip_compressor());
#endif
      filter.push(ofs);
      boost::archive::text_oarchive outputArchive(filter);
      data.serialize(outputArchive, 0);
   }else {
      QString msg("Failed to open file for write: ");
      msg += filePath;
      m_errors.append(msg);
    }

    return m_errors.isEmpty();
}