1
0
mirror of https://github.com/Halofreak1990/XFXFramework synced 2024-12-26 13:49:34 +01:00
XFXFramework/include/System/IO/StreamWriter.h
Halofreak1990 e7a47c8ed9 Revamped the List class so that it can (properly) handle pointers as well
Added 'ValueTypes' Single and Double
Added some components in the new System::Net namespace
Added the Console class, which can be used to output text to the screen
Updated a bunch of structs to include the IComparable and IEquatable interfaces, and inheritance from Object to allow better interoperability between container classes and other types
Replaced all exception handling code with a report to stdout.txt - this will, I hope, eventually be reversed, but as of yet, there is no support for exceptions.

BEWARE! Even though all libraries correctly compile, you cannot use any class/structure that inherits from a template class, because stupid G++ wants to include exception handling for each template.
2011-11-07 01:29:50 +00:00

74 lines
2.0 KiB
C++

/********************************************************
* StreamWriter.h *
* *
* XFX StreamWriter definition file *
* Copyright © XFX Team. All Rights Reserved *
********************************************************/
#ifndef _SYSTEM_IO_STREAMWRITER_
#define _SYSTEM_IO_STREAMWRITER_
#include <System/Text/Encoding.h>
#include <System/Text/Encoder.h>
#include "Stream.h"
#include "TextWriter.h"
#include <System/Types.h>
using namespace System::Text;
namespace System
{
namespace IO
{
/// <summary>
/// Implements a TextWriter for writing characters to a stream in a particular encoding.
/// </summary>
class StreamWriter : public TextWriter, virtual Object
{
private:
static Encoding _UTF8NoBOM;
bool autoFlush;
byte* byteBuffer;
char* charBuffer;
int charLen;
int charPos;
bool closable;
static const int DefaultBufferSize;
Encoder encoder;
Encoding encoding;
bool haveWrittenPreamble;
Stream* stream;
static Stream* CreateFile(char* path, bool append);
void Init(Stream* stream, Encoding encoding, int bufferSize);
void Flush(bool flushStream, bool flushEncoder);
protected:
void Dispose(bool disposing);
public:
bool AutoFlush;
virtual Stream BaseStream();
Encoding getEncoding();
static const StreamWriter Null;
StreamWriter(char* path);
StreamWriter(char* path, bool append);
StreamWriter(char* path, bool append, Encoding encoding);
StreamWriter(char* path, bool append, Encoding encoding, int bufferSize);
StreamWriter(Stream* stream);
StreamWriter(Stream* stream, Encoding encoding);
StreamWriter(Stream* stream, Encoding encoding, int bufferSize);
virtual ~StreamWriter();
void Close();
void Flush();
void Write(char value);
void Write(char buffer[]);
void Write(char buffer[], int index, int count);
void Write(const char* value);
};
}
}
#endif //_SYSTEM_IO_STREAMWRITER_