
#include <WFX/io/InputStream.h>

using namespace WFX;
using namespace WFX::io;
using namespace std;

InputStream::InputStream(std::istream* s) {
    setStream(s);
}

InputStream::InputStream() {
    IStream = NULL;
}

InputStream::~InputStream() {
}

void InputStream::setStream(std::istream* s) {
    IStream = s;
}

void InputStream::operator >>(Int& i) {
    assert(IStream);
    IStream->read((Char*)&i, sizeof(i));
}

void InputStream::operator >>(UInt& i) {
    assert(IStream);
    IStream->read((Char*)&i, sizeof(i));
}

void InputStream::operator >>(Long& i) {
    assert(IStream);
    IStream->read((Char*)&i, sizeof(i));
}

void InputStream::operator >>(ULong& i) {
    assert(IStream);
    IStream->read((Char*)&i, sizeof(i));
}

void InputStream::operator >>(Short& i) {
    assert(IStream);
    IStream->read((Char*)&i, sizeof(i));
}

void InputStream::operator >>(UShort& i) {
    assert(IStream);
    IStream->read((Char*)&i, sizeof(i));
}

void InputStream::operator >>(Char& i) {
    assert(IStream);
    IStream->read((Char*)&i, sizeof(i));
}

void InputStream::operator >>(UChar& i) {
    assert(IStream);
    IStream->read((Char*)&i, sizeof(i));
}

void InputStream::operator >>(Real& r) {
    assert(IStream);
    IStream->read((Char*)&r, sizeof(r));
}

void InputStream::operator >>(std::string& str) {
    assert(IStream);
    Char c;
    *this >> c;
    while (c) {
        str += c;
        *this >> c;
    }
}

bool InputStream::good() {
    return IStream->good();
}

UInt InputStream::getPos() {
    return IStream->tellg();
}


