メインページ   クラス階層   構成   ファイル一覧   構成メンバ   ファイルメンバ  

data-conv.h

解説を見る。
00001 /*
00002 
00003 Copyright (C) 1996, 1997 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 2, or (at your option) any
00010 later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, write to the Free
00019 Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020 
00021 */
00022 
00023 #if !defined (octave_data_conv_h)
00024 #define octave_data_conv_h 1
00025 
00026 #include <climits>
00027 
00028 #include "mach-info.h"
00029 
00030 // Not all of the following are currently used.
00031 
00032 #if CHAR_BIT != 8
00033 #error "CHAR_BIT is not 8!"
00034 #endif
00035 
00036 #if SIZEOF_SHORT == 2
00037 #define TWO_BYTE_INT short
00038 #elif SIZEOF_INT == 2
00039 #define TWO_BYTE_INT int
00040 #else
00041 #error "No 2 byte integer type found!"
00042 #endif
00043 
00044 #if SIZEOF_INT == 4
00045 #define FOUR_BYTE_INT int
00046 #elif SIZEOF_LONG == 4
00047 #define FOUR_BYTE_INT long
00048 #else
00049 #error "No 4 byte integer type found!"
00050 #endif
00051 
00052 #if SIZEOF_LONG == 8
00053 #define EIGHT_BYTE_INT long
00054 #else
00055 #if SIZEOF_LONG_LONG == 8
00056 // if `long long' is not implemented, then SIZEOF_LONG_LONG will be 0
00057 #define EIGHT_BYTE_INT long long
00058 // if no 8 byte integer type is found, then EIGHT_BYTE_INT is not defined
00059 #endif
00060 #endif
00061 
00062 class
00063 oct_data_conv
00064 {
00065 public:
00066 
00067   enum data_type
00068     {
00069       dt_int8      =  0,
00070       dt_uint8     =  1,
00071       dt_int16     =  2,
00072       dt_uint16    =  3,
00073       dt_int32     =  4,
00074       dt_uint32    =  5,
00075       dt_int64     =  6,
00076       dt_uint64    =  7,
00077       dt_single    =  8,
00078       dt_double    =  9,
00079       dt_char      = 10,
00080       dt_schar     = 11,
00081       dt_uchar     = 12,
00082       dt_logical   = 13,
00083       dt_short     = 14,
00084       dt_ushort    = 15,
00085       dt_int       = 16,
00086       dt_uint      = 17,
00087       dt_long      = 18,
00088       dt_ulong     = 19,
00089       dt_longlong  = 20,
00090       dt_ulonglong = 21,
00091       dt_float     = 22,
00092       dt_unknown   = 23 // Must be last, have largest value!
00093     };
00094 
00095   static data_type string_to_data_type (const std::string& s);
00096 
00097   static void string_to_data_type (const std::string& s, int& block_size,
00098                                    data_type& input_type,
00099                                    data_type& output_type);
00100 
00101   static void string_to_data_type (const std::string& s, int& block_size,
00102                                    data_type& output_type);
00103 
00104   static std::string data_type_as_string (data_type dt);
00105 };
00106 
00107 // Add new entries to the end of this enum, otherwise Octave will not
00108 // be able to read binary data files stored in Octave's binary data
00109 // format that were created with previous versions of Octave.
00110 
00111 enum save_type
00112   {
00113     LS_U_CHAR  = 0,
00114     LS_U_SHORT = 1,
00115     LS_U_INT   = 2,
00116     LS_CHAR    = 3,
00117     LS_SHORT   = 4,
00118     LS_INT     = 5,
00119     LS_FLOAT   = 6,
00120     LS_DOUBLE  = 7,
00121     LS_U_LONG  = 8,
00122     LS_LONG    = 9
00123   };
00124 
00125 extern void
00126 do_double_format_conversion (void *data, int len,
00127                              oct_mach_info::float_format from_fmt,
00128                              oct_mach_info::float_format to_fmt
00129                                = oct_mach_info::native_float_format ());
00130 
00131 extern void
00132 do_float_format_conversion (void *data, int len,
00133                             oct_mach_info::float_format from_fmt,
00134                             oct_mach_info::float_format to_fmt
00135                               = oct_mach_info::native_float_format ());
00136 
00137 extern void
00138 do_float_format_conversion (void *data, size_t sz, int len,
00139                             oct_mach_info::float_format from_fmt,
00140                             oct_mach_info::float_format to_fmt
00141                               = oct_mach_info::native_float_format ());
00142 
00143 extern void
00144 read_doubles (std::istream& is, double *data, save_type type, int len,
00145               bool swap, oct_mach_info::float_format fmt);
00146 extern void
00147 write_doubles (std::ostream& os, const double *data, save_type type, int len);
00148 
00149 #endif
00150 
00151 /*
00152 ;;; Local Variables: ***
00153 ;;; mode: C++ ***
00154 ;;; End: ***
00155 */

Wed Dec 29 11:51:10 2004に生成されました。 doxygen1.2.18
SEO [PR] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送