* Archiving of GiNaC expressions. */
/*
- * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2000 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"
#include "utils.h"
-#ifndef NO_GINAC_NAMESPACE
+#ifndef NO_NAMESPACE_GINAC
namespace GiNaC {
-#endif // ndef NO_GINAC_NAMESPACE
+#endif // ndef NO_NAMESPACE_GINAC
/** Archive an expression.
* - unsigned root node ID
* - unsigned number of nodes
* - unsigned number of properties
- * - unsigned type (PTYPE_*)
- * - unsigned name atom
+ * - unsigned containing type (PTYPE_*) in its lower 3 bits and
+ * name atom in the upper bits
* - unsigned property value
*
* Unsigned quantities are stored in a compressed format:
unsigned int num_props = n.props.size();
write_unsigned(os, num_props);
for (unsigned int i=0; i<num_props; i++) {
- write_unsigned(os, n.props[i].type);
- write_unsigned(os, n.props[i].name);
+ write_unsigned(os, n.props[i].type | (n.props[i].name << 3));
write_unsigned(os, n.props[i].value);
}
+ return os;
}
/** Write archive to binary data stream. */
write_unsigned(os, num_nodes);
for (unsigned int i=0; i<num_nodes; i++)
os << ar.nodes[i];
+ return os;
}
/** Read archive_node from binary data stream. */
unsigned int num_props = read_unsigned(is);
n.props.resize(num_props);
for (unsigned int i=0; i<num_props; i++) {
- n.props[i].type = (archive_node::property_type)read_unsigned(is);
- n.props[i].name = read_unsigned(is);
+ unsigned int name_type = read_unsigned(is);
+ n.props[i].type = (archive_node::property_type)(name_type & 7);
+ n.props[i].name = name_type >> 3;
n.props[i].value = read_unsigned(is);
}
+ return is;
}
/** Read archive from binary data stream. */
ar.nodes.resize(num_nodes, ar);
for (unsigned int i=0; i<num_nodes; i++)
is >> ar.nodes[i];
+ return is;
}
}
-/** Dump archive to stream (for debugging). */
-void archive::dump(ostream &os) const
+/** Print archive to stream in ugly raw format (for debugging). */
+void archive::printraw(ostream &os) const
{
// Dump atoms
os << "Atoms:\n";
archive_node_id id = 0;
while (i != iend) {
os << " " << id << " ";
- i->dump(os);
+ i->printraw(os);
i++; id++;
}
}
}
-/** Dump archive_node to stream (for debugging). */
-void archive_node::dump(ostream &os) const
+/** Output archive_node to stream in ugly raw format (for debugging). */
+void archive_node::printraw(ostream &os) const
{
// Dump cached unarchived expression
if (has_expression)
os << "(basic * " << e.bp << " = " << e << ")\n";
else
- os << "(no expression)\n";
+ os << "\n";
// Dump properties
vector<property>::const_iterator i = props.begin(), iend = props.end();
}
}
+/** 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(void)
+{
+ static archive* some_ar = new archive;
+ return some_ar;
+}
+
-#ifndef NO_GINAC_NAMESPACE
+#ifndef NO_NAMESPACE_GINAC
} // namespace GiNaC
-#endif // ndef NO_GINAC_NAMESPACE
+#endif // ndef NO_NAMESPACE_GINAC