LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
defaulthookproxy.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 <QMap>
12 #include "xpcconfig.h"
13 #include "interfaces/iinfo.h"
15 
16 namespace LC::Util
17 {
25  class UTIL_XPC_API DefaultHookProxy : public IHookProxy
26  {
27  bool Cancelled_ = false;
28  QVariant ReturnValue_;
29 
30  QMap<QByteArray, QVariant> Name2NewVal_;
31  public:
34  DefaultHookProxy () = default;
35 
44 
49  void CancelDefault () override;
50 
60  bool IsCancelled () const;
61 
64  const QVariant& GetReturnValue () const override;
65 
68  void SetReturnValue (const QVariant&) override;
69 
81  template<typename T>
82  void FillValue (const QByteArray& name, T& val)
83  {
84  if (!Name2NewVal_.contains (name))
85  return;
86 
87  const QVariant& newVal = Name2NewVal_ [name];
88  if (!newVal.isValid ())
89  return;
90 
91  val = newVal.value<T> ();
92  }
93 
96  QVariant GetValue (const QByteArray&) const override;
97 
100  void SetValue (const QByteArray&, const QVariant&) override;
101  };
102 
103  using DefaultHookProxy_ptr = std::shared_ptr<DefaultHookProxy>;
104 }
LC::Util::DefaultHookProxy_ptr
std::shared_ptr< DefaultHookProxy > DefaultHookProxy_ptr
Definition: defaulthookproxy.h:109
xpcconfig.h
LC::Util
Definition: icoreproxy.h:33
LC::Util::DefaultHookProxy
Standard implementation of IHookProxy.
Definition: defaulthookproxy.h:31
iinfo.h
ihookproxy.h
UTIL_XPC_API
#define UTIL_XPC_API
Definition: xpcconfig.h:16
QMap< QByteArray, QVariant >