Added NzInputStream

Added NzFile::Read(buffer, size)
NzFile::Read(nullptr, size) now acts as a skip function (ex: SetCursorPos(GetCursorPos() + size)
This commit is contained in:
Lynix
2012-05-15 13:26:35 +02:00
parent 182bd4cffe
commit cef402c8a5
17 changed files with 101 additions and 49 deletions

View File

@@ -71,6 +71,9 @@
#define NAZARA_THREADSAFETY_STRINGSTREAM 0 // NzStringStream
#endif
// Optimise certaines parties du code avec les avancées venues de Windows Vista (Nécessite Vista ou supérieur et compilateur compatible)
#define NAZARA_CORE_WINDOWS_VISTA 0
/*
// Règle le temps entre le réveil du thread des timers et l'activation d'un timer (En millisecondes)
#define NAZARA_CORE_TIMER_WAKEUPTIME 10

View File

@@ -8,6 +8,7 @@
#define NAZARA_ERROR_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Config.hpp>
#include <Nazara/Core/String.hpp>
#if NAZARA_CORE_ENABLE_ASSERTS || defined(NAZARA_DEBUG)

View File

@@ -12,6 +12,7 @@
#include <Nazara/Core/Endianness.hpp>
#include <Nazara/Core/Hashable.hpp>
#include <Nazara/Core/HashDigest.hpp>
#include <Nazara/Core/InputStream.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Utility/NonCopyable.hpp>
@@ -20,7 +21,7 @@
class NzFileImpl;
class NAZARA_API NzFile : public NzHashable, NzNonCopyable
class NAZARA_API NzFile : public NzHashable, public NzInputStream, NzNonCopyable
{
public:
enum CursorPosition
@@ -74,6 +75,7 @@ class NAZARA_API NzFile : public NzHashable, NzNonCopyable
bool Open(unsigned long openMode = Current);
std::size_t Read(void* buffer, std::size_t size);
std::size_t Read(void* buffer, std::size_t typeSize, unsigned int count);
bool Rename(const NzString& newFilePath);

View File

@@ -0,0 +1,21 @@
// Copyright (C) 2012 Jérôme Leclercq
// This file is part of the "Nazara Engine".
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_INPUTSTREAM_HPP
#define NAZARA_INPUTSTREAM_HPP
#include <Nazara/Prerequesites.hpp>
class NzInputStream
{
public:
virtual ~NzInputStream();
virtual bool EndOfFile() const = 0;
virtual std::size_t Read(void* buffer, std::size_t size) = 0;
};
#endif // NAZARA_INPUTSTREAM_HPP

View File

@@ -283,19 +283,19 @@ class NAZARA_API NzString : public NzHashable
{
}
SharedString(unsigned int bufferSize, unsigned int stringSize, unsigned short referenceCount, char* str) :
SharedString(unsigned short referenceCount, unsigned int bufferSize, unsigned int stringSize, char* str) :
allocatedSize(bufferSize),
size(stringSize),
refCount(referenceCount),
string(str)
string(str),
refCount(referenceCount)
{
}
unsigned int allocatedSize;
unsigned int size;
unsigned short refCount;
char* string;
unsigned short refCount;
NazaraMutex(mutex)
};