1
0
mirror of https://github.com/Halofreak1990/XFXFramework synced 2024-12-26 13:49:34 +01:00
XFXFramework/include/System/IO/BinaryReader.h
Halofreak1990 1bf933432b List class now works.
TextureCollection is broken because it can somehow not resolve Texture as template argument for the List it uses.
Added missing BinaryWriter and TextWriter classes to System::IO namespace
Modified BinaryReader
Added PacketReader and PacketWriter classes to XFX::Net namespace
2011-03-10 22:55:43 +00:00

62 lines
1.4 KiB
C++

#ifndef _IO_BINARYREADER_
#define _IO_BINARYREADER_
#include "../Types.h"
#include "../Interfaces.h"
#include "../Text/Encoding.h"
#include "Stream.h"
using namespace System::Text;
namespace System
{
namespace IO
{
/// <summary>
/// Reads primitive data types as binary values in a specific encoding.
/// </summary>
class BinaryReader : public IDisposable, virtual Object
{
private:
bool m_2BytesPerChar;
byte* m_buffer;
char* m_charBuffer;
byte* m_charBytes;
char* m_singleChar;
Stream* m_stream;
Encoding m_encoding;
bool m_isMemoryStream;
Decoder m_decoder;
//! 128 chars should cover most strings in one grab.
static const int MaxBufferSize = 128;
bool m_disposed;
int InternalReadChars(char buffer[], int index, int count);
int InternalReadOneChar();
protected:
virtual void Dispose(bool disposing);
virtual void FillBuffer(int numBytes);
public:
virtual Stream* BaseStream();
BinaryReader(Stream* input);
BinaryReader(Stream* input, Encoding encoding);
virtual ~BinaryReader();
virtual void Close();
virtual void Dispose();
virtual int PeekChar();
virtual int Read();
virtual int Read(byte buffer[], int index, int count);
virtual int Read(char buffer[], int index, int count);
virtual float ReadSingle();
};
}
}
#endif //_IO_BINARYREADER_