GiNaC 1.8.7
|
This class holds archived versions of GiNaC expressions (class ex). More...
#include <archive.h>
Classes | |
struct | archived_ex |
Archived expression descriptor. More... | |
Public Member Functions | |
archive () | |
~archive () | |
archive (const ex &e) | |
Construct archive from expression using the default name "ex". More... | |
archive (const ex &e, const char *n) | |
Construct archive from expression using the specified name. More... | |
void | archive_ex (const ex &e, const char *name) |
Archive an expression. More... | |
ex | unarchive_ex (const lst &sym_lst, const char *name) const |
Retrieve expression from archive by name. More... | |
ex | unarchive_ex (const lst &sym_lst, unsigned index=0) const |
Retrieve expression from archive by index. More... | |
ex | unarchive_ex (const lst &sym_lst, std::string &name, unsigned index=0) const |
Retrieve expression and its name from archive by index. More... | |
unsigned | num_expressions () const |
Return number of archived expressions. More... | |
const archive_node & | get_top_node (unsigned index=0) const |
Return reference to top node of an expression specified by index. More... | |
void | clear () |
Clear all archived expressions. More... | |
archive_node_id | add_node (const archive_node &n) |
Add archive_node to archive if the corresponding expression is not already archived. More... | |
archive_node & | get_node (archive_node_id id) |
Retrieve archive_node by ID. More... | |
void | forget () |
Delete cached unarchived expressions in all archive_nodes (mainly for debugging). More... | |
void | printraw (std::ostream &os) const |
Print archive to stream in ugly raw format (for debugging). More... | |
archive_atom | atomize (const std::string &s) const |
Atomize a string (i.e. More... | |
const std::string & | unatomize (archive_atom id) const |
Unatomize a string (i.e. More... | |
Private Types | |
typedef std::map< std::string, archive_atom >::const_iterator | inv_at_cit |
The map of from strings to indices of the atoms vectors allows for faster archiving. More... | |
Private Attributes | |
std::vector< archive_node > | nodes |
Vector of archived nodes. More... | |
std::vector< archived_ex > | exprs |
Vector of archived expression descriptors. More... | |
std::vector< std::string > | atoms |
Vector of atomized strings (using a vector allows faster unarchiving). More... | |
std::map< std::string, archive_atom > | inverse_atoms |
std::map< ex, archive_node_id, ex_is_less > | exprtable |
Map of stored expressions to nodes for faster archiving. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const archive &ar) |
Write archive to binary data stream. More... | |
std::istream & | operator>> (std::istream &is, archive &ar) |
Read archive from binary data stream. More... | |
This class holds archived versions of GiNaC expressions (class ex).
An archive can be constructed from an expression and then written to a stream; or it can be read from a stream and then unarchived, yielding back the expression. Archives can hold multiple expressions which can be referred to by name or index number. The main component of the archive class is a vector of archive_nodes which each store one object of class basic (or a derived class).
|
private |
|
inline |
Construct archive from expression using the default name "ex".
Definition at line 264 of file archive.h.
References archive_ex().
|
inline |
Construct archive from expression using the specified name.
Definition at line 267 of file archive.h.
References archive_ex(), and n.
void GiNaC::archive::archive_ex | ( | const ex & | e, |
const char * | name | ||
) |
Archive an expression.
e | the expression to be archived |
name | name under which the expression is stored |
Definition at line 35 of file archive.cpp.
References add_node(), atomize(), and exprs.
Referenced by archive().
Retrieve expression from archive by name.
sym_lst | list of pre-defined symbols |
name | name of expression |
Definition at line 78 of file archive.cpp.
Retrieve expression from archive by index.
sym_lst | list of pre-defined symbols |
index | index of expression |
Definition at line 97 of file archive.cpp.
ex GiNaC::archive::unarchive_ex | ( | const lst & | sym_lst, |
std::string & | name, | ||
unsigned | index = 0 |
||
) | const |
Retrieve expression and its name from archive by index.
sym_lst | list of pre-defined symbols |
name | receives the name of the expression |
index | index of expression |
Definition at line 107 of file archive.cpp.
References exprs, nodes, and unatomize().
unsigned GiNaC::archive::num_expressions | ( | ) | const |
Return number of archived expressions.
Definition at line 120 of file archive.cpp.
References exprs.
const archive_node & GiNaC::archive::get_top_node | ( | unsigned | index = 0 | ) | const |
Return reference to top node of an expression specified by index.
Definition at line 125 of file archive.cpp.
void GiNaC::archive::clear | ( | ) |
Clear all archived expressions.
Definition at line 599 of file archive.cpp.
References atoms, exprs, exprtable, inverse_atoms, and nodes.
archive_node_id GiNaC::archive::add_node | ( | const archive_node & | n | ) |
Add archive_node to archive if the corresponding expression is not already archived.
Definition at line 50 of file archive.cpp.
References exprtable, n, and nodes.
Referenced by GiNaC::archive_node::add_ex(), and archive_ex().
archive_node & GiNaC::archive::get_node | ( | archive_node_id | id | ) |
Retrieve archive_node by ID.
Definition at line 69 of file archive.cpp.
References nodes.
Referenced by GiNaC::archive_node::find_ex(), GiNaC::archive_node::find_ex_by_loc(), and GiNaC::archive_node::find_ex_node().
void GiNaC::archive::forget | ( | ) |
Delete cached unarchived expressions in all archive_nodes (mainly for debugging).
Definition at line 610 of file archive.cpp.
References GiNaC::archive_node::forget(), and nodes.
void GiNaC::archive::printraw | ( | std::ostream & | os | ) | const |
Print archive to stream in ugly raw format (for debugging).
Definition at line 624 of file archive.cpp.
References atoms, exprs, nodes, and unatomize().
archive_atom GiNaC::archive::atomize | ( | const std::string & | s | ) | const |
Atomize a string (i.e.
convert it into an ID number that uniquely represents the string).
Definition at line 301 of file archive.cpp.
References atoms, and inverse_atoms.
Referenced by GiNaC::archive_node::add_bool(), GiNaC::archive_node::add_ex(), GiNaC::archive_node::add_string(), GiNaC::archive_node::add_unsigned(), archive_ex(), GiNaC::archive_node::find_bool(), GiNaC::archive_node::find_ex(), GiNaC::archive_node::find_ex_node(), GiNaC::archive_node::find_first(), GiNaC::archive_node::find_last(), GiNaC::archive_node::find_property_range(), GiNaC::archive_node::find_string(), GiNaC::archive_node::find_unsigned(), and unarchive_ex().
const std::string & GiNaC::archive::unatomize | ( | archive_atom | id | ) | const |
Unatomize a string (i.e.
convert the ID number back to the string).
Definition at line 316 of file archive.cpp.
References atoms.
Referenced by GiNaC::archive_node::find_string(), GiNaC::archive_node::get_properties(), GiNaC::archive_node::printraw(), printraw(), and unarchive_ex().
|
friend |
Write archive to binary data stream.
Definition at line 213 of file archive.cpp.
|
friend |
Read archive from binary data stream.
Definition at line 260 of file archive.cpp.
|
private |
Vector of archived nodes.
Definition at line 309 of file archive.h.
Referenced by add_node(), clear(), forget(), get_node(), get_top_node(), printraw(), and unarchive_ex().
|
private |
Vector of archived expression descriptors.
Definition at line 321 of file archive.h.
Referenced by archive_ex(), clear(), get_top_node(), num_expressions(), printraw(), and unarchive_ex().
|
mutableprivate |
Vector of atomized strings (using a vector allows faster unarchiving).
Definition at line 329 of file archive.h.
Referenced by atomize(), clear(), printraw(), and unatomize().
|
mutableprivate |
|
mutableprivate |
Map of stored expressions to nodes for faster archiving.
Definition at line 337 of file archive.h.
Referenced by add_node(), and clear().