00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined (octave_liboctave_utils_h)
00025 #define octave_liboctave_utils_h 1
00026
00027 #include <cstdio>
00028
00029 #include <iostream>
00030 #include <string>
00031
00032 #include "oct-cmplx.h"
00033 #include "syswait.h"
00034
00035 extern OCTAVE_API octave_idx_type NINTbig (double x);
00036 extern OCTAVE_API octave_idx_type NINTbig (float x);
00037 extern OCTAVE_API int NINT (double x);
00038 extern OCTAVE_API int NINT (float x);
00039 extern OCTAVE_API double D_NINT (double x);
00040 extern OCTAVE_API float F_NINT (float x);
00041
00042 extern OCTAVE_API char *strsave (const char *);
00043
00044 extern OCTAVE_API void octave_putenv (const std::string&, const std::string&);
00045
00046 extern OCTAVE_API std::string octave_fgets (std::FILE *);
00047 extern OCTAVE_API std::string octave_fgetl (std::FILE *);
00048
00049 extern OCTAVE_API std::string octave_fgets (std::FILE *, bool& eof);
00050 extern OCTAVE_API std::string octave_fgetl (std::FILE *, bool& eof);
00051
00052 extern "C" OCTAVE_API int octave_gethostname (char *, int);
00053
00054 extern "C" OCTAVE_API void octave_qsort (void *base, size_t n, size_t size,
00055 int (*cmp) (const void *, const void *));
00056
00057 extern "C" OCTAVE_API char *oct_strptime (const char *buf, const char *format,
00058 struct tm *tm);
00059
00060 extern "C" OCTINTERP_API int octave_strcasecmp (const char *s1, const char *s2);
00061
00062 extern "C" OCTINTERP_API int octave_strncasecmp (const char *s1, const char *s2, size_t n);
00063
00064 template <typename T>
00065 T
00066 octave_read_value (std::istream& is)
00067 {
00068 T retval;
00069 is >> retval;
00070 return retval;
00071 }
00072
00073 template <> OCTAVE_API double octave_read_value (std::istream& is);
00074 template <> OCTAVE_API Complex octave_read_value (std::istream& is);
00075 template <> OCTAVE_API float octave_read_value (std::istream& is);
00076 template <> OCTAVE_API FloatComplex octave_read_value (std::istream& is);
00077
00078
00079 inline double
00080 octave_read_double (std::istream& is)
00081 {
00082 return octave_read_value<double> (is);
00083 }
00084
00085 inline Complex
00086 octave_read_complex (std::istream& is)
00087 {
00088 return octave_read_value<Complex> (is);
00089 }
00090
00091 inline float
00092 octave_read_float (std::istream& is)
00093 {
00094 return octave_read_value<float> (is);
00095 }
00096
00097 inline FloatComplex
00098 octave_read_float_complex (std::istream& is)
00099 {
00100 return octave_read_value<FloatComplex> (is);
00101 }
00102
00103 extern OCTAVE_API void octave_write_double (std::ostream& os, double dval);
00104 extern OCTAVE_API void octave_write_complex (std::ostream& os, const Complex& cval);
00105
00106 extern OCTAVE_API void octave_write_float (std::ostream& os, float dval);
00107 extern OCTAVE_API void octave_write_float_complex (std::ostream& os, const FloatComplex& cval);
00108
00109 #ifdef HAVE_LOADLIBRARY_API
00110 #include <windows.h>
00111 extern "C" OCTAVE_API void * octave_w32_library_search (HINSTANCE handle, const char *name);
00112 #undef min
00113 #undef max
00114 #endif
00115 #endif
00116
00117 extern "C" OCTAVE_API pid_t octave_waitpid (pid_t pid, int *status, int options);
00118
00119
00120
00121
00122
00123