libftc
|
00001 #include "ftc_abi_safe.h" 00002 #include "ftc.h" 00003 #include <cstring> 00004 00005 namespace ftc_detail { 00006 00007 namespace { 00008 00009 struct implementation 00010 { 00011 implementation (const char* id, bool writable, const char* host 00012 , unsigned short port, const char* accessKey) 00013 : ftc_impl (id, std::strlen(id), writable, host, port, accessKey, 16) {} 00014 ftc ftc_impl; 00015 }; 00016 00017 implementation* get_impl (ftc_abi_safe::implementation* impl) 00018 { 00019 return static_cast<implementation*>(static_cast<void*>(impl)); 00020 } 00021 00022 } 00023 00024 } 00025 00026 ftc_abi_safe::ftc_abi_safe(const char* id, bool writable, const char* host 00027 , unsigned short port, const char* accessKey) 00028 : impl (0) 00029 { 00030 ftc_detail::implementation* impl_ 00031 = new ftc_detail::implementation (id, writable, host 00032 , port, accessKey); 00033 impl = static_cast<ftc_abi_safe::implementation*>( 00034 static_cast<void*>(impl_)); 00035 } 00036 00037 ftc_abi_safe::~ftc_abi_safe() 00038 { 00039 delete ftc_detail::get_impl (impl); 00040 } 00041 00042 void ftc_abi_safe::open( bool readonly ) 00043 { 00044 ftc_detail::get_impl (impl)->ftc_impl.open (readonly); 00045 } 00046 00047 bool ftc_abi_safe::isOpen() 00048 { 00049 return ftc_detail::get_impl (impl)->ftc_impl.isOpen (); 00050 } 00051 00052 void ftc_abi_safe::close() 00053 { 00054 ftc_detail::get_impl (impl)->ftc_impl.close (); 00055 } 00056 00057 void ftc_abi_safe::setPosition( unsigned long long position ) 00058 { 00059 ftc_detail::get_impl (impl)->ftc_impl.setPosition (position); 00060 } 00061 00062 unsigned long long ftc_abi_safe::getPosition() const 00063 { 00064 return ftc_detail::get_impl (impl)->ftc_impl.getPosition (); 00065 } 00066 00067 void ftc_abi_safe::setSize( unsigned long long size ) 00068 { 00069 ftc_detail::get_impl (impl)->ftc_impl.setSize (size); 00070 } 00071 00072 unsigned long long ftc_abi_safe::getSize() const 00073 { 00074 return ftc_detail::get_impl (impl)->ftc_impl.getSize (); 00075 } 00076 00077 unsigned long long ftc_abi_safe::read(char* data, unsigned long long nbytes, unsigned long long position) 00078 { 00079 return ftc_detail::get_impl (impl)->ftc_impl.read (data, nbytes, position); 00080 } 00081 00082 unsigned long long ftc_abi_safe::write(const char* data, unsigned long long nbytes, unsigned long long position) 00083 { 00084 return ftc_detail::get_impl (impl)->ftc_impl.write (data, nbytes, position); 00085 } 00086 00087 unsigned long long ftc_abi_safe::transferTo(unsigned long long position, unsigned long long nbytes, FILE* fd, char* buffer) 00088 { 00089 return ftc_detail::get_impl (impl)->ftc_impl.transferTo (position, nbytes, fd, buffer); 00090 }