00001
00002 #ifndef vsl_block_binary_io_h_
00003 #define vsl_block_binary_io_h_
00004
00005
00006
00007
00008
00009 #include <vsl/vsl_binary_io.h>
00010 #include <vsl/vsl_binary_explicit_io.h>
00011
00012
00013 void vsl_block_binary_read_confirm_specialisation(vsl_b_istream &is, bool specialised);
00014
00015
00016 template <class T>
00017 inline void vsl_block_binary_write(vsl_b_ostream &os, const T* begin, vcl_size_t nelems);
00018
00019
00020 template <class T>
00021 inline void vsl_block_binary_read(vsl_b_istream &is, T* begin, vcl_size_t nelems);
00022
00023
00024
00025
00026
00027 template <class T>
00028 void vsl_block_binary_write_float_impl(vsl_b_ostream &os, const T* begin, vcl_size_t nelems);
00029
00030
00031 template <class T>
00032 void vsl_block_binary_read_float_impl(vsl_b_istream &is, T* begin, vcl_size_t nelems);
00033
00034
00035
00036
00037
00038
00039
00040 VCL_DEFINE_SPECIALIZATION
00041 inline void vsl_block_binary_write(vsl_b_ostream &os, const double* begin, vcl_size_t nelems)
00042 {
00043 vsl_block_binary_write_float_impl(os, begin, nelems);
00044 }
00045
00046
00047
00048 VCL_DEFINE_SPECIALIZATION
00049 inline void vsl_block_binary_read(vsl_b_istream &is, double* begin, vcl_size_t nelems)
00050 {
00051 vsl_block_binary_read_float_impl(is, begin, nelems);
00052 }
00053
00054
00055
00056
00057
00058
00059
00060 VCL_DEFINE_SPECIALIZATION
00061 inline void vsl_block_binary_write(vsl_b_ostream &os, const float* begin, vcl_size_t nelems)
00062 {
00063 vsl_block_binary_write_float_impl(os, begin, nelems);
00064 }
00065
00066
00067
00068 VCL_DEFINE_SPECIALIZATION
00069 inline void vsl_block_binary_read(vsl_b_istream &is, float* begin, vcl_size_t nelems)
00070 {
00071 vsl_block_binary_read_float_impl(is, begin, nelems);
00072 }
00073
00074
00075
00076
00077 template <class T>
00078 void vsl_block_binary_write_int_impl(vsl_b_ostream &os, const T* begin, vcl_size_t nelems);
00079
00080
00081 template <class T>
00082 void vsl_block_binary_read_int_impl(vsl_b_istream &is, T* begin, vcl_size_t nelems);
00083
00084
00085
00086
00087
00088
00089
00090 VCL_DEFINE_SPECIALIZATION
00091 inline void vsl_block_binary_write(vsl_b_ostream &os, const int* begin, vcl_size_t nelems)
00092 {
00093 vsl_block_binary_write_int_impl(os, begin, nelems);
00094 }
00095
00096
00097
00098
00099
00100 VCL_DEFINE_SPECIALIZATION
00101 inline void vsl_block_binary_read(vsl_b_istream &is, int* begin, vcl_size_t nelems)
00102 {
00103 vsl_block_binary_read_int_impl(is, begin, nelems);
00104 }
00105
00106
00107
00108
00109
00110
00111
00112 VCL_DEFINE_SPECIALIZATION
00113 inline void vsl_block_binary_write(vsl_b_ostream &os, const unsigned int* begin, vcl_size_t nelems)
00114 {
00115 vsl_block_binary_write_int_impl(os, begin, nelems);
00116 }
00117
00118
00119
00120
00121
00122 VCL_DEFINE_SPECIALIZATION
00123 inline void vsl_block_binary_read(vsl_b_istream &is, unsigned int* begin, vcl_size_t nelems)
00124 {
00125 vsl_block_binary_read_int_impl(is, begin, nelems);
00126 }
00127
00128
00129
00130
00131
00132
00133
00134
00135 VCL_DEFINE_SPECIALIZATION
00136 inline void vsl_block_binary_write(vsl_b_ostream &os, const short* begin, vcl_size_t nelems)
00137 {
00138 vsl_block_binary_write_int_impl(os, begin, nelems);
00139 }
00140
00141
00142
00143
00144
00145 VCL_DEFINE_SPECIALIZATION
00146 inline void vsl_block_binary_read(vsl_b_istream &is, short* begin, vcl_size_t nelems)
00147 {
00148 vsl_block_binary_read_int_impl(is, begin, nelems);
00149 }
00150
00151
00152
00153
00154
00155
00156
00157
00158 VCL_DEFINE_SPECIALIZATION
00159 inline void vsl_block_binary_write(vsl_b_ostream &os, const unsigned short* begin, vcl_size_t nelems)
00160 {
00161 vsl_block_binary_write_int_impl(os, begin, nelems);
00162 }
00163
00164
00165
00166
00167
00168 VCL_DEFINE_SPECIALIZATION
00169 inline void vsl_block_binary_read(vsl_b_istream &is, unsigned short* begin, vcl_size_t nelems)
00170 {
00171 vsl_block_binary_read_int_impl(is, begin, nelems);
00172 }
00173
00174
00175
00176
00177
00178
00179
00180
00181 VCL_DEFINE_SPECIALIZATION
00182 inline void vsl_block_binary_write(vsl_b_ostream &os, const long* begin, vcl_size_t nelems)
00183 {
00184 vsl_block_binary_write_int_impl(os, begin, nelems);
00185 }
00186
00187
00188
00189
00190
00191 VCL_DEFINE_SPECIALIZATION
00192 inline void vsl_block_binary_read(vsl_b_istream &is, long* begin, vcl_size_t nelems)
00193 {
00194 vsl_block_binary_read_int_impl(is, begin, nelems);
00195 }
00196
00197
00198
00199
00200
00201
00202
00203
00204 VCL_DEFINE_SPECIALIZATION
00205 inline void vsl_block_binary_write(vsl_b_ostream &os, const unsigned long* begin, vcl_size_t nelems)
00206 {
00207 vsl_block_binary_write_int_impl(os, begin, nelems);
00208 }
00209
00210
00211
00212
00213
00214 VCL_DEFINE_SPECIALIZATION
00215 inline void vsl_block_binary_read(vsl_b_istream &is, unsigned long* begin, vcl_size_t nelems)
00216 {
00217 vsl_block_binary_read_int_impl(is, begin, nelems);
00218 }
00219
00220
00221 #if VXL_HAS_INT_64 && !VXL_INT_64_IS_LONG
00222
00223
00224
00225
00226
00227 VCL_DEFINE_SPECIALIZATION
00228 inline void vsl_block_binary_write(vsl_b_ostream &os, const vxl_int_64* begin, vcl_size_t nelems)
00229 {
00230 vsl_block_binary_write_int_impl(os, begin, nelems);
00231 }
00232
00233
00234
00235
00236
00237 VCL_DEFINE_SPECIALIZATION
00238 inline void vsl_block_binary_read(vsl_b_istream &is, vxl_int_64* begin, vcl_size_t nelems)
00239 {
00240 vsl_block_binary_read_int_impl(is, begin, nelems);
00241 }
00242
00243
00244
00245
00246
00247
00248
00249
00250 VCL_DEFINE_SPECIALIZATION
00251 inline void vsl_block_binary_write(vsl_b_ostream &os, const vxl_uint_64* begin, vcl_size_t nelems)
00252 {
00253 vsl_block_binary_write_int_impl(os, begin, nelems);
00254 }
00255
00256
00257
00258
00259
00260 VCL_DEFINE_SPECIALIZATION
00261 inline void vsl_block_binary_read(vsl_b_istream &is, vxl_uint_64* begin, vcl_size_t nelems)
00262 {
00263 vsl_block_binary_read_int_impl(is, begin, nelems);
00264 }
00265 #endif //VXL_HAS_INT_64 && !VXL_INT_64_IS_LONG
00266
00267
00268
00269
00270 template <class T>
00271 void vsl_block_binary_write_byte_impl(vsl_b_ostream &os, const T* begin, vcl_size_t nelems);
00272
00273
00274 template <class T>
00275 void vsl_block_binary_read_byte_impl(vsl_b_istream &is, T* begin, vcl_size_t nelems);
00276
00277
00278
00279
00280
00281 VCL_DEFINE_SPECIALIZATION
00282 inline void vsl_block_binary_write(vsl_b_ostream &os, const unsigned char* begin, vcl_size_t nelems)
00283 {
00284 vsl_block_binary_write_byte_impl(os, begin, nelems);
00285 }
00286
00287
00288
00289 VCL_DEFINE_SPECIALIZATION
00290 inline void vsl_block_binary_read(vsl_b_istream &is, unsigned char* begin, vcl_size_t nelems)
00291 {
00292 vsl_block_binary_read_byte_impl(is, begin, nelems);
00293 }
00294
00295
00296
00297
00298
00299 VCL_DEFINE_SPECIALIZATION
00300 inline void vsl_block_binary_write(vsl_b_ostream &os, const signed char* begin, vcl_size_t nelems)
00301 {
00302 vsl_block_binary_write_byte_impl(os, begin, nelems);
00303 }
00304
00305
00306
00307 VCL_DEFINE_SPECIALIZATION
00308 inline void vsl_block_binary_read(vsl_b_istream &is, signed char* begin, vcl_size_t nelems)
00309 {
00310 vsl_block_binary_read_byte_impl(is, begin, nelems);
00311 }
00312
00313
00314
00315
00316
00317
00318
00319 template <class T>
00320 inline void vsl_block_binary_write(vsl_b_ostream &os, const T* begin, vcl_size_t nelems)
00321 {
00322 vsl_b_write(os, false);
00323 while (nelems--)
00324 vsl_b_write(os, *(begin++));
00325 }
00326
00327
00328
00329
00330 template <class T>
00331 inline void vsl_block_binary_read(vsl_b_istream &is, T* begin, vcl_size_t nelems)
00332 {
00333 vsl_block_binary_read_confirm_specialisation(is, false);
00334 if (!is) return;
00335 while (nelems--)
00336 vsl_b_read(is, *(begin++));
00337 }
00338
00339 #endif // vsl_block_binary_io_h_