Gorgon Game Engine
Writer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stdexcept>
4 #include <iostream>
5 #include <fstream>
6 #include <map>
7 #include <memory>
8 
9 #include "../Utils/Assert.h"
10 #include "../Filesystem.h"
11 #include "../IO/Stream.h"
12 #include "../Geometry/Point.h"
13 
14 namespace Gorgon { namespace Resource {
15 
16  class Base;
17 
19  class WriteError : public std::runtime_error {
20  public:
21 
23  enum ErrorType {
24 
26  Unknown = 0,
27 
31 
33  NoData = 2,
34  };
35 
36 
39 
40  }
41 
43  WriteError(ErrorType number, const std::string &text) : runtime_error(text), number(number) {
44 
45  }
46 
49 
51  static const std::string ErrorStrings[3];
52  };
53 
59  class Writer {
60  friend class File;
61  public:
62 
63  class Marker {
64  friend class Writer;
65  public:
66  Marker(const Marker &) = delete;
67  Marker(Marker &&other) {
68  pos = other.pos;
69  other.pos = -1;
70  }
71 
72  Marker &operator =(Marker &&other) {
73  pos = other.pos;
74  other.pos = -1;
75 
76  return *this;
77  }
78 
79  ~Marker() {
80  if(pos!=-1)
81  Utils::ASSERT_FALSE("Marker is not ended.");
82  }
83 
84  private:
85  Marker(unsigned long pos) : pos(pos) { }
86 
87  unsigned long pos = -1;
88  };
89 
91  virtual ~Writer() {
92  ASSERT(stream==nullptr, "Stream is not closed by the opener");
93  }
94 
96  std::ostream &GetStream() {
97  ASSERT(stream, "Writer is not opened.");
98  ASSERT(IsGood(), "Writer is failed.");
99 
100  return *stream;
101  }
102 
104  bool IsGood() const {
105  return stream && stream->good();
106  }
107 
108  void Close() {
109  close();
110  stream = nullptr;
111  }
112 
114  unsigned long Tell() const {
115  ASSERT(stream, "Writer is not opened.");
116  ASSERT(IsGood(), "Writer is failed.");
117 
118  return (unsigned long)stream->tellp();
119  }
120 
122  void Seek(unsigned long pos) {
123  ASSERT(stream, "Writer is not opened.");
124  ASSERT(IsGood(), "Writer is failed.");
125 
126  stream->seekp((std::streampos)pos, std::ios::beg);
127  }
128 
129 
136 
137 
139  template<class E_>
140  void WriteEnum32(E_ value) {
141  ASSERT(stream, "Writer is not opened.");
142  ASSERT(IsGood(), "Writer is failed.");
143 
144  IO::WriteEnum32(*stream, value);
145  }
146 
149  void WriteInt32(long value) {
150  ASSERT(stream, "Writer is not opened.");
151  ASSERT(IsGood(), "Writer is failed.");
152 
153  IO::WriteInt32(*stream, value);
154  }
155 
158  void WriteUInt32(unsigned long value) {
159  ASSERT(stream, "Writer is not opened.");
160  ASSERT(IsGood(), "Writer is failed.");
161 
162  IO::WriteUInt32(*stream, value);
163  }
164 
167  void WriteInt16(int value) {
168  ASSERT(stream, "Writer is not opened.");
169  ASSERT(IsGood(), "Writer is failed.");
170 
171  IO::WriteInt16(*stream, value);
172  }
173 
176  void WriteUInt16(unsigned value) {
177  ASSERT(stream, "Writer is not opened.");
178  ASSERT(IsGood(), "Writer is failed.");
179 
180  IO::WriteUInt16(*stream, value);
181  }
182 
185  void WriteInt8(char value) {
186  ASSERT(stream, "Writer is not opened.");
187  ASSERT(IsGood(), "Writer is failed.");
188 
189  IO::WriteInt8(*stream, value);
190  }
191 
194  void WriteUInt8(Byte value) {
195  ASSERT(stream, "Writer is not opened.");
196  ASSERT(IsGood(), "Writer is failed.");
197 
198  IO::WriteUInt8(*stream, value);
199  }
200 
203  void WriteFloat(float value) {
204  ASSERT(stream, "Writer is not opened.");
205  ASSERT(IsGood(), "Writer is failed.");
206 
207  IO::WriteFloat(*stream, value);
208  }
209 
212  void WriteDouble(double value) {
213  ASSERT(stream, "Writer is not opened.");
214  ASSERT(IsGood(), "Writer is failed.");
215 
216  IO::WriteDouble(*stream, value);
217  }
218 
220  void WriteBool(bool value) {
221  ASSERT(stream, "Writer is not opened.");
222  ASSERT(IsGood(), "Writer is failed.");
223 
224  IO::WriteBool(*stream, value);
225  }
226 
228  void WriteRGBA(Graphics::RGBA value) {
229  ASSERT(stream, "Writer is not opened.");
230  ASSERT(IsGood(), "Writer is failed.");
231 
232  IO::WriteRGBA(*stream, value);
233  }
234 
237  ASSERT(stream, "Writer is not opened.");
238  ASSERT(IsGood(), "Writer is failed.");
239 
240  IO::WriteRGBAf(*stream, value);
241  }
242 
245  ASSERT(stream, "Writer is not opened.");
246  ASSERT(IsGood(), "Writer is failed.");
247 
248  IO::WritePoint(*stream, value);
249  }
252  ASSERT(stream, "Writer is not opened.");
253  ASSERT(IsGood(), "Writer is failed.");
254 
255  IO::WritePointf(*stream, value);
256  }
257 
259  void WriteSize(Geometry::Size value) {
260  ASSERT(stream, "Writer is not opened.");
261  ASSERT(IsGood(), "Writer is failed.");
262 
263  IO::WriteSize(*stream, value);
264  }
265 
268  void WriteStringWithSize(const std::string &value) {
269  ASSERT(stream, "Writer is not opened.");
270  ASSERT(IsGood(), "Writer is failed.");
271 
273  }
274 
276  void WriteString(const std::string &value) {
277  ASSERT(stream, "Writer is not opened.");
278  ASSERT(IsGood(), "Writer is failed.");
279 
280  IO::WriteString(*stream, value);
281  }
282 
287  template<class T_>
288  void WriteArray(const T_ *data, unsigned long size) {
289  ASSERT(stream, "Writer is not opened.");
290  ASSERT(IsGood(), "Writer is failed.");
291 
292  IO::WriteArray<T_>(*stream, data, size);
293  }
294 
297  template<class T_>
298  inline void WriteVector(const std::vector<T_> &data) {
299  IO::WriteVector(*stream, data);
300  }
301 
303  void WriteGID(GID::Type value) {
304  ASSERT(stream, "Writer is not opened.");
305  ASSERT(IsGood(), "Writer is failed.");
306 
307  WriteUInt32(value.AsInteger());
308  }
309 
311  void WriteGuid(const SGuid &value) {
312  ASSERT(stream, "Writer is not opened.");
313  ASSERT(IsGood(), "Writer is failed.");
314 
315  IO::WriteGuid(*stream, value);
316  }
317 
319  void WriteChunkSize(unsigned long value) {
320  ASSERT(stream, "Writer is not opened.");
321  ASSERT(IsGood(), "Writer is failed.");
322 
323  WriteUInt32(value);
324  }
325 
327 
328 
330  Marker WriteObjectStart(const Base &base);
331 
332 
334  Marker WriteObjectStart(const Base *base) {
335  ASSERT(base, "Object cannot be nullptr");
336  return WriteObjectStart(*base);
337  }
338 
341  Marker WriteObjectStart(const Base &base, GID::Type type);
342 
345  Marker WriteObjectStart(const Base *base, GID::Type type) {
346  ASSERT(base, "Object cannot be nullptr");
347  return WriteObjectStart(*base, type);
348  }
349 
352  ASSERT(stream, "Writer is not opened.");
353  ASSERT(IsGood(), "Writer is failed.");
354 
355  WriteGID(type);
356  auto pos=Tell();
357  WriteChunkSize(-1);
358 
359  return {pos};
360  }
361 
364  void WriteChunkHeader(GID::Type type, unsigned long size) {
365  ASSERT(stream, "Writer is not opened.");
366  ASSERT(IsGood(), "Writer is failed.");
367 
368  WriteGID(type);
369  WriteChunkSize(size);
370  }
371 
373  void WriteEnd(Marker &marker) {
374  ASSERT(stream, "Writer is not opened.");
375  ASSERT(IsGood(), "Writer is failed.");
376 
377  auto pos=Tell();
378 
379  ASSERT(pos>=marker.pos+4, "Seeking before the start of the file.");
380  ASSERT(marker.pos<=pos, "Marker is after the current position.");
381 
382  auto size=pos-marker.pos-4;
383 
384  Seek(marker.pos);
385  WriteChunkSize(size);
386  Seek(pos);
387 
388  marker.pos=-1;
389  }
390 
391  protected:
394  virtual void close() = 0;
395 
399  virtual bool open(bool thrw) = 0;
400 
403  std::ostream *stream = nullptr;
404 
405  };
406 
407 
409  class FileWriter : public Writer {
410  public:
412  FileWriter(const std::string &filename) : filename(filename) {
413  try {
414  auto path=Filesystem::GetDirectory(filename);
415  auto file=Filesystem::GetFilename(filename);
416 
417  this->filename=Filesystem::Join(Filesystem::Canonical(path), file);
418  }
419  catch(...) {}
420  }
421 
422  protected:
423  virtual void close() override {
424  file.close();
425  }
426 
427  virtual bool open(bool thrw) override {
428  file.open(filename, std::ios::binary);
429  if(!file.is_open()) {
430  if(thrw) {
431  throw WriteError(WriteError::CannotOpenFile, "Cannot open file: "+filename+" either target path does not exist or access denied.");
432  }
433 
434  return false;
435  }
436 
437  stream = &file;
438 
439  return true;
440  }
441 
442  private:
443  std::ofstream file;
444  std::string filename;
445  };
446 
447 } }
Gorgon::Resource::WriteError
This error is fired to a write operations.
Definition: Writer.h:19
Gorgon::Resource::WriteError::WriteError
WriteError(ErrorType number, const std::string &text)
A constructor to allow custom text for the error.
Definition: Writer.h:43
Gorgon::Resource::Writer::WriteRGBAf
void WriteRGBAf(Graphics::RGBAf value)
Writes a RGBAf color, R will be saved first. RGBAf takes 4 x 4 bytes.
Definition: Writer.h:236
Gorgon::IO::WriteInt16
void WriteInt16(std::ostream &stream, int value)
Writes a 16-bit integer from the stream.
Definition: Stream.h:211
Gorgon::Resource::Writer::WriteObjectStart
Marker WriteObjectStart(const Base *base)
Writes the start of an object. Should have a matching WriteEnd with the returned marker.
Definition: Writer.h:334
Gorgon::Resource::TintedObject::save
void save(Writer &writer) const override
Definition: TintedObject.cpp:128
Gorgon::Animation::basic_Storage
This class stores animations as a part of itself so that it can be moved around as a value rather tha...
Definition: Storage.h:21
Gorgon::Resource::Writer::Marker::~Marker
~Marker()
Definition: Writer.h:79
Gorgon::Resource::Writer::WriteString
void WriteString(const std::string &value)
Writes a string without its size.
Definition: Writer.h:276
Gorgon::Graphics::RGBA
This class represents a color information.
Definition: Color.h:91
Gorgon::Filesystem::GetFilename
std::string GetFilename(std::string path)
Returns the filename portion of a file path.
Definition: Filesystem.h:183
Gorgon::Graphics::basic_StackedObjectProvider
This object creates an object that has two subobjects drawn on top of each other.
Definition: StackedObject.h:116
Gorgon::Resource::GID::Type::AsInteger
constexpr uint32_t AsInteger() const
Returns the value of the GID as an integer.
Definition: GID.h:32
File.h
Gorgon::Resource::Writer::GetStream
std::ostream & GetStream()
This should be last resort, use if the actual stream is needed.
Definition: Writer.h:96
Gorgon::Graphics::BitmapAnimationProvider
basic_TextureAnimationProvider< Bitmap, basic_TextureAnimation, basic_AnimationFrame< Bitmap > > BitmapAnimationProvider
Definition: TextureAnimation.h:520
Gorgon::Resource::GID::Null
constexpr Type Null
Null resource.
Definition: GID.h:105
Gorgon::Graphics::StackedObjectProvider
basic_StackedObjectProvider< RectangularAnimationProvider > StackedObjectProvider
Definition: StackedObject.h:357
Gorgon::Resource::Writer::stream
std::ostream * stream
This is the stream that will be used to write data to.
Definition: Writer.h:403
Gorgon::IO::WriteInt32
void WriteInt32(std::ostream &stream, long value)
Writes a 32-bit integer to the stream.
Definition: Stream.h:197
Gorgon::Resource::Writer::WriteStringWithSize
void WriteStringWithSize(const std::string &value)
Writes a string from a given stream.
Definition: Writer.h:268
Gorgon::Resource::GID::StackedObject
constexpr Type StackedObject
Definition: GID.h:250
Gorgon::Resource::SaveAnimation
void SaveAnimation(Writer &writer, const Graphics::RectangularAnimationProvider &object)
Saves a given generic rectangular animation as resource.
Definition: Resource.cpp:22
Gorgon::Graphics::basic_StackedObjectProvider::SetTop
void SetTop(A_ *value)
Sets the top provider, ownership semantics will not be changed.
Definition: StackedObject.h:225
Gorgon::IO::WriteBool
void WriteBool(std::ostream &stream, bool value)
Writes a boolean value. In resource 1.0, booleans are stored as 32bit integers.
Definition: Stream.h:256
Gorgon::Resource::Writer::Marker::Marker
Marker(Marker &&other)
Definition: Writer.h:67
Reader.h
Gorgon::IO::WritePointf
std::enable_if< std::is_same< F_, float >::value, void >::type WritePointf(std::ostream &stream, Geometry::Pointf p)
Saves the point as two consecutive floats. This function will not work if float type is double.
Definition: Stream.h:321
Gorgon::Resource::Writer::WriteChunkHeader
void WriteChunkHeader(GID::Type type, unsigned long size)
Writes the header of a chunk.
Definition: Writer.h:364
Gorgon::Resource::Writer::WritePointf
void WritePointf(Geometry::Pointf value)
Writes a point to the stream, point takes 2 x 4 bytes.
Definition: Writer.h:251
Gorgon::IO::WriteUInt16
void WriteUInt16(std::ostream &stream, unsigned value)
Writes a 16-bit unsigned integer from the stream.
Definition: Stream.h:218
Gorgon::Resource::StackedObject::SaveThis
static void SaveThis(Writer &writer, const Graphics::IStackedObjectProvider &provider)
Definition: StackedObject.cpp:151
Gorgon::Graphics::basic_StackedObjectProvider::SetBottom
void SetBottom(A_ *value)
Sets the bottom provider, ownership semantics will not be changed.
Definition: StackedObject.h:233
Image.h
Gorgon::IO::WriteEnum32
void WriteEnum32(std::ostream &stream, E_ v)
Writes an enumeration as a 32-bit integer.
Definition: Stream.h:191
Gorgon::Resource::FileWriter
Allows data to be written to a file.
Definition: Writer.h:409
Gorgon::Resource::Writer::Close
void Close()
Definition: Writer.h:108
Gorgon::Resource::Writer::Marker
Definition: Writer.h:63
Gorgon::Graphics::RGBAf
Represents a four channel 32 bit float per channel color information.
Definition: Color.h:373
Gorgon::Resource::GID::Image
constexpr Type Image
Image resource.
Definition: GID.h:149
Gorgon::Resource::Writer::WriteObjectStart
Marker WriteObjectStart(const Base &base)
Writes the start of an object. Should have a matching WriteEnd with the returned marker.
Definition: File.cpp:211
Gorgon::Resource::Writer::open
virtual bool open(bool thrw)=0
This function should open the stream and set stream member.
Gorgon::Filesystem::GetDirectory
std::string GetDirectory(std::string filepath)
Returns the directory portion of a file path.
Definition: Filesystem.h:167
Gorgon::Resource::Writer::WriteChunkSize
void WriteChunkSize(unsigned long value)
Writes chunk size to the stream.
Definition: Writer.h:319
Gorgon::Resource::FileWriter::open
virtual bool open(bool thrw) override
This function should open the stream and set stream member.
Definition: Writer.h:427
Gorgon::Resource::GID::TintedObject
constexpr Type TintedObject
Definition: GID.h:244
Gorgon::Filesystem::Join
std::string Join(std::string path1, const std::string &path2)
Joins two given paths or a path and filename.
Definition: Filesystem.h:154
Gorgon::Resource::Writer::WriteUInt32
void WriteUInt32(unsigned long value)
Writes a 32-bit unsigned integer to the stream.
Definition: Writer.h:158
Gorgon::Graphics::basic_TintedObjectProvider
This object creates a scalable object from a graphic object.
Definition: TintedObject.h:124
Gorgon::Resource::WriteError::number
ErrorType number
The type of loading error occurred.
Definition: Writer.h:48
Gorgon::Resource::Writer::WriteObjectStart
Marker WriteObjectStart(const Base *base, GID::Type type)
Writes the start of an object.
Definition: Writer.h:345
Gorgon::Resource::Writer::WriteGuid
void WriteGuid(const SGuid &value)
Writes a GUID to the given stream.
Definition: Writer.h:311
Gorgon::IO::WriteVector
void WriteVector(std::ostream &stream, const std::vector< T_ > &data)
Writes a vector to the stream.
Definition: Stream.h:302
Gorgon::Graphics::ITintedObjectProvider
For ease of use in resource system.
Definition: TintedObject.h:11
Gorgon::Utils::ASSERT_FALSE
void ASSERT_FALSE(const std::string &message, int skip=1, int depth=4)
Definition: Assert.h:192
Gorgon::Resource::Writer::IsGood
bool IsGood() const
Checks if the stream is open and it can be written to.
Definition: Writer.h:104
Gorgon::IO::WriteRGBA
void WriteRGBA(std::ostream &stream, Graphics::RGBA value)
Writes a RGBA color, R will be saved first.
Definition: Stream.h:261
Gorgon::Graphics::basic_StackedObjectProvider::GetTop
A_ * GetTop() const
Returns the top component. Could return nullptr.
Definition: StackedObject.h:215
Gorgon::Resource::TintedObject
This is a tinted object resource.
Definition: TintedObject.h:16
Gorgon::Resource::Writer::Marker::operator=
Marker & operator=(Marker &&other)
Definition: Writer.h:72
Null.h
Gorgon::Graphics::basic_StackedObjectProvider::GetBottom
A_ * GetBottom() const
Returns the bottom component. Could return nullptr.
Definition: StackedObject.h:220
Gorgon::Resource::Writer::Marker::Marker
Marker(const Marker &)=delete
Gorgon::Resource::Writer::~Writer
virtual ~Writer()
Any writer implementation should close and set the stream to nullptr in destructor.
Definition: Writer.h:91
Gorgon
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
Gorgon::Geometry::basic_Size
This class represents a 2D geometric size.
Definition: Size.h:23
Gorgon::Resource::GID::TintedObject_Props
constexpr Type TintedObject_Props
Definition: GID.h:245
Gorgon::Resource::GID::StackedObject_Props
constexpr Type StackedObject_Props
Definition: GID.h:251
Gorgon::Resource::WriteError::ErrorStrings
static const std::string ErrorStrings[3]
Strings for error codes.
Definition: Writer.h:51
Gorgon::Resource::Writer::WriteChunkStart
Marker WriteChunkStart(GID::Type type)
Writes the start of a chunk. Should have a matching WriteEnd.
Definition: Writer.h:351
Gorgon::IO::WriteUInt32
void WriteUInt32(std::ostream &stream, unsigned long value)
Writes a 32-bit unsigned integer from the stream.
Definition: Stream.h:204
Gorgon::Resource::StackedObject
This is a stacked object resource.
Definition: StackedObject.h:15
Gorgon::Resource::TintedObject::MoveOutProvider
ITintedObjectProvider & MoveOutProvider() override
This function moves this animation provider into a new provider.
Definition: TintedObject.cpp:204
Gorgon::Resource::WriteError::WriteError
WriteError(ErrorType number=Unknown)
Regular constructor, creates error text to error number.
Definition: Writer.h:38
Gorgon::Resource::FileWriter::FileWriter
FileWriter(const std::string &filename)
Constructs a new object with the given filename.
Definition: Writer.h:412
ASSERT
#define ASSERT(expression, message,...)
Replaces regular assert to allow messages and backtrace.
Definition: Assert.h:161
Gorgon::Containers::Collection
Collection is a container for reference typed objects.
Definition: Collection.h:21
Gorgon::Resource::File
This class represents a logical resource file.
Definition: File.h:53
Gorgon::Resource::Writer::WriteArray
void WriteArray(const T_ *data, unsigned long size)
Writes an array to the file.
Definition: Writer.h:288
Gorgon::Graphics::Bitmap
This object contains an bitmap image.
Definition: Bitmap.h:25
Gorgon::Resource::GID::Animation
constexpr Type Animation
Definition: GID.h:187
Gorgon::Resource::Base
This class is the base for all Gorgon Resources.
Definition: Base.h:20
Gorgon::Graphics::IStackedObjectProvider
For ease of use in resource system.
Definition: StackedObject.h:10
Gorgon::IO::WriteUInt8
void WriteUInt8(std::ostream &stream, Byte value)
Writes an 8-bit unsigned integer from the stream.
Definition: Stream.h:231
Gorgon::Resource::WriteError::Unknown
@ Unknown
The cause of the error cannot be determined.
Definition: Writer.h:26
Gorgon::Graphics::TintedBitmapAnimationProvider
basic_TintedObjectProvider< BitmapAnimationProvider > TintedBitmapAnimationProvider
Definition: TintedObject.h:280
Gorgon::Resource::Writer::WriteSize
void WriteSize(Geometry::Size value)
Writes a size to the stream, size takes 2 x 4 bytes.
Definition: Writer.h:259
Gorgon::Resource::Writer::WriteRGBA
void WriteRGBA(Graphics::RGBA value)
Writes a RGBA color, R will be saved first. RGBA takes 4 x 1 bytes.
Definition: Writer.h:228
Gorgon::Containers::Collection::GetCount
long GetCount() const
Returns number of elements.
Definition: Collection.h:236
Gorgon::IO::WriteSize
void WriteSize(std::ostream &stream, Geometry::Size s)
Saves the size as two consecutive 32bit integers.
Definition: Stream.h:327
Gorgon::Geometry::basic_Point
This class represents a 2D point.
Definition: Point.h:32
Gorgon::Resource::Writer
This class allows resource objects to save their data to a stream.
Definition: Writer.h:59
TintedObject.h
Gorgon::Graphics::TintedObjectProvider
basic_TintedObjectProvider< RectangularAnimationProvider > TintedObjectProvider
Definition: TintedObject.h:277
Gorgon::Resource::TintedObject::TintedObject
TintedObject()
Creates a new empty tinted object.
Definition: TintedObject.h:43
Gorgon::Resource::Writer::WriteUInt16
void WriteUInt16(unsigned value)
Writes a 16-bit unsigned integer to the stream.
Definition: Writer.h:176
Gorgon::Resource::StackedObject::save
void save(Writer &writer) const override
Definition: StackedObject.cpp:132
Gorgon::Byte
unsigned char Byte
Represents smallest cell in memory.
Definition: Types.h:9
Gorgon::Resource::Writer::WriteEnd
void WriteEnd(Marker &marker)
This function performs writes necessary to end a chunk that is represented by the marker.
Definition: Writer.h:373
Gorgon::Graphics::basic_TintedObjectProvider::GetColor
RGBAf GetColor() const override
Returns the tint color.
Definition: TintedObject.h:183
Gorgon::Resource::TintedObject::animmoveout
virtual Graphics::RectangularAnimationStorage animmoveout() override
Definition: TintedObject.cpp:200
Gorgon::Graphics::basic_StackedObjectProvider::GetOffset
Geometry::Point GetOffset() const override
Returns the offset of the top image.
Definition: StackedObject.h:241
Gorgon::IO::WriteInt8
void WriteInt8(std::ostream &stream, char value)
Writes an 8-bit integer from the stream.
Definition: Stream.h:225
Gorgon::Graphics::RectangularAnimationStorage
Gorgon::Animation::basic_Storage< RectangularAnimationProvider > RectangularAnimationStorage
Definition: Animations.h:374
Gorgon::Resource::Writer::WriteInt16
void WriteInt16(int value)
Writes a 16-bit integer to the stream.
Definition: Writer.h:167
Gorgon::Resource::TintedObject::SaveThis
static void SaveThis(Writer &writer, const Graphics::ITintedObjectProvider &provider)
Definition: TintedObject.cpp:147
Gorgon::Graphics::basic_TintedObjectProvider::GetBase
A_ * GetBase() const
Returns the base component. Could return nullptr.
Definition: TintedObject.h:178
Gorgon::Resource::Writer::Seek
void Seek(unsigned long pos)
Seeks to the given position.
Definition: Writer.h:122
Gorgon::Resource::WriteError::NoData
@ NoData
There is no data to save.
Definition: Writer.h:33
Gorgon::Graphics::basic_TintedObjectProvider::SetBase
void SetBase(A_ *value)
Sets the base provider, ownership semantics will not be changed.
Definition: TintedObject.h:193
Gorgon::Resource::Writer::WriteInt32
void WriteInt32(long value)
Writes a 32-bit integer to the stream.
Definition: Writer.h:149
Gorgon::Resource::Writer::close
virtual void close()=0
This function should close the stream.
Gorgon::Resource::Writer::WriteBool
void WriteBool(bool value)
Writes a boolean value. In resource 1.0, booleans are stored as 32bit integers.
Definition: Writer.h:220
Gorgon::Resource::FileWriter::close
virtual void close() override
This function should close the stream.
Definition: Writer.h:423
Gorgon::IO::WriteDouble
void WriteDouble(std::ostream &stream, double value)
Writes a 64 bit IEEE double precision floating point number from the stream.
Definition: Stream.h:247
Gorgon::Resource::WriteError::ErrorType
ErrorType
Error types.
Definition: Writer.h:23
Gorgon::Resource::GID::Type
Type to store GID information.
Definition: GID.h:23
Gorgon::SGuid
This class represents a short globally unique identifier.
Definition: SGuid.h:22
Gorgon::Resource::Base::children
Containers::Collection< Base > children
Child objects that this resource object have.
Definition: Base.h:162
Gorgon::Resource::Writer::WriteEnum32
void WriteEnum32(E_ value)
Writes an enumeration as 32-bit integer to the stream.
Definition: Writer.h:140
Gorgon::Resource::StackedObject::MoveOutProvider
IStackedObjectProvider & MoveOutProvider() override
This function moves this animation provider into a new provider.
Definition: StackedObject.cpp:211
Gorgon::Resource::WriteError::CannotOpenFile
@ CannotOpenFile
The given file cannot be opened, probably its path does not exists or the operation is denied.
Definition: Writer.h:30
Gorgon::Graphics::StackedBitmapAnimationProvider
basic_StackedObjectProvider< BitmapAnimationProvider > StackedBitmapAnimationProvider
Definition: StackedObject.h:360
Gorgon::Resource::Writer::WriteDouble
void WriteDouble(double value)
Writes a 64 bit IEEE double precision floating point number to the file.
Definition: Writer.h:212
Gorgon::Filesystem::Canonical
std::string Canonical(const std::string &path)
Canonicalizes a given relative path.
Definition: Linux.cpp:94
Gorgon::Resource::Writer::WriteUInt8
void WriteUInt8(Byte value)
Writes an 8-bit unsigned integer to the stream.
Definition: Writer.h:194
Gorgon::Resource::Writer::WriteGID
void WriteGID(GID::Type value)
Writes a GID to the given stream.
Definition: Writer.h:303
Gorgon::IO::WritePoint
void WritePoint(std::ostream &stream, Geometry::Point p)
Saves the point as two consecutive 32bit integers.
Definition: Stream.h:313
Gorgon::IO::WriteGuid
void WriteGuid(std::ostream &stream, const SGuid &value)
Writes a GUID from the given stream.
Definition: Stream.h:308
StackedObject.h
Gorgon::Resource::StackedObject::LoadResource
static StackedObject * LoadResource(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long size)
This function loads a stacked object resource from the file.
Definition: StackedObject.cpp:36
Gorgon::IO::WriteFloat
void WriteFloat(std::ostream &stream, float value)
Writes a 32 bit IEEE floating point number from the stream.
Definition: Stream.h:237
Animation.h
Gorgon::Resource::StackedObject::animmoveout
virtual Graphics::RectangularAnimationStorage animmoveout() override
Definition: StackedObject.cpp:207
Gorgon::Resource::Writer::Tell
unsigned long Tell() const
Tells the current position.
Definition: Writer.h:114
Gorgon::Resource::StackedObject::StackedObject
StackedObject()
Creates a new empty stacked object.
Definition: StackedObject.h:42
Gorgon::Resource::Writer::WriteFloat
void WriteFloat(float value)
Writes a 32 bit IEEE floating point number to the file.
Definition: Writer.h:203
Gorgon::Resource::Writer::WriteInt8
void WriteInt8(char value)
Writes an 8-bit integer to the stream.
Definition: Writer.h:185
Gorgon::IO::WriteString
void WriteString(std::ostream &stream, const std::string &value)
Writes a string without its size.
Definition: Stream.h:285
Gorgon::Resource::Writer::WritePoint
void WritePoint(Geometry::Point value)
Writes a point to the stream, point takes 2 x 4 bytes.
Definition: Writer.h:244
Gorgon::IO::WriteStringWithSize
void WriteStringWithSize(std::ostream &stream, const std::string &value)
Writes a string from a given stream.
Definition: Stream.h:278
Gorgon::IO::WriteRGBAf
void WriteRGBAf(std::ostream &stream, Graphics::RGBAf value)
Writes a RGBAf color, R will be saved first.
Definition: Stream.h:269
Gorgon::Resource::Writer::WriteVector
void WriteVector(const std::vector< T_ > &data)
Writes a vector to the stream.
Definition: Writer.h:298
Gorgon::Resource::TintedObject::LoadResource
static TintedObject * LoadResource(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long size)
This function loads a tinted object resource from the file.
Definition: TintedObject.cpp:35