
#include <WFX/io/EndianAwareInputStream.h>
#include <WFX/lang/WFXSystem.h>

using namespace WFX;
using namespace WFX::io;
using namespace WFX::util;
using namespace WFX::lang;
using namespace std;

EndianAwareInputStream::EndianAwareInputStream(InputStream* s) :
                         InputStreamDecorator(s) {
    Converter = SYS.getEndianConvert();
}

EndianAwareInputStream::~EndianAwareInputStream() {
    delete Converter;
}

void EndianAwareInputStream::operator >>(Int& i) {
    *Stream >> i;
    i = Converter->swap(i);
}

void EndianAwareInputStream::operator >>(UInt& i) {
    *Stream >> i;
    i = Converter->swap(i);
}

void EndianAwareInputStream::operator >>(Long& i) {
    *Stream >> i;
    i = Converter->swap(i);
}

void EndianAwareInputStream::operator >>(ULong& i) {
    *Stream >> i;
    i = Converter->swap(i);
}

void EndianAwareInputStream::operator >>(Short& i) {
    *Stream >> i;
    i = Converter->swap(i);
}

void EndianAwareInputStream::operator >>(UShort& i) {
    *Stream >> i;
    i = Converter->swap(i);
}

void EndianAwareInputStream::operator >>(Char& i) {
    *Stream >> i;
    i = Converter->swap(i);
}

void EndianAwareInputStream::operator >>(UChar& i) {
    *Stream >> i;
    i = Converter->swap(i);
}

void EndianAwareInputStream::operator >>(Real& r) {
    *Stream >> r;
    r = Converter->swap(r);
}

