diskio_proto.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2009 NICTA
00002 // 
00003 // Authors:
00004 // - Conrad Sanderson (conradsand at ieee dot org)
00005 // 
00006 // This file is part of the Armadillo C++ library.
00007 // It is provided without any warranty of fitness
00008 // for any purpose. You can redistribute this file
00009 // and/or modify it under the terms of the GNU
00010 // Lesser General Public License (LGPL) as published
00011 // by the Free Software Foundation, either version 3
00012 // of the License or (at your option) any later version.
00013 // (see http://www.opensource.org/licenses for more info)
00014 
00015 
00016 //! \addtogroup diskio
00017 //! @{
00018 
00019 
00020 //! class for saving and loading matrices and fields
00021 class diskio
00022   {
00023   public:
00024   
00025   template<typename eT>
00026   struct is_supported_type
00027     {
00028     static const bool value = 
00029       (
00030       false
00031       || is_u8<eT>::value
00032       || is_s8<eT>::value
00033       || is_u16<eT>::value
00034       || is_s16<eT>::value
00035       || is_u32<eT>::value
00036       || is_s32<eT>::value
00037       || is_float<eT>::value
00038       || is_double<eT>::value
00039       || is_complex_float<eT>::value
00040       || is_complex_double<eT>::value
00041       );
00042     };
00043   
00044   
00045   template<typename eT>
00046   inline static std::string gen_txt_header(const Mat<eT>& x);
00047   
00048   template<typename eT>
00049   inline static std::string gen_bin_header(const Mat<eT>& x);
00050 
00051   
00052   inline static char conv_to_hex_char(const u8 x);
00053   inline static void conv_to_hex(char* out, const u8 x);
00054 
00055   inline static std::string gen_tmp_name(const std::string& x);
00056   
00057   inline static void safe_rename(const std::string& old_name, const std::string& new_name);
00058   
00059   
00060   //
00061   // saving
00062   
00063   template<typename eT>
00064   inline static void save_raw_ascii  (const Mat<eT>& x, const std::string& name);
00065   
00066   template<typename eT>
00067   inline static void save_arma_ascii (const Mat<eT>& x, const std::string& name);
00068   
00069   template<typename eT>
00070   inline static void save_arma_ascii (const Mat<eT>& x, const std::string& name, std::ofstream& f);
00071   
00072   template<typename eT>
00073   inline static void save_arma_binary(const Mat<eT>& x, const std::string& name);
00074   
00075   template<typename eT>
00076   inline static void save_arma_binary(const Mat<eT>& x, const std::string& name, std::ofstream& f);
00077   
00078   template<typename eT>
00079   inline static void save_pgm_binary (const Mat<eT>& x, const std::string& name);
00080   
00081   template<typename T>
00082   inline static void save_pgm_binary (const Mat< std::complex<T> >& x, const std::string& name);
00083   
00084   
00085   //
00086   // loading
00087   
00088   template<typename eT>
00089   inline static void load_raw_ascii  (Mat<eT>& x, const std::string& name);
00090   
00091   template<typename eT>
00092   inline static void load_arma_ascii (Mat<eT>& x, const std::string& name);
00093   
00094   template<typename eT>
00095   inline static void load_arma_ascii (Mat<eT>& x, const std::string& name, std::ifstream& f);
00096   
00097   template<typename eT>
00098   inline static void load_arma_binary(Mat<eT>& x, const std::string& name);
00099   
00100   template<typename eT>
00101   inline static void load_arma_binary(Mat<eT>& x, const std::string& name, std::ifstream& f);
00102   
00103   template<typename eT>
00104   inline static void load_pgm_binary (Mat<eT>& x, const std::string& name);
00105   
00106   template<typename T>
00107   inline static void load_pgm_binary (Mat< std::complex<T> >& x, const std::string& name);
00108   
00109   template<typename eT>
00110   inline static void load_auto_detect(Mat<eT>& x, const std::string& name);
00111   
00112   inline static void pnm_skip_comments(std::fstream& f);
00113   
00114   
00115   // field saving and loading
00116   
00117   template<typename T1>
00118   inline static void save_field_arma_binary(const field<T1>& x, const std::string& name);
00119   
00120   template<typename T1>
00121   inline static void load_field_arma_binary(      field<T1>& x, const std::string& name);
00122   
00123   
00124   template<typename T1>
00125   inline static void save_field_ppm_binary(const field<T1>& x, const std::string& final_name);
00126   
00127   template<typename T1>
00128   inline static void load_field_ppm_binary(      field<T1>& x, const std::string& final_name);
00129   
00130   
00131   inline static void save_field_std_string(const field<std::string>& x, const std::string& name);
00132   inline static void load_field_std_string(      field<std::string>& x, const std::string& name);
00133   
00134   template<typename T1>
00135   inline static void load_field_auto_detect(field<T1>& x, const std::string& name);
00136   
00137   };
00138 
00139 
00140 //! @}