#ifndef __rf_channel_ih__ #define __rf_channel_ih__ #include "rf_channel.hh" #include "rf_object.ih" #include "rf_expr.ih" #include namespace rftype { inline Channel::Channel (FILE* _fp /* = null */) : fp (_fp) { // was_opened = (fp != null) ? true : false; } inline Channel::~Channel () { /*if (!was_opened)*/ close(); } inline Channel& Channel::operator = (Channel const& _channel) { if (this != &_channel) { fp = _channel.fp; } return self; } inline unsigned Channel::get_type () const { return reg.get_type(); } // // FIXME: Return proper hash value inline uint32_t Channel::hash () const { return 0; } inline bool Channel::open (char const* _fname, char const* _mode) { if (fp != null) fclose(fp); fp = fopen(_fname, _mode); return fp != null ? true : false; } inline void Channel::close () { if (fp != null) fclose(fp); fp = null; } inline bool Channel::eof() { return (feof(fp)); } inline FILE* Channel::get_fp () const { return fp; } inline pxx::WString Channel::to_string () const { size_t max_len = hex_ptr_len + max_int_len + 15; wchar_t* str = static_cast(alloca(max_len * sizeof(wchar_t))); int len = swprintf(str, max_len, L"", this, fp ? fileno(fp) : -1); if (-1 == len) { FATAL(" is more then %u wide characters", this, fp ? fileno(fp) : -1, max_len); } return pxx::WString(str, len); } } #endif // __rf_channel_ih__