Skip to content

Commit

Permalink
Rename header containing TextFileInputStream
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Aug 31, 2017
1 parent aa25da7 commit 4b6e3e2
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 45 deletions.
2 changes: 1 addition & 1 deletion libs/DirectoryArchiveTextFile.h
@@ -1,7 +1,7 @@
#pragma once

#include "iarchive.h"
#include "stream/textfilestream.h"
#include "stream/TextFileInputStream.h"

namespace archive
{
Expand Down
2 changes: 1 addition & 1 deletion libs/debugging/ScopedDebugTimer.h
Expand Up @@ -36,7 +36,7 @@
#endif

#include <string>
#include "stream/textfilestream.h"
#include "stream/TextFileInputStream.h"

namespace {

Expand Down
16 changes: 9 additions & 7 deletions libs/stream/PointerInputStream.h
Expand Up @@ -2,11 +2,12 @@

#include "idatastream.h"

namespace stream
{

/**
* A class implementing the InputStream interface
* around a simple byte pointer. No bounds or
* validity checking is performed on the pointer
* passed to the constructor.
* A class implementing the InputStream interface around a simple byte pointer.
* No bounds or validity checking is performed on the given pointer.
*/
class PointerInputStream :
public InputStream
Expand All @@ -17,10 +18,9 @@ class PointerInputStream :
public:
PointerInputStream(const byte* pointer) :
_curPos(pointer)
{
}
{}

std::size_t read(byte* buffer, std::size_t length)
std::size_t read(byte* buffer, std::size_t length) override
{
const byte* end = _curPos + length;

Expand All @@ -42,3 +42,5 @@ class PointerInputStream :
return _curPos;
}
};

}
5 changes: 5 additions & 0 deletions libs/stream/ScopedArchiveBuffer.h
Expand Up @@ -4,6 +4,9 @@
#include "iarchive.h"
#include <memory>

namespace archive
{

/**
* Scoped class reading all the data from the attached
* ArchiveFile into a single memory chunk. Clients usually
Expand All @@ -27,3 +30,5 @@ class ScopedArchiveBuffer
data[file.size()] = 0;
}
};

}
Expand Up @@ -28,15 +28,15 @@ class TextFileInputStream :
return _file == 0;
}

std::size_t read(char* buffer, std::size_t length)
std::size_t read(char* buffer, std::size_t length) override
{
return fread(buffer, 1, length, _file);
}

// greebo: Override default std::streambuf::seekoff() method to provide buffer positioning capabilities
virtual std::streampos seekoff(std::streamoff off,
std::ios_base::seekdir way,
std::ios_base::openmode which = std::ios_base::in | std::ios_base::out)
std::ios_base::openmode which = std::ios_base::in | std::ios_base::out) override
{
if (way == std::ios_base::beg)
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/image/ImageLoaderWx.cpp
Expand Up @@ -63,7 +63,7 @@ ImageLoaderWx::ImageLoaderWx()

ImagePtr ImageLoaderWx::load(ArchiveFile& file) const
{
ScopedArchiveBuffer buffer(file);
archive::ScopedArchiveBuffer buffer(file);

// Construct a wxImage from the memory buffer
wxMemoryInputStream inputStream(buffer.buffer, buffer.length);
Expand Down
44 changes: 22 additions & 22 deletions plugins/image/TGALoader.cpp
Expand Up @@ -44,7 +44,7 @@ class Flip10 {}; // horizontal flip only
class Flip11 {}; // both

template<typename PixelDecoder>
void image_decode(PointerInputStream& istream, PixelDecoder& decode, RGBAImage& image, const Flip00&)
void image_decode(stream::PointerInputStream& istream, PixelDecoder& decode, RGBAImage& image, const Flip00&)
{
RGBAPixel* end = image.pixels + (image.height * image.width);
for(RGBAPixel* row = end; row != image.pixels; row -= image.width)
Expand All @@ -57,7 +57,7 @@ void image_decode(PointerInputStream& istream, PixelDecoder& decode, RGBAImage&
}

template<typename PixelDecoder>
void image_decode(PointerInputStream& istream, PixelDecoder& decode, RGBAImage& image, const Flip01&)
void image_decode(stream::PointerInputStream& istream, PixelDecoder& decode, RGBAImage& image, const Flip01&)
{
RGBAPixel* end = image.pixels + (image.height * image.width);
for(RGBAPixel* row = image.pixels; row != end; row += image.width)
Expand All @@ -70,7 +70,7 @@ void image_decode(PointerInputStream& istream, PixelDecoder& decode, RGBAImage&
}

template<typename PixelDecoder>
void image_decode(PointerInputStream& istream, PixelDecoder& decode, RGBAImage& image, const Flip10&)
void image_decode(stream::PointerInputStream& istream, PixelDecoder& decode, RGBAImage& image, const Flip10&)
{
RGBAPixel* end = image.pixels + (image.height * image.width);
for(RGBAPixel* row = end; row != image.pixels; row -= image.width)
Expand All @@ -83,7 +83,7 @@ void image_decode(PointerInputStream& istream, PixelDecoder& decode, RGBAImage&
}

template<typename PixelDecoder>
void image_decode(PointerInputStream& istream, PixelDecoder& decode, RGBAImage& image, const Flip11&)
void image_decode(stream::PointerInputStream& istream, PixelDecoder& decode, RGBAImage& image, const Flip11&)
{
RGBAPixel* end = image.pixels + (image.height * image.width);
for(RGBAPixel* row = image.pixels; row != end; row += image.width)
Expand All @@ -95,22 +95,22 @@ void image_decode(PointerInputStream& istream, PixelDecoder& decode, RGBAImage&
}
}

inline void istream_read_gray(PointerInputStream& istream, RGBAPixel& pixel)
inline void istream_read_gray(stream::PointerInputStream& istream, RGBAPixel& pixel)
{
istream.read(&pixel.blue, 1);
pixel.red = pixel.green = pixel.blue;
pixel.alpha = 0xff;
}

inline void istream_read_rgb(PointerInputStream& istream, RGBAPixel& pixel)
inline void istream_read_rgb(stream::PointerInputStream& istream, RGBAPixel& pixel)
{
istream.read(&pixel.blue, 1);
istream.read(&pixel.green, 1);
istream.read(&pixel.red, 1);
pixel.alpha = 0xff;
}

inline void istream_read_rgba(PointerInputStream& istream, RGBAPixel& pixel)
inline void istream_read_rgba(stream::PointerInputStream& istream, RGBAPixel& pixel)
{
istream.read(&pixel.blue, 1);
istream.read(&pixel.green, 1);
Expand All @@ -121,14 +121,14 @@ inline void istream_read_rgba(PointerInputStream& istream, RGBAPixel& pixel)
class TargaDecodeGrayPixel
{
public:
void operator()(PointerInputStream& istream, RGBAPixel& pixel)
void operator()(stream::PointerInputStream& istream, RGBAPixel& pixel)
{
istream_read_gray(istream, pixel);
}
};

template<typename Flip>
void targa_decode_grayscale(PointerInputStream& istream, RGBAImage& image, const Flip& flip)
void targa_decode_grayscale(stream::PointerInputStream& istream, RGBAImage& image, const Flip& flip)
{
TargaDecodeGrayPixel decode;
image_decode(istream, decode, image, flip);
Expand All @@ -137,14 +137,14 @@ void targa_decode_grayscale(PointerInputStream& istream, RGBAImage& image, const
class TargaDecodeRGBPixel
{
public:
void operator()(PointerInputStream& istream, RGBAPixel& pixel)
void operator()(stream::PointerInputStream& istream, RGBAPixel& pixel)
{
istream_read_rgb(istream, pixel);
}
};

template<typename Flip>
void targa_decode_rgb(PointerInputStream& istream, RGBAImage& image, const Flip& flip)
void targa_decode_rgb(stream::PointerInputStream& istream, RGBAImage& image, const Flip& flip)
{
TargaDecodeRGBPixel decode;
image_decode(istream, decode, image, flip);
Expand All @@ -153,14 +153,14 @@ void targa_decode_rgb(PointerInputStream& istream, RGBAImage& image, const Flip&
class TargaDecodeRGBAPixel
{
public:
void operator()(PointerInputStream& istream, RGBAPixel& pixel)
void operator()(stream::PointerInputStream& istream, RGBAPixel& pixel)
{
istream_read_rgba(istream, pixel);
}
};

template<typename Flip>
void targa_decode_rgba(PointerInputStream& istream, RGBAImage& image, const Flip& flip)
void targa_decode_rgba(stream::PointerInputStream& istream, RGBAImage& image, const Flip& flip)
{
TargaDecodeRGBAPixel decode;
image_decode(istream, decode, image, flip);
Expand All @@ -169,7 +169,7 @@ void targa_decode_rgba(PointerInputStream& istream, RGBAImage& image, const Flip
typedef byte TargaPacket;
typedef byte TargaPacketSize;

inline void targa_packet_read_istream(TargaPacket& packet, PointerInputStream& istream)
inline void targa_packet_read_istream(TargaPacket& packet, stream::PointerInputStream& istream)
{
istream.read(&packet, 1);
}
Expand All @@ -194,7 +194,7 @@ class TargaDecodeRGBPixelRLE
TargaDecodeRGBPixelRLE() : m_packetSize(0)
{
}
void operator()(PointerInputStream& istream, RGBAPixel& pixel)
void operator()(stream::PointerInputStream& istream, RGBAPixel& pixel)
{
if(m_packetSize == 0)
{
Expand All @@ -221,7 +221,7 @@ class TargaDecodeRGBPixelRLE
};

template<typename Flip>
void targa_decode_rle_rgb(PointerInputStream& istream, RGBAImage& image, const Flip& flip)
void targa_decode_rle_rgb(stream::PointerInputStream& istream, RGBAImage& image, const Flip& flip)
{
TargaDecodeRGBPixelRLE decode;
image_decode(istream, decode, image, flip);
Expand All @@ -236,7 +236,7 @@ class TargaDecodeRGBAPixelRLE
TargaDecodeRGBAPixelRLE() : m_packetSize(0)
{
}
void operator()(PointerInputStream& istream, RGBAPixel& pixel)
void operator()(stream::PointerInputStream& istream, RGBAPixel& pixel)
{
if(m_packetSize == 0)
{
Expand All @@ -263,7 +263,7 @@ class TargaDecodeRGBAPixelRLE
};

template<typename Flip>
void targa_decode_rle_rgba(PointerInputStream& istream, RGBAImage& image, const Flip& flip)
void targa_decode_rle_rgba(stream::PointerInputStream& istream, RGBAImage& image, const Flip& flip)
{
TargaDecodeRGBAPixelRLE decode;
image_decode(istream, decode, image, flip);
Expand All @@ -278,7 +278,7 @@ struct TargaHeader
unsigned char pixel_size, attributes;
};

inline void targa_header_read_istream(TargaHeader& targa_header, PointerInputStream& istream)
inline void targa_header_read_istream(TargaHeader& targa_header, stream::PointerInputStream& istream)
{
targa_header.id_length = istream_read_byte(istream);
targa_header.colormap_type = istream_read_byte(istream);
Expand Down Expand Up @@ -319,7 +319,7 @@ class ScopeDelete
};

template<typename Flip>
RGBAImagePtr Targa_decodeImageData(const TargaHeader& targa_header, PointerInputStream& istream, const Flip& flip)
RGBAImagePtr Targa_decodeImageData(const TargaHeader& targa_header, stream::PointerInputStream& istream, const Flip& flip)
{
RGBAImagePtr image (new RGBAImage(targa_header.width, targa_header.height));

Expand Down Expand Up @@ -365,7 +365,7 @@ const unsigned int TGA_FLIP_VERTICAL = 0x20;

RGBAImagePtr LoadTGABuff(const byte* buffer)
{
PointerInputStream istream(buffer);
stream::PointerInputStream istream(buffer);
TargaHeader targa_header;

targa_header_read_istream(targa_header, istream);
Expand Down Expand Up @@ -419,7 +419,7 @@ RGBAImagePtr LoadTGABuff(const byte* buffer)

ImagePtr TGALoader::load(ArchiveFile& file) const
{
ScopedArchiveBuffer buffer(file);
archive::ScopedArchiveBuffer buffer(file);
return LoadTGABuff(buffer.buffer);
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/sound/OggFileStream.h
Expand Up @@ -14,11 +14,11 @@ namespace sound {

class OggFileStream
{
ScopedArchiveBuffer& _source;
archive::ScopedArchiveBuffer& _source;

unsigned char* _curPtr;
public:
OggFileStream(ScopedArchiveBuffer& source) :
OggFileStream(archive::ScopedArchiveBuffer& source) :
_source(source)
{
// Set the pointer to the beginning of the buffer
Expand Down
4 changes: 2 additions & 2 deletions plugins/sound/SoundPlayer.cpp
Expand Up @@ -5,7 +5,7 @@
#include <vector>
#include <boost/algorithm/string/case_conv.hpp>

#include "stream/textfilestream.h"
#include "stream/TextFileInputStream.h"
#include "os/path.h"
#include <memory>

Expand Down Expand Up @@ -203,7 +203,7 @@ void SoundPlayer::createBufferDataFromWav(ArchiveFile& file)
void SoundPlayer::createBufferDataFromOgg(ArchiveFile& file)
{
// Convert the file into a buffer, self-destructs at end of scope
ScopedArchiveBuffer buffer(file);
archive::ScopedArchiveBuffer buffer(file);

// This is an OGG Vorbis file, decode it
vorbis_info* vorbisInfo;
Expand Down
2 changes: 1 addition & 1 deletion plugins/uimanager/colourscheme/ColourSchemeManager.cpp
@@ -1,7 +1,7 @@
#include "ColourSchemeManager.h"
#include "iregistry.h"

#include "stream/textfilestream.h"
#include "stream/TextFileInputStream.h"

namespace ui {

Expand Down
2 changes: 1 addition & 1 deletion radiant/map/Map.cpp
Expand Up @@ -20,7 +20,7 @@
#include "igame.h"

#include "registry/registry.h"
#include "stream/textfilestream.h"
#include "stream/TextFileInputStream.h"
#include "entitylib.h"
#include "gamelib.h"
#include "os/path.h"
Expand Down
2 changes: 1 addition & 1 deletion radiant/map/MapResource.cpp
Expand Up @@ -23,7 +23,7 @@
#include "os/file.h"
#include "os/fs.h"
#include "map/algorithm/Traverse.h"
#include "stream/textfilestream.h"
#include "stream/TextFileInputStream.h"
#include "scenelib.h"

#include <functional>
Expand Down
2 changes: 1 addition & 1 deletion tools/msvc/libs.vcxproj
Expand Up @@ -198,7 +198,7 @@
<ClInclude Include="..\..\libs\stream\FileInputStream.h" />
<ClInclude Include="..\..\libs\stream\PointerInputStream.h" />
<ClInclude Include="..\..\libs\stream\ScopedArchiveBuffer.h" />
<ClInclude Include="..\..\libs\stream\textfilestream.h" />
<ClInclude Include="..\..\libs\stream\TextFileInputStream.h" />
<ClInclude Include="..\..\libs\string\convert.h" />
<ClInclude Include="..\..\libs\string\string.h" />
<ClInclude Include="..\..\libs\SurfaceShader.h" />
Expand Down
6 changes: 3 additions & 3 deletions tools/msvc/libs.vcxproj.filters
Expand Up @@ -111,9 +111,6 @@
<ClInclude Include="..\..\libs\render\NopVolumeTest.h">
<Filter>render</Filter>
</ClInclude>
<ClInclude Include="..\..\libs\stream\textfilestream.h">
<Filter>stream</Filter>
</ClInclude>
<ClInclude Include="..\..\libs\stream\BufferInputStream.h">
<Filter>stream</Filter>
</ClInclude>
Expand Down Expand Up @@ -155,6 +152,9 @@
<ClInclude Include="..\..\libs\stream\FileInputStream.h">
<Filter>stream</Filter>
</ClInclude>
<ClInclude Include="..\..\libs\stream\TextFileInputStream.h">
<Filter>stream</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="util">
Expand Down

0 comments on commit 4b6e3e2

Please sign in to comment.