diff options
author | nyamatongwe <unknown> | 2001-12-19 07:02:39 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2001-12-19 07:02:39 +0000 |
commit | 0b3663846c53925091d7666a0c31fdc7ae09eb52 (patch) | |
tree | 3d983555cded31e753797f15243edeecb746e7c4 /src | |
parent | 8fcf7e6bf6e3f1d6ed9ed7a01d199da3f5cd8fd4 (diff) | |
download | scintilla-mirror-0b3663846c53925091d7666a0c31fdc7ae09eb52.tar.gz |
Added AutoSurface class which is a smart pointer that ensures correct
deallocation of Surface objects.
Diffstat (limited to 'src')
-rw-r--r-- | src/Editor.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/Editor.h b/src/Editor.h index 9c42e28cb..c58da4ea5 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -71,6 +71,38 @@ public: }; /** + * A smart pointer class to ensure Surfaces are set up and deleted correctly. + */ +class AutoSurface { +private: + Surface *surf; +public: + AutoSurface(bool unicodeMode) { + surf = Surface::Allocate(); + if (surf) { + surf->Init(); + surf->SetUnicodeMode(unicodeMode); + } + } + AutoSurface(SurfaceID sid, bool unicodeMode) { + surf = Surface::Allocate(); + if (surf) { + surf->Init(sid); + surf->SetUnicodeMode(unicodeMode); + } + } + ~AutoSurface() { + delete surf; + } + Surface *operator->() const { + return surf; + } + operator Surface *() const { + return surf; + } +}; + +/** */ class Editor : public DocWatcher { // Private so Editor objects can not be copied |