]> Dogcows Code - chaz/yoink/blob - src/stlplus/persistence/persistent_matrix.tpp
testing new non-autotools build system
[chaz/yoink] / src / stlplus / persistence / persistent_matrix.tpp
1 ////////////////////////////////////////////////////////////////////////////////
2
3 // Author: Andy Rushton
4 // Copyright: (c) Southampton University 1999-2004
5 // (c) Andy Rushton 2004-2009
6 // License: BSD License, see ../docs/license.html
7
8 ////////////////////////////////////////////////////////////////////////////////
9 #include "persistent_int.hpp"
10
11 namespace stlplus
12 {
13
14 ////////////////////////////////////////////////////////////////////////////////
15
16 template<typename T, typename DT>
17 void dump_matrix(dump_context& context, const matrix<T>& data,
18 DT dump_fn)
19 throw(persistent_dump_failed)
20 {
21 unsigned rows = data.rows();
22 unsigned cols = data.columns();
23 dump_unsigned(context, rows);
24 dump_unsigned(context, cols);
25 for (unsigned r = 0; r < rows; r++)
26 for (unsigned c = 0; c < cols; c++)
27 dump_fn(context, data(r,c));
28 }
29
30 ////////////////////////////////////////////////////////////////////////////////
31
32 template<typename T, typename RT>
33 void restore_matrix(restore_context& context, matrix<T>& data,
34 RT restore_fn)
35 throw(persistent_restore_failed)
36 {
37 unsigned rows = 0;
38 restore_unsigned(context, rows);
39 unsigned cols = 0;
40 restore_unsigned(context, cols);
41 data.resize(rows,cols);
42 for (unsigned r = 0; r < rows; r++)
43 for (unsigned c = 0; c < cols; c++)
44 restore_fn(context, data(r,c));
45 }
46
47 ////////////////////////////////////////////////////////////////////////////////
48
49 } // end namespace stlplus
This page took 0.030632 seconds and 4 git commands to generate.