PLearn 0.1
pl_NSPR_io.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // pl_NSPR_io.h
00004 // Copyright (C) 2005 Pascal Vincent
00005 //
00006 
00007 // Redistribution and use in source and binary forms, with or without
00008 // modification, are permitted provided that the following conditions are met:
00009 // 
00010 //  1. Redistributions of source code must retain the above copyright
00011 //     notice, this list of conditions and the following disclaimer.
00012 // 
00013 //  2. Redistributions in binary form must reproduce the above copyright
00014 //     notice, this list of conditions and the following disclaimer in the
00015 //     documentation and/or other materials provided with the distribution.
00016 // 
00017 //  3. The name of the authors may not be used to endorse or promote
00018 //     products derived from this software without specific prior written
00019 //     permission.
00020 // 
00021 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
00022 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00023 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
00024 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00025 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00026 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00027 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00028 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00029 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00030 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031 // 
00032 // This file is part of the PLearn library. For more information on the PLearn
00033 // library, go to the PLearn Web site at www.plearn.org
00034 
00035 
00036  
00037 
00038 /* *******************************************************      
00039  * AUTHORS: Pascal Vincent
00040  * This file is part of the PLearn library.
00041  ******************************************************* */
00042 
00043 
00046 #ifndef pl_NSPR_io_INC
00047 #define pl_NSPR_io_INC
00048 
00049 #include <nspr/prio.h>
00050 
00051 namespace PLearn {
00052 
00053 // Functions to read from a file written in any representation
00054 
00055 void PR_Read_int(PRFileDesc *f, int* ptr, int n, bool is_file_bigendian);
00056 void PR_Read_float(PRFileDesc *f, float* ptr, int n, bool is_file_bigendian);
00057 void PR_Read_float(PRFileDesc *f, double* ptr, int n, bool is_file_bigendian);
00058 void PR_Read_double(PRFileDesc *f, double* ptr, int n, bool is_file_bigendian);
00059 void PR_Read_double(PRFileDesc *f, float* ptr, int n, bool is_file_bigendian);
00060 void PR_Read_short(PRFileDesc *f, unsigned short* ptr, int n, bool is_file_bigendian);
00061 
00062 
00063 // Functions to write to a file in any representation
00064 
00065 void PR_Write_int(PRFileDesc *f, const int* ptr, int n, bool is_file_bigendian);
00066 void PR_Write_float(PRFileDesc *f, const float* ptr, int n, bool is_file_bigendian);
00067 void PR_Write_float(PRFileDesc *f, const double* ptr, int n, bool is_file_bigendian);
00068 void PR_Write_double(PRFileDesc *f, const double* ptr, int n, bool is_file_bigendian);
00069 void PR_Write_double(PRFileDesc *f, const float* ptr, int n, bool is_file_bigendian);
00070 
00071 
00076 inline int PR_Read_int(PRFileDesc *f, bool is_file_bigendian=true) 
00077 { int res; PR_Read_int(f,&res,1,is_file_bigendian); return res; }
00078 inline float PR_Read_float(PRFileDesc *f, bool is_file_bigendian=true)
00079 { float res; PR_Read_float(f,&res,1,is_file_bigendian); return res; }
00080 inline double PR_Read_double(PRFileDesc *f, bool is_file_bigendian=true)
00081 { double res; PR_Read_double(f,&res,1,is_file_bigendian); return res; }
00082 
00085 inline void PR_Write_int(PRFileDesc *f, int value, bool is_file_bigendian=true)
00086 { PR_Write_int(f, &value, 1, is_file_bigendian); }
00087 inline void PR_Write_float(PRFileDesc *f, float value, bool is_file_bigendian=true)
00088 { PR_Write_float(f, &value, 1, is_file_bigendian); }
00089 inline void PR_Write_double(PRFileDesc *f, double value, bool is_file_bigendian=true)
00090 { PR_Write_double(f, &value, 1, is_file_bigendian); }
00091 
00092 
00093 } // end of namespace PLearn
00094 
00095 
00096 #endif
00097 
00098 
00099 /*
00100   Local Variables:
00101   mode:c++
00102   c-basic-offset:4
00103   c-file-style:"stroustrup"
00104   c-file-offsets:((innamespace . 0)(inline-open . 0))
00105   indent-tabs-mode:nil
00106   fill-column:79
00107   End:
00108 */
00109 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=79 :
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines