AusweisApp2
BluetoothMessageParameter.h
gehe zur Dokumentation dieser Datei
1 
7 #pragma once
8 
10 
11 #include <QLoggingCategory>
12 
13 Q_DECLARE_LOGGING_CATEGORY(bluetooth)
14 
15 
16 namespace governikus
17 {
18 
20 {
21  private:
22  BluetoothParamId mParamId;
23 
24  protected:
25  QByteArray mValue;
26  bool mValid;
27 
28  inline QString toStringBase() const
29  {
30  return mParamId + QStringLiteral(" | Value: ");
31  }
32 
33 
34  template<typename T> bool parseByteParameter(const QByteArray& pValue, T& pDest) const
35  {
36  if (pValue.size() == 1)
37  {
38  pDest = static_cast<T>(pValue.at(0));
39  if (!Enum<T>::isValue(pValue.at(0)))
40  {
41  qCWarning(bluetooth) << "Value is unknown:" << pDest;
42  }
43  return true;
44  }
45  else
46  {
47  qCWarning(bluetooth) << "Content has wrong size:" << pValue.toHex();
48  }
49 
50  return false;
51  }
52 
53  public:
54  BluetoothMessageParameter(BluetoothParamId pParamId, const QByteArray& pValue);
56 
57  BluetoothParamId getParameterId() const;
58  const QByteArray& getValue() const;
59  QByteArray toData() const;
60  bool isValid() const;
61 
62  virtual QString toString() const;
63  virtual QString toStringValue() const;
64 };
65 
66 } // namespace governikus
67 
68 QDebug operator<<(QDebug pDbg, const governikus::BluetoothMessageParameter& pMsg);
governikus::Enum
Definition: EnumHelper.h:81
governikus::operator<<
QDebug operator<<(QDebug pDbg, const CardInfo &pCardInfo)
Definition: CardInfo.cpp:259
governikus::BluetoothMessageParameter::toStringValue
virtual QString toStringValue() const
Definition: BluetoothMessageParameter.cpp:44
governikus::BluetoothMessageParameter::~BluetoothMessageParameter
virtual ~BluetoothMessageParameter()
Definition: BluetoothMessageParameter.cpp:27
operator<<
QDebug operator<<(QDebug pDbg, const governikus::BluetoothMessageParameter &pMsg)
Definition: BluetoothMessageParameter.cpp:12
BluetoothUtils.h
governikus::Enum::getValue
static EnumBaseTypeT getValue(EnumTypeT pType)
Definition: EnumHelper.h:172
governikus::BluetoothMessageParameter::parseByteParameter
bool parseByteParameter(const QByteArray &pValue, T &pDest) const
Definition: BluetoothMessageParameter.h:34
governikus::BluetoothMessageParameter::mValue
QByteArray mValue
Definition: BluetoothMessageParameter.h:25
BluetoothIDs.h
governikus::BluetoothMessageParameter::mValid
bool mValid
Definition: BluetoothMessageParameter.h:26
governikus::BluetoothMessageParameter::BluetoothMessageParameter
BluetoothMessageParameter(BluetoothParamId pParamId, const QByteArray &pValue)
Definition: BluetoothMessageParameter.cpp:19
governikus::BluetoothMessageParameter::getValue
const QByteArray & getValue() const
Definition: BluetoothMessageParameter.cpp:38
governikus::BluetoothMessageParameter::getParameterId
BluetoothParamId getParameterId() const
Definition: BluetoothMessageParameter.cpp:32
governikus::BluetoothUtils::addPadding
static void addPadding(QByteArray &pData, const QByteArray &pContent, ushort pPaddingLen=DEFAULT_PADDING_LENGTH)
Definition: BluetoothUtils.cpp:22
governikus
Implementation of ActivationContext for Intent based activation on Android systems.
Definition: ActivationContext.h:15
governikus::BluetoothMessageParameter::toStringBase
QString toStringBase() const
Definition: BluetoothMessageParameter.h:28
governikus::BluetoothMessageParameter::isValid
bool isValid() const
Definition: BluetoothMessageParameter.cpp:56
BluetoothMessageParameter.h
governikus::BluetoothMessageParameter
Definition: BluetoothMessageParameter.h:20
T
#define T(v)
Definition: http_parser.cpp:237
governikus::BluetoothMessageParameter::toData
QByteArray toData() const
Definition: BluetoothMessageParameter.cpp:62
governikus::BluetoothMessageParameter::toString
virtual QString toString() const
Definition: BluetoothMessageParameter.cpp:50