Gorgon Game Engine
DataItems.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Base.h"
4 #include "Reader.h"
5 #include "../Geometry/Point.h"
6 #include "../Geometry/Size.h"
7 #include "../Geometry/Rectangle.h"
8 #include "../Geometry/Bounds.h"
9 #include "../Geometry/Margin.h"
10 
11 #include <functional>
12 
13 namespace Gorgon { namespace Resource {
14 
15  class File;
16 
17  class DataItem {
18  public:
19 
20  using LoaderFn=std::function<DataItem *(std::weak_ptr<File> file, std::shared_ptr<Reader> reader, unsigned long totalsize)>;
21 
22  virtual ~DataItem() {}
23 
25  virtual GID::Type GetGID() const = 0;
26 
28  std::string Name;
29 
31  virtual void Save(Writer &writer) const {
32  auto start=writer.WriteChunkStart(GetGID());
33  writer.WriteStringWithSize(Name);
34  SaveValue(writer);
35  writer.WriteEnd(start);
36  }
37 
39  template <class T_>
40  T_ Get() const {
41  static_assert(std::is_same<T_, int>::value, "Unknown data type.");
42  }
43 
44  template <class T_>
45  T_ &GetObject() const;
46 
48  virtual std::string ToString() const = 0;
49 
52  virtual void SaveValue(Writer &writer) const = 0;
53 
55  static void InitializeLoaders();
56 
58  static std::map<GID::Type, LoaderFn> DataLoaders;
59  };
60 
61  namespace internal {
62  template<class T_>
63  class DataImp {
64  public:
65  DataImp() = default;
66 
67  DataImp(T_ v) : value(v) {}
68 
69  T_ Get() const { return value; }
70 
71  void Set(T_ val) { value = val; }
72 
73  protected:
74  T_ value = T_();
75  };
76  }
77 
78  class IntegerData : public DataItem, private internal::DataImp<int> {
79  public:
81 
82  IntegerData(int v) : DataImp<int>(v) {}
83 
84  IntegerData(const std::string &name, int v) : DataImp<int>(v) {
85  Name=name;
86  }
87 
88  virtual GID::Type GetGID() const override { return GID::Data_Int; }
89 
92 
93  virtual void SaveValue(Writer &writer) const override {
94  writer.WriteInt32(value);
95  }
96 
97  static DataItem *Load(std::weak_ptr<File> file, std::shared_ptr<Reader> reader, unsigned long totalsize);
98 
99  virtual std::string ToString() const override {
100  return String::From(value);
101  }
102  };
103 
104  class FloatData : public DataItem, private internal::DataImp<float> {
105  public:
107 
108  FloatData(float v) : DataImp<float>(v) {}
109 
110  FloatData(const std::string &name, float v) : DataImp<float>(v) {
111  Name=name;
112  }
113 
114  virtual GID::Type GetGID() const override { return GID::Data_Float; }
115 
118 
119  virtual void SaveValue(Writer &writer) const override {
120  writer.WriteFloat(value);
121  }
122 
123  static DataItem *Load(std::weak_ptr<File> file, std::shared_ptr<Reader> reader, unsigned long totalsize);
124 
125  virtual std::string ToString() const override {
126  return String::From(value);
127  }
128  };
129 
130  class TextData : public DataItem, private internal::DataImp<std::string> {
131  public:
132  TextData() {}
133 
134  TextData(std::string v) : DataImp<std::string>(v) {}
135 
136  TextData(const std::string &name, const std::string &v) : DataImp<std::string>(v) {
137  Name=name;
138  }
139 
140  virtual GID::Type GetGID() const override { return GID::Data_Text; }
141 
144 
145  virtual void SaveValue(Writer &writer) const override {
146  writer.WriteStringWithSize(value);
147  }
148 
149  static DataItem *Load(std::weak_ptr<File> file, std::shared_ptr<Reader> reader, unsigned long totalsize);
150 
151  virtual std::string ToString() const override {
152  return value;
153  }
154  };
155 
156  class PointData : public DataItem, private internal::DataImp<Geometry::Point> {
157  public:
159 
160  PointData(Geometry::Point v) : DataImp<Geometry::Point>(v) {}
161 
162  PointData(const std::string &name, Geometry::Point v) : DataImp<Geometry::Point>(v) {
163  Name=name;
164  }
165 
166  virtual GID::Type GetGID() const override { return GID::Data_Point; }
167 
170 
171  virtual void SaveValue(Writer &writer) const override {
172  writer.WriteInt32(value.X);
173  writer.WriteInt32(value.Y);
174  }
175 
176  static DataItem *Load(std::weak_ptr<File> file, std::shared_ptr<Reader> reader, unsigned long totalsize);
177 
178  virtual std::string ToString() const override {
179  return String::From(value);
180  }
181  };
182 
183  class PointfData : public DataItem, private internal::DataImp<Geometry::Pointf> {
184  public:
186 
188 
189  PointfData(const std::string &name, Geometry::Pointf v) : DataImp<Geometry::Pointf>(v) {
190  Name=name;
191  }
192 
193  virtual GID::Type GetGID() const override { return GID::Data_Pointf; }
194 
197 
198  virtual void SaveValue(Writer &writer) const override {
199  writer.WriteFloat(value.X);
200  writer.WriteFloat(value.Y);
201  }
202 
203  static DataItem *Load(std::weak_ptr<File> file, std::shared_ptr<Reader> reader, unsigned long totalsize);
204 
205  virtual std::string ToString() const override {
206  return String::From(value);
207  }
208  };
209 
210  class SizeData : public DataItem, private internal::DataImp<Geometry::Size> {
211  public:
212  SizeData() {}
213 
214  SizeData(Geometry::Size v) : DataImp<Geometry::Size>(v) {}
215 
216  SizeData(const std::string &name, Geometry::Size v) : DataImp<Geometry::Size>(v) {
217  Name=name;
218  }
219 
220  virtual GID::Type GetGID() const override { return GID::Data_Size; }
221 
224 
225  virtual void SaveValue(Writer &writer) const override {
226  writer.WriteInt32(value.Width);
227  writer.WriteInt32(value.Height);
228  }
229 
230  static DataItem *Load(std::weak_ptr<File> file, std::shared_ptr<Reader> reader, unsigned long totalsize);
231 
232  virtual std::string ToString() const override {
233  return String::From(value);
234  }
235  };
236 
237  class RectangleData : public DataItem, private internal::DataImp<Geometry::Rectangle> {
238  public:
240 
242 
243  RectangleData(const std::string &name, Geometry::Rectangle v) : DataImp<Geometry::Rectangle>(v) {
244  Name=name;
245  }
246 
247  virtual GID::Type GetGID() const override { return GID::Data_Rectangle; }
248 
251 
252  virtual void SaveValue(Writer &writer) const override {
253  writer.WriteInt32(value.X);
254  writer.WriteInt32(value.Y);
255  writer.WriteInt32(value.Width);
256  writer.WriteInt32(value.Height);
257  }
258 
259  static DataItem *Load(std::weak_ptr<File> file, std::shared_ptr<Reader> reader, unsigned long totalsize);
260 
261  virtual std::string ToString() const override {
262  return String::From(value);
263  }
264  };
265 
266  class BoundsData : public DataItem, private internal::DataImp<Geometry::Bounds> {
267  public:
269 
271 
272  BoundsData(const std::string &name, Geometry::Bounds v) : DataImp<Geometry::Bounds>(v) {
273  Name=name;
274  }
275 
276  virtual GID::Type GetGID() const override { return GID::Data_Bounds; }
277 
280 
281  virtual void SaveValue(Writer &writer) const override {
282  writer.WriteInt32(value.Left);
283  writer.WriteInt32(value.Top);
284  writer.WriteInt32(value.Right);
285  writer.WriteInt32(value.Bottom);
286  }
287 
288  static DataItem *Load(std::weak_ptr<File> file, std::shared_ptr<Reader> reader, unsigned long totalsize);
289 
290  virtual std::string ToString() const override {
291  return String::From(value);
292  }
293  };
294 
295  class MarginData : public DataItem, private internal::DataImp<Geometry::Margin> {
296  public:
298 
300 
301  MarginData(const std::string &name, Geometry::Margin v) : DataImp<Geometry::Margin>(v) {
302  Name=name;
303  }
304 
305  virtual GID::Type GetGID() const override { return GID::Data_Margin; }
306 
309 
310  virtual void SaveValue(Writer &writer) const override {
311  writer.WriteInt32(value.Left);
312  writer.WriteInt32(value.Top);
313  writer.WriteInt32(value.Right);
314  writer.WriteInt32(value.Bottom);
315  }
316 
317  static DataItem *Load(std::weak_ptr<File> file, std::shared_ptr<Reader> reader, unsigned long totalsize);
318 
319  virtual std::string ToString() const override {
320  return String::From(value);
321  }
322  };
323 
324  class ObjectData : public DataItem {
325  public:
327 
328  ObjectData(Base &v) : value(&v) {}
329 
330  ObjectData(const std::string &name, Base &v) : value(&v) {
331  Name=name;
332  }
333 
334  ObjectData(Base *v) : value(v) {}
335 
336  ObjectData(const std::string &name, Base *v) : value(v) {
337  Name=name;
338  }
339 
340  virtual ~ObjectData() {
341  if(value)
342  value->DeleteResource();
343  }
344 
345  virtual GID::Type GetGID() const override { return GID::Data_Object; }
346 
347  virtual void SaveValue(Writer &writer) const override {
348  if(value) {
349  value->Save(writer);
350  }
351  }
352 
354  void Set(Base &v) {
355  if(value && value!=&v)
356  value->DeleteResource();
357 
358  value=&v;
359  }
360 
362  void Set(Base *v) {
363  if(value && value!=v)
364  value->DeleteResource();
365 
366  value=v;
367  }
368 
370  void Unset() {
371  if(value)
372  value->DeleteResource();
373 
374  value=nullptr;
375  }
376 
379  auto temp=value;
380  value=nullptr;
381 
382  return *temp;
383  }
384 
385  bool IsSet() const {
386  return value!=nullptr;
387  }
388 
390  template<class T_>
391  T_ &Get() const {
392  if(!value)
393  throw std::runtime_error("This data does not contain any object.");
394 
395  return dynamic_cast<T_ &>(*value);
396  }
397 
398  static DataItem *Load(std::weak_ptr<File> file, std::shared_ptr<Reader> reader, unsigned long totalsize);
399 
400  virtual std::string ToString() const override {
401  if(value)
402  return value->GetName();
403  else
404  return "[Empty]";
405  }
406 
407  private:
408  Base *value = nullptr;
409  };
410 
411  inline std::ostream &operator <<(std::ostream &out, const DataItem &item) {
412  out<<item.ToString();
413 
414  return out;
415  }
416 
417 
418  template<>
419  inline int DataItem::Get<int>() const {
420  auto &item=dynamic_cast<const IntegerData&>(*this);
421 
422  return item.Get();
423  }
424 
425  template<>
426  inline float DataItem::Get<float>() const {
427  auto &item=dynamic_cast<const FloatData&>(*this);
428 
429  return item.Get();
430  }
431 
432  template<>
433  inline std::string DataItem::Get<std::string>() const {
434  auto &item=dynamic_cast<const TextData&>(*this);
435 
436  return item.Get();
437  }
438 
439  template<>
440  inline Geometry::Point DataItem::Get<Geometry::Point>() const {
441  auto &item=dynamic_cast<const PointData&>(*this);
442 
443  return item.Get();
444  }
445 
446  template<>
447  inline Geometry::Pointf DataItem::Get<Geometry::Pointf>() const {
448  auto &item=dynamic_cast<const PointfData&>(*this);
449 
450  return item.Get();
451  }
452 
453  template<>
454  inline Geometry::Size DataItem::Get<Geometry::Size>() const {
455  auto &item=dynamic_cast<const SizeData&>(*this);
456 
457  return item.Get();
458  }
459 
460  template<>
461  inline Geometry::Rectangle DataItem::Get<Geometry::Rectangle>() const {
462  auto &item=dynamic_cast<const RectangleData&>(*this);
463 
464  return item.Get();
465  }
466 
467  template<>
468  inline Geometry::Bounds DataItem::Get<Geometry::Bounds>() const {
469  auto &item=dynamic_cast<const BoundsData&>(*this);
470 
471  return item.Get();
472  }
473 
474  template<>
475  inline Geometry::Margin DataItem::Get<Geometry::Margin>() const {
476  auto &item=dynamic_cast<const MarginData&>(*this);
477 
478  return item.Get();
479  }
480 
481  template <class T_>
482  T_ &DataItem::GetObject() const {
483  auto &item=dynamic_cast<const ObjectData&>(*this);
484 
485  return item.Get<T_>();
486  }
487 } }
Gorgon::Resource::operator<<
std::ostream & operator<<(std::ostream &out, const DataItem &item)
Definition: DataItems.h:411
Gorgon::Resource::Base::DeleteResource
bool DeleteResource()
Safely deletes the resource.
Definition: Base.cpp:34
Gorgon::Resource::PointfData
Definition: DataItems.h:183
Gorgon::Geometry::basic_Bounds
This class represents boundaries of 2D objects.
Definition: Bounds.h:27
Gorgon::Resource::BoundsData::BoundsData
BoundsData(Geometry::Bounds v)
Definition: DataItems.h:270
Gorgon::Resource::IntegerData::IntegerData
IntegerData(int v)
Definition: DataItems.h:82
Gorgon::Resource::RectangleData::RectangleData
RectangleData(const std::string &name, Geometry::Rectangle v)
Definition: DataItems.h:243
Gorgon::Resource::PointfData::GetGID
virtual GID::Type GetGID() const override
Returns the Gorgon ID of this data object.
Definition: DataItems.h:193
Gorgon::Resource::FloatData::FloatData
FloatData(const std::string &name, float v)
Definition: DataItems.h:110
Gorgon::Resource::GID::File
constexpr Type File
File.
Definition: GID.h:84
Gorgon::String::From
std::enable_if< decltype(gorgon__enum_tr_loc(T_()))::isupgradedenum, std::string >::type From(const T_ &e)
Definition: Enum.h:303
Gorgon::Resource::FloatData::SaveValue
virtual void SaveValue(Writer &writer) const override
Saves only the value of the data item to gorgon file.
Definition: DataItems.h:119
Gorgon::Resource::internal::DataImp::DataImp
DataImp()=default
Gorgon::Resource::DataItem::LoaderFn
std::function< DataItem *(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long totalsize)> LoaderFn
Definition: DataItems.h:20
Gorgon::Resource::ObjectData::ObjectData
ObjectData(const std::string &name, Base *v)
Definition: DataItems.h:336
File.h
Gorgon::Geometry::basic_Margin::Left
T_ Left
Left margin.
Definition: Margin.h:167
Gorgon::Resource::MarginData::MarginData
MarginData(const std::string &name, Geometry::Margin v)
Definition: DataItems.h:301
Gorgon::Resource::FloatData::GetGID
virtual GID::Type GetGID() const override
Returns the Gorgon ID of this data object.
Definition: DataItems.h:114
Gorgon::Resource::ObjectData::IsSet
bool IsSet() const
Definition: DataItems.h:385
Gorgon::Resource::PointData::GetGID
virtual GID::Type GetGID() const override
Returns the Gorgon ID of this data object.
Definition: DataItems.h:166
Gorgon::Resource::Writer::WriteStringWithSize
void WriteStringWithSize(const std::string &value)
Writes a string from a given stream.
Definition: Writer.h:268
Gorgon::Resource::BoundsData::BoundsData
BoundsData()
Definition: DataItems.h:268
Gorgon::Resource::ObjectData::Release
Base & Release()
Removes the object from this data without destroying it.
Definition: DataItems.h:378
Gorgon::Resource::GID::Data_Rectangle
constexpr Type Data_Rectangle
Definition: GID.h:174
Gorgon::Resource::MarginData::ToString
virtual std::string ToString() const override
Converts the contents of this data to string.
Definition: DataItems.h:319
Gorgon::Resource::SizeData::SizeData
SizeData(const std::string &name, Geometry::Size v)
Definition: DataItems.h:216
Base.h
Gorgon::Resource::FloatData
Definition: DataItems.h:104
Gorgon::Resource::ObjectData::ObjectData
ObjectData(Base &v)
Definition: DataItems.h:328
Gorgon::Resource::PointData::ToString
virtual std::string ToString() const override
Converts the contents of this data to string.
Definition: DataItems.h:178
Gorgon::Resource::TextData::SaveValue
virtual void SaveValue(Writer &writer) const override
Saves only the value of the data item to gorgon file.
Definition: DataItems.h:145
Gorgon::Geometry::basic_Point::X
T_ X
X coordinate.
Definition: Point.h:368
Gorgon::Resource::TextData::Load
static DataItem * Load(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long totalsize)
Definition: DataItems.cpp:50
Gorgon::Resource::SizeData::GetGID
virtual GID::Type GetGID() const override
Returns the Gorgon ID of this data object.
Definition: DataItems.h:220
Gorgon::Resource::SizeData::SaveValue
virtual void SaveValue(Writer &writer) const override
Saves only the value of the data item to gorgon file.
Definition: DataItems.h:225
Gorgon::Resource::PointData::PointData
PointData(Geometry::Point v)
Definition: DataItems.h:160
Reader.h
Gorgon::Geometry::basic_Rectangle::X
T_ X
X coordinate of the top left corner of this rectangle.
Definition: Rectangle.h:354
Gorgon::Resource::SizeData::SizeData
SizeData()
Definition: DataItems.h:212
Gorgon::Resource::FloatData::FloatData
FloatData(float v)
Definition: DataItems.h:108
Gorgon::Geometry::basic_Size::Height
T_ Height
Height of this size object.
Definition: Size.h:261
Gorgon::Resource::RectangleData
Definition: DataItems.h:237
Gorgon::Resource::DataItem::GetGID
virtual GID::Type GetGID() const =0
Returns the Gorgon ID of this data object.
Gorgon::Resource::SizeData::ToString
virtual std::string ToString() const override
Converts the contents of this data to string.
Definition: DataItems.h:232
Gorgon::Resource::GID::Data_Pointf
constexpr Type Data_Pointf
Definition: GID.h:173
Gorgon::Resource::GID::Data_Margin
constexpr Type Data_Margin
Definition: GID.h:180
Gorgon::Resource::internal::DataImp::Get
T_ Get() const
Definition: DataItems.h:69
Gorgon::Resource::DataItem
Definition: DataItems.h:17
Gorgon::Resource::IntegerData::GetGID
virtual GID::Type GetGID() const override
Returns the Gorgon ID of this data object.
Definition: DataItems.h:88
Gorgon::Resource::GID::Data_Point
constexpr Type Data_Point
Definition: GID.h:172
Gorgon::Resource::ObjectData::GetGID
virtual GID::Type GetGID() const override
Returns the Gorgon ID of this data object.
Definition: DataItems.h:345
Gorgon::Resource::internal::DataImp::DataImp
DataImp(T_ v)
Definition: DataItems.h:67
Gorgon::Geometry::basic_Rectangle::Width
T_ Width
Width of the rectangle.
Definition: Rectangle.h:360
Gorgon::Resource::ObjectData::Set
void Set(Base &v)
Changes the object that this data holds. Once set, the data owns the object.
Definition: DataItems.h:354
Gorgon::Resource::IntegerData::IntegerData
IntegerData(const std::string &name, int v)
Definition: DataItems.h:84
Gorgon::Resource::TextData::ToString
virtual std::string ToString() const override
Converts the contents of this data to string.
Definition: DataItems.h:151
Gorgon::Resource::DataItem::Name
std::string Name
The name of the data item.
Definition: DataItems.h:28
Gorgon::Geometry::Size
basic_Size< int > Size
Definition: Size.h:385
Gorgon::Resource::IntegerData::ToString
virtual std::string ToString() const override
Converts the contents of this data to string.
Definition: DataItems.h:99
Gorgon::Resource::DataItem::InitializeLoaders
static void InitializeLoaders()
This function will initialize data loaders.
Definition: DataItems.cpp:9
Gorgon::Resource::TextData
Definition: DataItems.h:130
Gorgon::Geometry::basic_Bounds::Left
T_ Left
Left-most boundary.
Definition: Bounds.h:399
Gorgon::Resource::RectangleData::ToString
virtual std::string ToString() const override
Converts the contents of this data to string.
Definition: DataItems.h:261
Gorgon::Resource::ObjectData::~ObjectData
virtual ~ObjectData()
Definition: DataItems.h:340
Gorgon::Geometry::basic_Margin::Top
T_ Top
Top margin.
Definition: Margin.h:170
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::Geometry::Margin
basic_Margin< int > Margin
Definition: Margin.h:289
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::Resource::DataItem::ToString
virtual std::string ToString() const =0
Converts the contents of this data to string.
Gorgon::Resource::DataItem::GetObject
T_ & GetObject() const
Definition: DataItems.h:482
Gorgon::Resource::Base::Save
void Save(Writer &writer)
Saves this object into the given writer. The writer should be open prior to this call.
Definition: Base.cpp:57
Gorgon::Resource::ObjectData
Definition: DataItems.h:324
Gorgon::Resource::PointData::Load
static DataItem * Load(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long totalsize)
Definition: DataItems.cpp:63
Gorgon::Resource::ObjectData::Get
T_ & Get() const
Returns the item contained within this object.
Definition: DataItems.h:391
Gorgon::Resource::GID::Data_Text
constexpr Type Data_Text
Definition: GID.h:169
Gorgon::Resource::PointfData::Load
static DataItem * Load(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long totalsize)
Definition: DataItems.cpp:79
ASSERT
#define ASSERT(expression, message,...)
Replaces regular assert to allow messages and backtrace.
Definition: Assert.h:161
Gorgon::Geometry::Point
basic_Point< int > Point
Definition: Point.h:598
Gorgon::Resource::PointData::SaveValue
virtual void SaveValue(Writer &writer) const override
Saves only the value of the data item to gorgon file.
Definition: DataItems.h:171
Gorgon::Resource::DataItem::DataLoaders
static std::map< GID::Type, LoaderFn > DataLoaders
Data loaders that all data containing classes would use to load their children.
Definition: DataItems.h:58
Gorgon::Resource::FloatData::FloatData
FloatData()
Definition: DataItems.h:106
Gorgon::Resource::PointfData::PointfData
PointfData(Geometry::Pointf v)
Definition: DataItems.h:187
Gorgon::Resource::ObjectData::Set
void Set(Base *v)
Changes the object that this data holds. Once set, the data owns the object.
Definition: DataItems.h:362
Gorgon::Resource::PointfData::ToString
virtual std::string ToString() const override
Converts the contents of this data to string.
Definition: DataItems.h:205
Gorgon::Resource::internal::DataImp
Definition: DataItems.h:63
Gorgon::Resource::TextData::GetGID
virtual GID::Type GetGID() const override
Returns the Gorgon ID of this data object.
Definition: DataItems.h:140
Gorgon::Resource::SizeData::SizeData
SizeData(Geometry::Size v)
Definition: DataItems.h:214
Gorgon::Resource::MarginData::SaveValue
virtual void SaveValue(Writer &writer) const override
Saves only the value of the data item to gorgon file.
Definition: DataItems.h:310
Gorgon::Resource::BoundsData::GetGID
virtual GID::Type GetGID() const override
Returns the Gorgon ID of this data object.
Definition: DataItems.h:276
Gorgon::Resource::Base
This class is the base for all Gorgon Resources.
Definition: Base.h:20
Gorgon::Resource::internal::DataImp::Set
void Set(T_ val)
Definition: DataItems.h:71
Gorgon::Resource::PointfData::PointfData
PointfData()
Definition: DataItems.h:185
Gorgon::Resource::IntegerData
Definition: DataItems.h:78
Gorgon::Resource::SizeData
Definition: DataItems.h:210
Gorgon::Resource::PointData::PointData
PointData()
Definition: DataItems.h:158
Gorgon::Resource::ObjectData::Unset
void Unset()
Removes the object that this data holds.
Definition: DataItems.h:370
Gorgon::Geometry::Pointf
basic_Point< Float > Pointf
Definition: Point.h:601
Gorgon::Resource::IntegerData::Load
static DataItem * Load(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long totalsize)
Definition: DataItems.cpp:22
Gorgon::Geometry::Bounds
basic_Bounds< int > Bounds
Definition: Bounds.h:722
Gorgon::Resource::MarginData
Definition: DataItems.h:295
Gorgon::Resource::BoundsData::ToString
virtual std::string ToString() const override
Converts the contents of this data to string.
Definition: DataItems.h:290
Gorgon::Geometry::basic_Margin::Bottom
T_ Bottom
Bottom margin.
Definition: Margin.h:176
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
Gorgon::Resource::ObjectData::ObjectData
ObjectData()
Definition: DataItems.h:326
Gorgon::Resource::GID::Data_Int
constexpr Type Data_Int
Definition: GID.h:170
Gorgon::Resource::Rectangle
Definition: Rectangle.h:11
Gorgon::Resource::BoundsData::Load
static DataItem * Load(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long totalsize)
Definition: DataItems.cpp:129
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::Resource::TextData::TextData
TextData(const std::string &name, const std::string &v)
Definition: DataItems.h:136
Gorgon::Geometry::basic_Rectangle::Y
T_ Y
Y coordinate of the top left corner of this rectangle.
Definition: Rectangle.h:357
Gorgon::Resource::FloatData::Load
static DataItem * Load(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long totalsize)
Definition: DataItems.cpp:36
Gorgon::Resource::internal::DataImp< int >::value
int value
Definition: DataItems.h:74
Gorgon::Resource::GID::Data_Bounds
constexpr Type Data_Bounds
Definition: GID.h:179
Gorgon::Geometry::basic_Bounds::Right
T_ Right
Right-most boundary.
Definition: Bounds.h:405
Gorgon::Geometry::basic_Margin::Right
T_ Right
Right margin.
Definition: Margin.h:173
Gorgon::Resource::MarginData::Load
static DataItem * Load(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long totalsize)
Definition: DataItems.cpp:147
Gorgon::Resource::PointData
Definition: DataItems.h:156
Gorgon::Geometry::basic_Rectangle::Height
T_ Height
Height of the rectangle.
Definition: Rectangle.h:363
Gorgon::Resource::DataItem::~DataItem
virtual ~DataItem()
Definition: DataItems.h:22
Gorgon::Resource::ObjectData::ObjectData
ObjectData(Base *v)
Definition: DataItems.h:334
Gorgon::Geometry::basic_Bounds::Bottom
T_ Bottom
Bottom-most boundary.
Definition: Bounds.h:408
Gorgon::Resource::MarginData::MarginData
MarginData(Geometry::Margin v)
Definition: DataItems.h:299
Gorgon::Resource::RectangleData::GetGID
virtual GID::Type GetGID() const override
Returns the Gorgon ID of this data object.
Definition: DataItems.h:247
Gorgon::Geometry::basic_Point::Y
T_ Y
Y coordinate.
Definition: Point.h:371
Data.h
Gorgon::Resource::Writer::WriteInt32
void WriteInt32(long value)
Writes a 32-bit integer to the stream.
Definition: Writer.h:149
Gorgon::Resource::ObjectData::SaveValue
virtual void SaveValue(Writer &writer) const override
Saves only the value of the data item to gorgon file.
Definition: DataItems.h:347
Gorgon::Geometry::basic_Size::Width
T_ Width
Width of this size object.
Definition: Size.h:258
Gorgon::Resource::FloatData::ToString
virtual std::string ToString() const override
Converts the contents of this data to string.
Definition: DataItems.h:125
Gorgon::Resource::IntegerData::SaveValue
virtual void SaveValue(Writer &writer) const override
Saves only the value of the data item to gorgon file.
Definition: DataItems.h:93
Gorgon::Resource::PointfData::SaveValue
virtual void SaveValue(Writer &writer) const override
Saves only the value of the data item to gorgon file.
Definition: DataItems.h:198
Gorgon::Resource::BoundsData::BoundsData
BoundsData(const std::string &name, Geometry::Bounds v)
Definition: DataItems.h:272
Gorgon::Resource::SizeData::Load
static DataItem * Load(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long totalsize)
Definition: DataItems.cpp:95
Gorgon::Resource::MarginData::MarginData
MarginData()
Definition: DataItems.h:297
Gorgon::Resource::GID::Type
Type to store GID information.
Definition: GID.h:23
Gorgon::Resource::RectangleData::RectangleData
RectangleData()
Definition: DataItems.h:239
Gorgon::Geometry::basic_Margin
This class defines Margin of an object or an area.
Definition: Margin.h:22
Gorgon::Resource::TextData::TextData
TextData()
Definition: DataItems.h:132
Gorgon::Resource::GID::Data_Size
constexpr Type Data_Size
Definition: GID.h:178
Gorgon::Resource::DataItem::Save
virtual void Save(Writer &writer) const
Saves the data item with header information to gorgon file.
Definition: DataItems.h:31
Gorgon::Resource::RectangleData::Load
static DataItem * Load(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long totalsize)
Definition: DataItems.cpp:111
Gorgon::Resource::BoundsData
Definition: DataItems.h:266
Gorgon::Resource::TextData::TextData
TextData(std::string v)
Definition: DataItems.h:134
Gorgon::Geometry::basic_Rectangle
Represents a rectangle in a 2D space.
Definition: Rectangle.h:19
Gorgon::Resource::PointData::PointData
PointData(const std::string &name, Geometry::Point v)
Definition: DataItems.h:162
Gorgon::Resource::RectangleData::RectangleData
RectangleData(Geometry::Rectangle v)
Definition: DataItems.h:241
Gorgon::Resource::MarginData::GetGID
virtual GID::Type GetGID() const override
Returns the Gorgon ID of this data object.
Definition: DataItems.h:305
Gorgon::Resource::ObjectData::ToString
virtual std::string ToString() const override
Converts the contents of this data to string.
Definition: DataItems.h:400
Gorgon::Resource::PointfData::PointfData
PointfData(const std::string &name, Geometry::Pointf v)
Definition: DataItems.h:189
Gorgon::Resource::GID::Data_Float
constexpr Type Data_Float
Definition: GID.h:171
Gorgon::Resource::ObjectData::Load
static DataItem * Load(std::weak_ptr< File > file, std::shared_ptr< Reader > reader, unsigned long totalsize)
Definition: DataItems.cpp:165
Gorgon::Resource::DataItem::SaveValue
virtual void SaveValue(Writer &writer) const =0
Saves only the value of the data item to gorgon file.
Gorgon::Resource::IntegerData::IntegerData
IntegerData()
Definition: DataItems.h:80
Gorgon::Resource::Base::GetName
const std::string & GetName() const
Returns the name of this object.
Definition: Base.h:61
Gorgon::Resource::DataItem::Get
T_ Get() const
Returns the contents of this data item to the requested type; use GetObject in order to get resource ...
Definition: DataItems.h:40
Gorgon::Resource::RectangleData::SaveValue
virtual void SaveValue(Writer &writer) const override
Saves only the value of the data item to gorgon file.
Definition: DataItems.h:252
Gorgon::Resource::GID::Data_Object
constexpr Type Data_Object
Definition: GID.h:181
Gorgon::Resource::BoundsData::SaveValue
virtual void SaveValue(Writer &writer) const override
Saves only the value of the data item to gorgon file.
Definition: DataItems.h:281
Gorgon::Geometry::basic_Bounds::Top
T_ Top
Top-most boundary.
Definition: Bounds.h:402
Gorgon::Resource::Writer::WriteFloat
void WriteFloat(float value)
Writes a 32 bit IEEE floating point number to the file.
Definition: Writer.h:203
DataItems.h
Gorgon::Resource::ObjectData::ObjectData
ObjectData(const std::string &name, Base &v)
Definition: DataItems.h:330