LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
scopeguards.h
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #pragma once
10 
11 #include <QSettings>
12 #include "util.h"
13 
14 namespace LC::Util
15 {
27  [[nodiscard]] inline auto MakeEndGroupScopeGuard (QSettings& settings)
28  {
29  return MakeScopeGuard ([&settings] { settings.endGroup (); });
30  }
31 
42  [[nodiscard]] inline auto BeginGroup (QSettings& settings, const QString& group)
43  {
44  settings.beginGroup (group);
45  return MakeScopeGuard ([&settings] { settings.endGroup (); });
46  }
47 }
LC::Util
Definition: icoreproxy.h:33
util.h
LC::Util::MakeEndGroupScopeGuard
auto MakeEndGroupScopeGuard(QSettings &settings)
Creates a scope guard that ends the current group on settings.
Definition: scopeguards.h:33
LC::Util::MakeScopeGuard
detail::ScopeGuard< F > MakeScopeGuard(const F &f)
Returns an object performing passed function on scope exit.
Definition: util.h:148
LC::Util::BeginGroup
auto BeginGroup(QSettings &settings, const QString &group)
Begins the group on settings and returns a scope guard ending that group.
Definition: scopeguards.h:48