qt.cfg: Add QByteArray container configuration (similar to QString) (#2088)

Reference: https://doc.qt.io/qt-5/qbytearray.html
This commit is contained in:
Sebastian 2019-08-15 16:14:17 +02:00 committed by GitHub
parent 95ac8db584
commit 544bedc6ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 0 deletions

View File

@ -3561,6 +3561,18 @@
<not-uninit/>
</arg>
</function>
<!-- QByteArray https://doc.qt.io/qt-5/qbytearray.html -->
<!-- char QByteArray::at(int i) const -->
<function name="QByteArray::at">
<noreturn>false</noreturn>
<returnValue type="char"/>
<use-retval/>
<const/>
<arg nr="1" direction="in">
<not-uninit/>
<not-bool/>
</arg>
</function>
<!-- ##### Container ##### -->
<container id="qtContainer" opLessAllowed="false" itEndPattern="&gt; :: iterator|const_iterator">
<type templateParameter="0"/>
@ -3664,6 +3676,27 @@
<function name="crend" yields="end-iterator"/>
</access>
</container>
<container id="qtByteArray" startPattern="QByteArray" endPattern="" inherits="qtContainer" opLessAllowed="true" itEndPattern=":: iterator|const_iterator|reverse_iterator|const_reverse_iterator">
<size>
<function name="isNull" yields="empty"/>
<function name="resize" action="resize"/>
<function name="push_back" action="push"/>
<function name="push_front" action="push"/>
<function name="prepend" action="push"/>
<function name="shrink_to_fit" action="change-internal"/>
<function name="squeeze" action="change-internal"/>
<function name="reserve" action="change-internal"/>
</size>
<access indexOperator="array-like">
<function name="at" yields="at_index"/>
<function name="front" yields="item"/>
<function name="back" yields="item"/>
<function name="rbegin" yields="start-iterator"/>
<function name="crbegin" yields="start-iterator"/>
<function name="rend" yields="end-iterator"/>
<function name="crend" yields="end-iterator"/>
</access>
</container>
<!-- TODO: Inheriting from qtList also inherits from qtContainer which sets "<type templateParameter="0"/>". This is not correct, but seems to do no harm. Currently this can not be unset. -->
<container id="qtStringList" startPattern="QStringList" inherits="qtList" opLessAllowed="true" itEndPattern=":: iterator|const_iterator|reverse_iterator|const_reverse_iterator">
<size>

View File

@ -44,6 +44,26 @@ QString::iterator QString3()
return it;
}
void QByteArray1(QByteArray byteArrayArg)
{
for (int i = 0; i <= byteArrayArg.size(); ++i) {
// cppcheck-suppress stlOutOfBounds
byteArrayArg[i] = 'x';
}
// cppcheck-suppress containerOutOfBoundsIndexExpression
byteArrayArg[byteArrayArg.length()] = 'a';
// cppcheck-suppress containerOutOfBoundsIndexExpression
byteArrayArg[byteArrayArg.count()] = 'b';
// cppcheck-suppress containerOutOfBoundsIndexExpression
printf("val: %c\n", byteArrayArg[byteArrayArg.size()]);
QByteArray byteArray1{'a', 'b'};
(void)byteArray1[1];
// cppcheck-suppress ignoredReturnValue
byteArray1.at(1);
}
void QList1(QList<int> intListArg)
{
for (int i = 0; i <= intListArg.size(); ++i) {