* Add fill to Stream

This commit is contained in:
Phillip Stephens 2014-05-15 00:41:54 -07:00
parent a19520ea1e
commit dfb0ce0b4f
4 changed files with 17 additions and 1 deletions

View File

@ -272,6 +272,9 @@ public:
*/
void writeString(const std::string& str);
void fill(Uint8 val, Uint64 length);
void fill(Int8 val, Uint64 length);
void setProgressCallback(std::function<void(int)> cb);
protected:
void loadData();

View File

@ -63,7 +63,7 @@ namespace Sakura
template <typename T>
class Vector2D
{ifndef
{
public:
T x;
T y;

View File

@ -74,6 +74,8 @@ protected:
virtual void writeBool (bool){THROW_NOT_IMPLEMENTED_EXCEPTION();}
virtual void writeString(const std::string&){THROW_NOT_IMPLEMENTED_EXCEPTION();}
virtual void writeUnicode(const std::string&){THROW_NOT_IMPLEMENTED_EXCEPTION();}
virtual void fill(Uint8, Uint64) {THROW_NOT_IMPLEMENTED_EXCEPTION();}
virtual void fill(Int8, Uint64) {THROW_NOT_IMPLEMENTED_EXCEPTION();}
};
}
#endif // STREAM_HPP

View File

@ -460,6 +460,17 @@ void BinaryWriter::writeString(const std::string& str)
writeUByte(0);
}
void BinaryWriter::fill(Uint8 val, Uint64 length)
{
while ((length--) > 0)
writeUByte(val);
}
void BinaryWriter::fill(Int8 val, Uint64 length)
{
fill((Uint8)val, length);
}
void BinaryWriter::setProgressCallback(std::function<void (int)> cb)
{
m_progressCallback = cb;