* 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 "registrar.h"
#include "ex.h"
#include "lst.h"
+#ifdef HAVE_CONFIG_H
#include "config.h"
-#include "tostring.h"
+#endif
+#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)"));
+ constexpr unsigned max_version = GINACLIB_ARCHIVE_VERSION;
+ constexpr 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 " + std::to_string(version) + " cannot be read by this GiNaC library (which supports versions " + std::to_string(min_version) + " thru " + std::to_string(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];
}
}
}
-/** Create a dummy archive. The intention is to fill archive_node's default
- * ctor, which is currently a Cint-requirement. */
-archive* archive_node::dummy_ar_creator()
-{
- static archive* some_ar = new archive;
- return some_ar;
-}
-
} // namespace GiNaC