include/comphelper/flagguard.hxx | 4 +++ include/o3tl/restoreguard.hxx | 40 --------------------------------------- vcl/source/fontsubset/cff.cxx | 6 ++--- 3 files changed, 7 insertions(+), 43 deletions(-)
New commits: commit a08ae2b5d06a49fa69f1282d1dddc45d1d5bd919 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Tue Nov 8 08:36:20 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Tue Nov 8 13:21:29 2022 +0100 Combine o3tl::RestoreGuard into comphelper::ValueRestorationGuard Change-Id: Iec42b3bf348ba82a98d4ad8236a9e8b95fdfe5f1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142422 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/include/comphelper/flagguard.hxx b/include/comphelper/flagguard.hxx index 14eee07a8401..72fa43aa90d0 100644 --- a/include/comphelper/flagguard.hxx +++ b/include/comphelper/flagguard.hxx @@ -46,6 +46,10 @@ namespace comphelper class ValueRestorationGuard : public ScopeGuard<ValueRestorationGuard_Impl<T>> { public: + ValueRestorationGuard(T& i_valRef) + : ScopeGuard<ValueRestorationGuard_Impl<T>>(ValueRestorationGuard_Impl(i_valRef)) + {} + template <typename T1> ValueRestorationGuard(T& i_valRef, T1&& i_temporaryValue) : ScopeGuard<ValueRestorationGuard_Impl<T>>(ValueRestorationGuard_Impl(i_valRef)) diff --git a/include/o3tl/restoreguard.hxx b/include/o3tl/restoreguard.hxx deleted file mode 100644 index 19075be3dcea..000000000000 --- a/include/o3tl/restoreguard.hxx +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#pragma once - -#include <sal/config.h> - -// A convenience guard class that captures a given object's value on guard construction and restores -// it on guard destruction: -namespace o3tl -{ -template <typename T> class RestoreGuard -{ -public: - RestoreGuard(T& object) - : object_(object) - , value_(object) - { - } - - ~RestoreGuard() { object_ = value_; } - -private: - RestoreGuard(RestoreGuard&) = delete; - RestoreGuard(RestoreGuard&&) = delete; - void operator=(RestoreGuard&) = delete; - void operator=(RestoreGuard&&) = delete; - - T& object_; - T value_; -}; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/source/fontsubset/cff.cxx b/vcl/source/fontsubset/cff.cxx index cb980018a64f..900ddfeea637 100644 --- a/vcl/source/fontsubset/cff.cxx +++ b/vcl/source/fontsubset/cff.cxx @@ -24,7 +24,7 @@ #include <fontsubset.hxx> -#include <o3tl/restoreguard.hxx> +#include <comphelper/flagguard.hxx> #include <o3tl/safeint.hxx> #include <o3tl/sprintf.hxx> #include <rtl/math.hxx> @@ -1938,8 +1938,8 @@ OString CffSubsetterContext::getString( int nStringID) return pStringIds[ nStringID]; // else get the string from the StringIndex table - o3tl::RestoreGuard pReadPtr(mpReadPtr); - o3tl::RestoreGuard pReadEnd(mpReadEnd); + comphelper::ValueRestorationGuard pReadPtr(mpReadPtr); + comphelper::ValueRestorationGuard pReadEnd(mpReadEnd); nStringID -= nStdStrings; int nLen = seekIndexData( mnStringIdxBase, nStringID); // assert( nLen >= 0);