/* * This file is a part of Winix * and is not publicly distributed * * Copyright (c) 2012, Tomasz Sowa * All rights reserved. * */ #include "textextstream.h" TexTextStream::TexTextStream() { } /* without escaping */ TexTextStream & TexTextStream::PutText(const char * str) { TextStream::operator<<(str); return *this; } TexTextStream & TexTextStream::PutText(const char * str, size_t len) { TextStream::operator<<(str); return *this; } TexTextStream & TexTextStream::PutText(const std::string * str) { return PutText(str->c_str()); } TexTextStream & TexTextStream::PutText(const std::string & str) { return PutText(str.c_str()); } TexTextStream & TexTextStream::PutText(const wchar_t * str) { TextStream::operator<<(str); return *this; } TexTextStream & TexTextStream::PutText(const std::wstring * str) { return PutText(str->c_str()); } TexTextStream & TexTextStream::PutText(const std::wstring & str) { return PutText(str.c_str()); } TexTextStream & TexTextStream::operator<<(const RawText & raw) { return PutText(raw.par); } TexTextStream & TexTextStream::operator<<(const RawText & raw) { return PutText(raw.par); } TexTextStream & TexTextStream::operator<<(RawText raw) { return PutText(raw.par); } TexTextStream & TexTextStream::operator<<(RawText raw) { return PutText(raw.par); } TexTextStream & TexTextStream::operator<<(RawText raw) { return PutText(raw.par); } TexTextStream & TexTextStream::operator<<(RawText raw) { return PutText(raw.par); } TexTextStream & TexTextStream::operator<<(RawText raw) { TextStream::operator<<(raw.par); return *this; } TexTextStream & TexTextStream::operator<<(RawText raw) { TextStream::operator<<(raw.par); return *this; } TexTextStream & TexTextStream::operator<<(RawText raw) { TextStream::operator<<(raw.par); return *this; } TexTextStream & TexTextStream::operator<<(RawText raw) { TextStream::operator<<(raw.par); return *this; } TexTextStream & TexTextStream::operator<<(RawText raw) { TextStream::operator<<(raw.par); return *this; } TexTextStream & TexTextStream::operator<<(RawText raw) { TextStream::operator<<(raw.par); return *this; } TexTextStream & TexTextStream::operator<<(RawText raw) { TextStream::operator<<(raw.par); return *this; } TexTextStream & TexTextStream::operator<<(RawText raw) { TextStream::operator<<(raw.par); return *this; } TexTextStream & TexTextStream::Write(const char * buf, size_t len) { TextStream::Write(buf, len); return *this; } TexTextStream & TexTextStream::Write(const wchar_t * buf, size_t len) { TextStream::Write(buf, len); return *this; } TexTextStream & TexTextStream::write(const char * buf, size_t len) { TextStream::write(buf, len); return *this; } TexTextStream & TexTextStream::write(const wchar_t * buf, size_t len) { TextStream::write(buf, len); return *this; } /* with escaping */ TexTextStream & TexTextStream::ETextPutChar(char c) { return ETextPutChar(static_cast(c)); } TexTextStream & TexTextStream::ETextPutChar(wchar_t c) { if( c == '$' ) buffer += L"\\$"; else if( c == '#' ) buffer += L"\\#"; else if( c == '%' ) buffer += L"\\%"; else if( c == '&' ) buffer += L"\\&"; else if( c == '\\' ) buffer += L"$\\backslash$"; else if( c == '{' ) buffer += L"$\\{$"; else if( c == '}' ) buffer += L"$\\}$"; else if( c == '^' ) buffer += L""; // !! IMPROVE ME add \char with specific code else if( c == '_' ) buffer += L"\\_"; else if( c == '~' ) buffer += L""; // !! IMPROVE ME add \char with specific code else if( c == '-' ) buffer += L"{-}"; else if( c != 0 ) buffer += c; return *this; } TexTextStream & TexTextStream::EPutText(const char * str) { for( ; *str ; ++str ) ETextPutChar(*str); return *this; } TexTextStream & TexTextStream::EPutText(const char * str, size_t len) { for(size_t i=0 ; ic_str(), str->size()); } TexTextStream & TexTextStream::EPutText(const std::string & str) { return EPutText(str.c_str(), str.size()); } TexTextStream & TexTextStream::EPutText(const wchar_t * str) { for( ; *str ; ++str ) ETextPutChar(*str); return *this; } TexTextStream & TexTextStream::EPutText(const wchar_t * str, size_t len) { for(size_t i=0 ; ic_str(), str->size()); } TexTextStream & TexTextStream::EPutText(const std::wstring & str) { return EPutText(str.c_str(), str.size()); } TexTextStream & TexTextStream::operator<<(const char * str) { return EPutText(str); } TexTextStream & TexTextStream::operator<<(const std::string * str) { return EPutText(str); } TexTextStream & TexTextStream::operator<<(const std::string & str) { return EPutText(str); } TexTextStream & TexTextStream::operator<<(const wchar_t * str) { return EPutText(str); } TexTextStream & TexTextStream::operator<<(const std::wstring * str) { return EPutText(str); } TexTextStream & TexTextStream::operator<<(const std::wstring & str) { return EPutText(str); } TexTextStream & TexTextStream::operator<<(char v) { ETextPutChar(v); return *this; } TexTextStream & TexTextStream::operator<<(wchar_t v) { ETextPutChar(v); return *this; } TexTextStream & TexTextStream::operator<<(int v) { TextStream::operator<<(v); return *this; } TexTextStream & TexTextStream::operator<<(long v) { TextStream::operator<<(v); return *this; } TexTextStream & TexTextStream::operator<<(unsigned int v) { TextStream::operator<<(v); return *this; } TexTextStream & TexTextStream::operator<<(unsigned long v) { TextStream::operator<<(v); return *this; } TexTextStream & TexTextStream::operator<<(double v) { TextStream::operator<<(v); return *this; } TexTextStream & TexTextStream::operator<<(const void * v) { TextStream::operator<<(v); return *this; } TexTextStream & TexTextStream::operator<<(const PT::Space & space) { tmp_stream.Clear(); // !! IMPROVE ME // we can calculate how many memory is needed beforehand space.Serialize(tmp_stream, true, false); operator<<(tmp_stream.Str()); tmp_stream.Clear(); return *this; } TexTextStream & TexTextStream::operator<<(const PT::Date & date) { tmp_stream.Clear(); // !! IMPROVE ME // we can calculate how many memory is needed beforehand date.Serialize(tmp_stream); operator<<(tmp_stream.Str()); tmp_stream.Clear(); return *this; }