[2660] | 1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
| 2 | // Classe pour faciliter entree-sortie PPF pour des pointeurs
|
---|
| 3 | // R. Ansari - Mars 2005
|
---|
| 4 |
|
---|
| 5 | #ifndef PPFTPOINTERIO_H_SEEN
|
---|
| 6 | #define PPFTPOINTERIO_H_SEEN
|
---|
| 7 |
|
---|
| 8 | #include "ppersist.h"
|
---|
| 9 |
|
---|
| 10 | //----------------------------------------------------------------------
|
---|
| 11 | namespace SOPHYA {
|
---|
| 12 |
|
---|
| 13 | /*!
|
---|
| 14 | \class SOPHYA::PPF_TPointer_IO
|
---|
| 15 | \ingroup BaseTools
|
---|
| 16 | A template utility class with static methods to ease handling of array
|
---|
| 17 | I/O in PPF streams (POutPersist and PInPersist). It is not intented for
|
---|
| 18 | direct use in user programs, but for writing PPF persistence handler
|
---|
| 19 | classes (PPersist).
|
---|
| 20 | The C++ I/O operators POutPersist& << and PInPersist& >> should be defined for
|
---|
| 21 | new types and classes.
|
---|
| 22 | */
|
---|
| 23 |
|
---|
| 24 | template <class T>
|
---|
| 25 | class PPF_TPointer_IO {
|
---|
| 26 | public:
|
---|
| 27 | //! Writes the array pointed to by \b arr (size \b n) to POutPersist stream \b os
|
---|
| 28 | static void Write(POutPersist & os, T const * arr, size_t n)
|
---|
| 29 | {
|
---|
| 30 | for(size_t k=0; k<n; k++) os << arr[k];
|
---|
| 31 | }
|
---|
| 32 | //! Reads from the PInPersist \b is into array pointed to by \b arr (size \b n)
|
---|
| 33 | static void Read(PInPersist & is, T * arr, size_t n)
|
---|
| 34 | {
|
---|
| 35 | for(size_t k=0; k<n; k++) is >> arr[k];
|
---|
| 36 | }
|
---|
| 37 | };
|
---|
| 38 | // Specific implementation using table I/O in PPFBinaryIOStreams
|
---|
[2665] | 39 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 40 | void PPF_TPointer_IO<char>::Write(POutPersist & os, char const * arr, size_t n)
|
---|
| 41 | { os.PutBytes(arr,n); }
|
---|
[2665] | 42 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 43 | void PPF_TPointer_IO<char>::Read(PInPersist & is, char * arr, size_t n)
|
---|
| 44 | { is.GetBytes(arr,n); }
|
---|
| 45 |
|
---|
[2665] | 46 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 47 | void PPF_TPointer_IO< int_1 >::Write(POutPersist & os, int_1 const * arr, size_t n)
|
---|
| 48 | { os.Put(arr,n); }
|
---|
[2665] | 49 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 50 | void PPF_TPointer_IO< int_1 >::Read(PInPersist & is, int_1 * arr, size_t n)
|
---|
| 51 | { is.Get(arr,n); }
|
---|
[2665] | 52 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 53 | void PPF_TPointer_IO< uint_1 >::Write(POutPersist & os, uint_1 const * arr, size_t n)
|
---|
| 54 | { os.Put(arr,n); }
|
---|
[2665] | 55 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 56 | void PPF_TPointer_IO< uint_1 >::Read(PInPersist & is, uint_1 * arr, size_t n)
|
---|
| 57 | { is.Get(arr,n); }
|
---|
| 58 |
|
---|
[2665] | 59 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 60 | void PPF_TPointer_IO< int_2 >::Write(POutPersist & os, int_2 const * arr, size_t n)
|
---|
| 61 | { os.Put(arr,n); }
|
---|
[2665] | 62 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 63 | void PPF_TPointer_IO< int_2 >::Read(PInPersist & is, int_2 * arr, size_t n)
|
---|
| 64 | { is.Get(arr,n); }
|
---|
[2665] | 65 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 66 | void PPF_TPointer_IO< uint_2 >::Write(POutPersist & os, uint_2 const * arr, size_t n)
|
---|
| 67 | { os.Put(arr,n); }
|
---|
[2665] | 68 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 69 | void PPF_TPointer_IO< uint_2 >::Read(PInPersist & is, uint_2 * arr, size_t n)
|
---|
| 70 | { is.Get(arr,n); }
|
---|
| 71 |
|
---|
[2665] | 72 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 73 | void PPF_TPointer_IO< int_4 >::Write(POutPersist & os, int_4 const * arr, size_t n)
|
---|
| 74 | { os.Put(arr,n); }
|
---|
[2665] | 75 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 76 | void PPF_TPointer_IO< int_4 >::Read(PInPersist & is, int_4 * arr, size_t n)
|
---|
| 77 | { is.Get(arr,n); }
|
---|
[2665] | 78 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 79 | void PPF_TPointer_IO< uint_4 >::Write(POutPersist & os, uint_4 const * arr, size_t n)
|
---|
| 80 | { os.Put(arr,n); }
|
---|
[2665] | 81 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 82 | void PPF_TPointer_IO< uint_4 >::Read(PInPersist & is, uint_4 * arr, size_t n)
|
---|
| 83 | { is.Get(arr,n); }
|
---|
| 84 |
|
---|
[2665] | 85 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 86 | void PPF_TPointer_IO< int_8 >::Write(POutPersist & os, int_8 const * arr, size_t n)
|
---|
| 87 | { os.Put(arr,n); }
|
---|
[2665] | 88 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 89 | void PPF_TPointer_IO< int_8 >::Read(PInPersist & is, int_8 * arr, size_t n)
|
---|
| 90 | { is.Get(arr,n); }
|
---|
[2665] | 91 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 92 | void PPF_TPointer_IO< uint_8 >::Write(POutPersist & os, uint_8 const * arr, size_t n)
|
---|
| 93 | { os.Put(arr,n); }
|
---|
[2665] | 94 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 95 | void PPF_TPointer_IO< uint_8 >::Read(PInPersist & is, uint_8 * arr, size_t n)
|
---|
| 96 | { is.Get(arr,n); }
|
---|
| 97 |
|
---|
| 98 |
|
---|
[2665] | 99 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 100 | void PPF_TPointer_IO< r_4 >::Write(POutPersist & os, r_4 const * arr, size_t n)
|
---|
| 101 | { os.Put(arr,n); }
|
---|
[2665] | 102 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 103 | void PPF_TPointer_IO< r_4 >::Read(PInPersist & is, r_4 * arr, size_t n)
|
---|
| 104 | { is.Get(arr,n); }
|
---|
| 105 |
|
---|
[2665] | 106 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 107 | void PPF_TPointer_IO< r_8 >::Write(POutPersist & os, r_8 const * arr, size_t n)
|
---|
| 108 | { os.Put(arr,n); }
|
---|
[2665] | 109 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 110 | void PPF_TPointer_IO< r_8 >::Read(PInPersist & is, r_8 * arr, size_t n)
|
---|
| 111 | { is.Get(arr,n); }
|
---|
| 112 |
|
---|
[2665] | 113 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 114 | void PPF_TPointer_IO< complex<r_4> >::Write(POutPersist & os, complex<r_4> const * arr, size_t n)
|
---|
| 115 | { os.Put(arr,n); }
|
---|
[2665] | 116 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 117 | void PPF_TPointer_IO< complex<r_4> >::Read(PInPersist & is, complex<r_4> * arr, size_t n)
|
---|
| 118 | { is.Get(arr,n); }
|
---|
| 119 |
|
---|
[2665] | 120 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 121 | void PPF_TPointer_IO< complex<r_8> >::Write(POutPersist & os, complex<r_8> const * arr, size_t n)
|
---|
| 122 | { os.Put(arr,n); }
|
---|
[2665] | 123 | DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
|
---|
[2660] | 124 | void PPF_TPointer_IO< complex<r_8> >::Read(PInPersist & is, complex<r_8> * arr, size_t n)
|
---|
| 125 | { is.Get(arr,n); }
|
---|
| 126 |
|
---|
| 127 |
|
---|
| 128 | } // namespace SOPHYA
|
---|
| 129 |
|
---|
| 130 | #endif /* PPFTPOINTERIO_H_SEEN */
|
---|