* Archiving of GiNaC expressions. */
/*
- * GiNaC Copyright (C) 1999-2011 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2015 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "config.h"
#endif
#include "tostring.h"
+#include "version.h"
#include <iostream>
#include <stdexcept>
os.put('A');
os.put('R');
os.put('C');
- write_unsigned(os, ARCHIVE_VERSION);
+ write_unsigned(os, GINACLIB_ARCHIVE_VERSION);
// Write atoms
unsigned num_atoms = ar.atoms.size();
is.get(c1); is.get(c2); is.get(c3); is.get(c4);
if (c1 != 'G' || c2 != 'A' || c3 != 'R' || c4 != 'C')
throw (std::runtime_error("not a GiNaC archive (signature not found)"));
+ static const unsigned max_version = GINACLIB_ARCHIVE_VERSION;
+ static const unsigned min_version = GINACLIB_ARCHIVE_VERSION - GINACLIB_ARCHIVE_AGE;
unsigned version = read_unsigned(is);
- if (version > ARCHIVE_VERSION || version < ARCHIVE_VERSION - ARCHIVE_AGE)
- throw (std::runtime_error("archive version " + ToString(version) + " cannot be read by this GiNaC library (which supports versions " + ToString(ARCHIVE_VERSION-ARCHIVE_AGE) + " thru " + ToString(ARCHIVE_VERSION)));
+ if ((version > max_version) || (version < min_version))
+ throw (std::runtime_error("archive version " + ToString(version) + " cannot be read by this GiNaC library (which supports versions " + ToString(min_version) + " thru " + ToString(max_version)));
// Read atoms
unsigned num_atoms = read_unsigned(is);
const std::string &archive::unatomize(archive_atom id) const
{
if (id >= atoms.size())
- throw (std::range_error("archive::unatomizee(): atom ID out of range"));
+ throw (std::range_error("archive::unatomize(): atom ID out of range"));
return atoms[id];
}