From b89669975f6156fce4ced5c8998125a845f8e7dc Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 21 Sep 2017 14:51:57 -0400 Subject: Move CFX_AutoRestorer to fxcrt::AutoRestorer This CL renames CFX_AutoRestorer to just AutoRestorer and places in the fxcrt namespace. Bug: pdfium:898 Change-Id: Id9f36df94e95f3b2a55054bc198ca1bfd249ee3d Reviewed-on: https://pdfium-review.googlesource.com/14450 Commit-Queue: dsinclair Reviewed-by: Tom Sepez --- core/fxcrt/autorestorer.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 core/fxcrt/autorestorer.h (limited to 'core/fxcrt/autorestorer.h') diff --git a/core/fxcrt/autorestorer.h b/core/fxcrt/autorestorer.h new file mode 100644 index 0000000000..745a56fff2 --- /dev/null +++ b/core/fxcrt/autorestorer.h @@ -0,0 +1,26 @@ +// Copyright 2017 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CORE_FXCRT_AUTORESTORER_H_ +#define CORE_FXCRT_AUTORESTORER_H_ + +namespace fxcrt { + +template +class AutoRestorer { + public: + explicit AutoRestorer(T* location) + : m_Location(location), m_OldValue(*location) {} + ~AutoRestorer() { *m_Location = m_OldValue; } + + private: + T* const m_Location; + const T m_OldValue; +}; + +} // namespace fxcrt + +using fxcrt::AutoRestorer; + +#endif // CORE_FXCRT_AUTORESTORER_H_ -- cgit v1.2.3