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

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

EndianAwareOutputStream::EndianAwareOutputStream(OutputStream* s) :
                         OutputStreamDecorator(s) {
    Converter = SYS.getEndianConvert();
}

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

void EndianAwareOutputStream::operator <<(Int i) {
    (*Stream) << Converter->swap(i);
}

void EndianAwareOutputStream::operator <<(UInt i) {
    *Stream << Converter->swap(i);
}

void EndianAwareOutputStream::operator <<(Long i) {
    *Stream << Converter->swap(i);
}

void EndianAwareOutputStream::operator <<(ULong i) {
    *Stream << Converter->swap(i);
}

void EndianAwareOutputStream::operator <<(Short i) {
    *Stream << Converter->swap(i);
}

void EndianAwareOutputStream::operator <<(UShort i) {
    *Stream << Converter->swap(i);
}

void EndianAwareOutputStream::operator <<(Char i) {
    *Stream << Converter->swap(i);
}

void EndianAwareOutputStream::operator <<(UChar i) {
    *Stream << Converter->swap(i);
}

void EndianAwareOutputStream::operator <<(Real r) {
    *Stream << Converter->swap(r);
}

