ADTF  3.18.2
qt_string_intf.h
Go to the documentation of this file.
1 
8 /*
9  * This file depends on Qt which is licensed under LGPLv3.
10  * See ADTF_DIR/3rdparty/qt5 and doc/license for detailed information.
11  */
12 #pragma once
13 #include <QString>
14 #include <adtfbase/string_intf.h>
15 
16 namespace adtf
17 {
18 namespace ui
19 {
20 namespace ant
21 {
27  {
28  private:
30  QString* m_pAssignValue;
31  mutable QByteArray m_oValueToReturnConstChar;
33  cQtIStringImpl() = delete;
36  cQtIStringImpl(const cQtIStringImpl& strValue) = delete;
39  cQtIStringImpl(cQtIStringImpl&& strValue) = delete;
43  cQtIStringImpl& operator=(const cQtIStringImpl& strValue) = delete;
47  cQtIStringImpl& operator=(cQtIStringImpl&& strValue) = delete;
48  public:
51  explicit cQtIStringImpl(QString* pstrAssignValue)
52  {
53  m_pAssignValue = pstrAssignValue;
54  }
57  {
58  m_pAssignValue = nullptr;
59  }
60  tResult Set(const char* strValue) override
61  {
62  if (strValue != nullptr)
63  {
64  *m_pAssignValue = QString::fromLocal8Bit(strValue);
65  m_pAssignValue->detach();
67  }
68  else
69  {
70  RETURN_ERROR(ERR_POINTER);
71  }
72  }
73  const char* Get() const override
74  {
75  const tChar* strValue = "";
76  if (m_pAssignValue != nullptr)
77  {
78  m_oValueToReturnConstChar = m_pAssignValue->toLocal8Bit();
79  strValue = m_oValueToReturnConstChar.data();
80  }
81  return strValue;
82  }
83  size_t GetLength() const override
84  {
85  if (m_pAssignValue != nullptr)
86  {
87  return static_cast<size_t>(m_pAssignValue->size());
88  }
89  return IString::InvalidPos;
90  }
91  };
92 
93 }
94 using ant::cQtIStringImpl;
95 }
96 }
97 
98 namespace adtf
99 {
100 namespace base
101 {
102 namespace ant
103 {
104 
105 template <>
106 struct adtf_string<QString>: public ui::ant::cQtIStringImpl
107 {
109 };
110 
111 }
112 }
113 }
114 
120 #define adtf_qstring_intf(q_string_val) ::adtf::ui::cQtIStringImpl(& (q_string_val))
char tChar
The tChar defines the type for platform character set (platform and compiler dependent type).
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
#define RETURN_ERROR(code)
Return specific error code, which requires the calling function's return type to be tResult.
The IString interface provides methods for getting and setting strings through abstract interfaces.
Definition: string_intf.h:28
Wrapping template for a rvalue reference of an IString interface for the type T (see Supported types ...
Definition: string_intf.h:196
Specialisation for QString class, because the QString stores values as unsigned short.
cQtIStringImpl(QString *pstrAssignValue)
CTOR with pointer to the value of value_type.
tResult Set(const char *strValue) override
Sets the given null-terminated string to the implementation.
cQtIStringImpl & operator=(const cQtIStringImpl &strValue)=delete
copy operator
cQtIStringImpl & operator=(cQtIStringImpl &&strValue)=delete
move operator
cQtIStringImpl(cQtIStringImpl &&strValue)=delete
move CTOR
size_t GetLength() const override
Gets the current size of the strng.
QString * m_pAssignValue
pointer to the value
cQtIStringImpl(const cQtIStringImpl &strValue)=delete
copy CTOR
const char * Get() const override
Gets the pointer to the current associated nullterminated-string.
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.