00001 #ifndef javafile_h
00002 #define javafile_h
00003
00004 #include "config.h"
00005
00006 #ifdef HAVE_IXLIB
00007
00008 #include "file.h"
00009
00010 #undef PACKAGE
00011 #undef VERSION
00012
00013 #include <ixlib_javascript.hh>
00014
00015 #undef PACKAGE
00016 #undef VERSION
00017
00018 #include <string>
00019
00020 using namespace ixion;
00021 using namespace javascript;
00022
00023 class SimpleFile : private File
00024 {
00025 public:
00026 SimpleFile() : File() {}
00027 SimpleFile( std::string name, std::string openmode, bool nocreate = false, bool real = false );
00028
00029 SimpleFile( const File& file ) : File( file ) {}
00030
00031 void open( std::string name, std::string openmode, bool nocreate = false, bool real = true)
00032 { *this = SimpleFile( name, openmode, nocreate, real ); }
00033
00034 bool is_valid() const { return File::is_valid(); }
00035 bool operator!() const { return File::operator!(); }
00036
00037 std::string get_name() const { return File::get_name(); }
00038
00039 void seekg( long pos ) { File::seekg( pos ); }
00040 long tellg() { return File::tellg(); }
00041 void seekp( long pos ) { File::seekp( pos ); }
00042 long tellp() { return File::tellp(); }
00043 int eof() { return File::eof(); }
00044
00045 void operator=( const SimpleFile& file )
00046 { File::operator=( file ); }
00047
00048 void flush() { File::flush(); }
00049 void put( char c ) { File::put( c ); }
00050
00051 void write( std::string s ) { File::write( s ); }
00052 void write( std::string s, std::streamsize n ) { File::write( s, n ); }
00053
00054 void get( char& c ) { File::get( c ); }
00055 void read( char* ptr, std::streamsize n ) { File::read( ptr, n ); }
00056
00057 void clear() { File::clear(); }
00058
00059 void trunc() { File::trunc(); }
00060
00061 bool append( SimpleFile other ) { return File::append( other ); }
00062
00063 std::string getline();
00064
00065 File get_file() const { return *this; }
00066
00067 private:
00068
00069 std::ios_base::openmode get_openmode( std::string mode );
00070 };
00071
00072
00073 class JavaFile : public value_with_methods
00074 {
00075 private:
00076 typedef value_with_methods super;
00077
00078 SimpleFile file;
00079
00080 public:
00081 JavaFile() {}
00082
00083 JavaFile( std::string name, std::string mode, bool nocreate = false, bool real = true);
00084
00085 JavaFile( const JavaFile& f );
00086
00087 JavaFile( const SimpleFile& f )
00088 : file( f )
00089 {}
00090
00091 JavaFile( const File& f )
00092 : file( f )
00093 {}
00094
00095 value_type getType() const { return VT_BUILTIN; }
00096
00097 ref<value> duplicate();
00098
00099 ref<value> lookup( std::string const &identifier );
00100 ref<value> callMethod( std::string const &identifier, parameter_list const ¶meters );
00101
00102 SimpleFile get_file() const { return file; }
00103 };
00104
00105
00106 class JavaFileConstructor : public value
00107 {
00108 public:
00109 value_type getType() const { return VT_TYPE; }
00110
00111 ref<value> duplicate(){ return this; }
00112 ref<value> construct( parameter_list const ¶meters );
00113 };
00114
00115 #endif // HAVE_IXLIB
00116
00117 #endif