X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fstlplus%2Fpersistence%2Fpersistent_shortcuts.hpp;fp=src%2Fstlplus%2Fpersistence%2Fpersistent_shortcuts.hpp;h=beb54d0c6902cbca6d1f2fa0a1f5bed0a0504b68;hb=6b0a0d0efafe34d48ab344fca3b479553bd4e62c;hp=0000000000000000000000000000000000000000;hpb=85783316365181491a3e3c0c63659972477cebba;p=chaz%2Fyoink diff --git a/src/stlplus/persistence/persistent_shortcuts.hpp b/src/stlplus/persistence/persistent_shortcuts.hpp new file mode 100644 index 0000000..beb54d0 --- /dev/null +++ b/src/stlplus/persistence/persistent_shortcuts.hpp @@ -0,0 +1,70 @@ +#ifndef STLPLUS_PERSISTENT_SHORTCUTS +#define STLPLUS_PERSISTENT_SHORTCUTS +//////////////////////////////////////////////////////////////////////////////// + +// Author: Andy Rushton +// Copyright: (c) Southampton University 1999-2004 +// (c) Andy Rushton 2004-2009 +// License: BSD License, see ../docs/license.html + +// Short-cut functions for dumping and restoring to common targets. These do +// the whole dump operation in a single function call. + +// They take as their second template argument a dump or restore functor which +// is then called to perform the dump/restore operation. + +// They use an installer callback function to install any polymorphic type +// handlers required prior to performing the dump/restore. If there are no +// polymorphic types used in the data structure, then the callback can be set +// to null (i.e. 0). + +//////////////////////////////////////////////////////////////////////////////// +#include "persistence_fixes.hpp" +#include "persistent_contexts.hpp" + +//////////////////////////////////////////////////////////////////////////////// + +namespace stlplus +{ + + //////////////////////////////////////////////////////////////////////////////// + // arbitrary IOStream device + // must be in binary mode + + template + void dump_to_device(const T& source, std::ostream& result, D dump_fn, dump_context::installer installer) + throw(persistent_dump_failed); + + template + void restore_from_device(std::istream& source, T& result, R restore_fn, restore_context::installer installer) + throw(persistent_restore_failed); + + //////////////////////////////////////////////////////////////////////////////// + // string IO device + + template + void dump_to_string(const T& source, std::string& result, D dump_fn, dump_context::installer installer) + throw(persistent_dump_failed); + + template + void restore_from_string(const std::string& source, T& result, R restore_fn, restore_context::installer installer) + throw(persistent_restore_failed); + + //////////////////////////////////////////////////////////////////////////////// + // file IO device + + template + void dump_to_file(const T& source, const std::string& filename, D dump_fn, dump_context::installer installer) + throw(persistent_dump_failed); + + template + void restore_from_file(const std::string& filename, T& result, R restore_fn, restore_context::installer installer) + throw(persistent_restore_failed); + + //////////////////////////////////////////////////////////////////////////////// + +} // end namespace stlplus + + //////////////////////////////////////////////////////////////////////////////// +#include "persistent_shortcuts.tpp" +#endif