diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-04-17 16:49:15 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-05-06 13:58:09 -0700 |
commit | fe82cb32b93e906b9bf53010538651b9c84df9db (patch) | |
tree | 91d944915294c37136221074e31e8077cefc52ad /core/pictureobj.h | |
parent | 6f8cc5aafecdbbd824be8872c6c4d837d725ef40 (diff) | |
download | subsurface-fe82cb32b93e906b9bf53010538651b9c84df9db.tar.gz |
media: add small C++ helper describing a picture struct
By using a std::string instead of a C-string, memory management
becomes so much simpler! This class will be used for keeping track
of deleted/added pictures in the undo system.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/pictureobj.h')
-rw-r--r-- | core/pictureobj.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/core/pictureobj.h b/core/pictureobj.h new file mode 100644 index 000000000..6ea20259b --- /dev/null +++ b/core/pictureobj.h @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0 + +#ifndef PICTUREOBJ_H +#define PICTUREOBJ_H + +// A tiny helper class that represents a struct picture of the core +// It does, however, keep the filename as a std::string so that C++ code +// doesn't have do its own memory-management. + +#include "core/units.h" +#include "core/picture.h" +#include <string> + +struct PictureObj { + std::string filename; + offset_t offset; + location_t location; + + PictureObj(); // Initialize to empty picture. + PictureObj(const picture &pic); // Create from core struct picture. + picture toCore() const; // Turn into core structure. Caller responsible for freeing. + bool operator<(const PictureObj &p2) const; +}; + +#endif // PICTUREOBJ_H |