aimsdata 6.0.0
Neuroimaging data handling
listItemR.h
Go to the documentation of this file.
1/* This software and supporting documentation are distributed by
2 * Institut Federatif de Recherche 49
3 * CEA/NeuroSpin, Batiment 145,
4 * 91191 Gif-sur-Yvette cedex
5 * France
6 *
7 * This software is governed by the CeCILL-B license under
8 * French law and abiding by the rules of distribution of free software.
9 * You can use, modify and/or redistribute the software under the
10 * terms of the CeCILL-B license as circulated by CEA, CNRS
11 * and INRIA at the following URL "http://www.cecill.info".
12 *
13 * As a counterpart to the access to the source code and rights to copy,
14 * modify and redistribute granted by the license, users are provided only
15 * with a limited warranty and the software's author, the holder of the
16 * economic rights, and the successive licensors have only limited
17 * liability.
18 *
19 * In this respect, the user's attention is drawn to the risks associated
20 * with loading, using, modifying and/or developing or reproducing the
21 * software by the user in light of its specific status of free software,
22 * that may mean that it is complicated to manipulate, and that also
23 * therefore means that it is reserved for developers and experienced
24 * professionals having in-depth computer knowledge. Users are therefore
25 * encouraged to load and test the software's suitability as regards their
26 * requirements in conditions enabling the security of their systems and/or
27 * data to be ensured and, more generally, to use and operate it in the
28 * same conditions as regards security.
29 *
30 * The fact that you are presently reading this means that you have had
31 * knowledge of the CeCILL-B license and that you accept its terms.
32 */
33
34/*
35 * List item reader class
36 */
37#ifndef AIMS_IO_LISTITEMR_H
38#define AIMS_IO_LISTITEMR_H
39
41#include <list>
42
43namespace aims
44{
45
46#ifndef DOXYGEN_HIDE_INTERNAL_CLASSES
47
48 template <typename T> class DefaultItemReader<std::list<T> >
49 : public ItemReader<std::list<T> >
50 {
51 public:
52 DefaultItemReader() : ItemReader<std::list<T> >() { }
53 virtual ~DefaultItemReader() { }
54
55 virtual void read( std::istream & is, std::list<T> & item ) const;
56 virtual void read( std::istream & is, std::list<T> * pitem,
57 size_t n ) const;
58 virtual ItemReader<std::list<T> >* reader( const std::string & openmode
59 = "binar",
60 bool bswap = false ) const;
61 };
62
63
64 template <typename T> class DefaultAsciiItemReader<std::list<T> >
65 : public DefaultItemReader<std::list<T> >
66 {
67 public:
70
71 virtual void read( std::istream & is, std::list<T> & item ) const;
72 };
73
74
75 template <typename T> class DefaultBSwapItemReader<std::list<T> >
76 : public DefaultItemReader<std::list<T> >
77 {
78 public:
81
82 virtual void read( std::istream & is, std::list<T> & item ) const;
83 };
84
85
86 template<class T> ItemReader<std::list<T> >*
87 DefaultItemReader<std::list<T> >::reader( const std::string & openmode,
88 bool bswap ) const
89 {
90 if( openmode == "ascii" )
92 if( bswap )
95 }
96
97
98 template <class T> inline void
100 std::list<T> * pitem,
101 size_t n ) const
102 {
103 std::list<T> *ptr = pitem;
104 for( size_t i=0; i<n; ++i )
105 read( is, *ptr++ );
106 }
107
108
109 template <class T> inline void
111 std::list<T> & item ) const
112 {
113 uint32_t n;
114 T data;
117 ir1.read( is, n );
118 for( uint i=0; i<n; ++i )
119 {
120 ir.read( is, data );
121 item.push_back( data );
122 }
123 }
124
125
126 template <class T> inline void
128 std::list<T> & item ) const
129 {
130 uint32_t n;
131 T data;
134 char tmp;
135 is >> tmp;
136 // ASSERT( tmp == '(' );
137 ir1.read( is, n );
138 for( uint i=0; i<n; ++i )
139 {
140 is >> tmp;
141 // ASSERT( tmp == ',' );
142 ir.read( is, data );
143 item.push_back( data );
144 }
145 is >> tmp;
146 // ASSERT( tmp == ')' );
147 }
148
149
150 template <class T> inline void
152 std::list<T> & item ) const
153 {
154 uint32_t n;
155 T data;
158 ir1.read( is, n );
159 for( uint i=0; i<n; ++i )
160 {
161 ir.read( is, data );
162 item.push_back( data );
163 }
164 }
165
166#endif // DOXYGEN_HIDE_INTERNAL_CLASSES
167
168} // namespace aims
169
170
171#endif
virtual void read(std::istream &is, std::list< T > &item) const
Definition listItemR.h:127
virtual void read(std::istream &is, T &item) const
virtual void read(std::istream &is, std::list< T > &item) const
Definition listItemR.h:151
virtual void read(std::istream &is, T &item) const
virtual ItemReader< std::list< T > > * reader(const std::string &openmode="binar", bool bswap=false) const
Definition listItemR.h:87
virtual void read(std::istream &is, std::list< T > &item) const
Definition listItemR.h:110
virtual ItemReader< T > * reader(const std::string &openmode="binar", bool bswap=false) const
virtual void read(std::istream &is, T &item) const
Low-level "small item" reader, used by higher-level file readers.
Definition itemR.h:99
The class for EcatSino data write operation.
STL namespace.
unsigned int uint