QXmlStreamAttributes Class
QXmlStreamAttributesクラスは、QXmlStreamAttribute のベクトルを表します。
ヘッダ | #include <QXmlStreamAttributes> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
継承: | QList |
- 継承されたメンバを含む、すべてのメンバのリスト
- QXmlStreamAttributesはXMLクラスの一部です。
メモ:このクラスの関数はすべてリエントラントです。
パブリック関数
QXmlStreamAttributes() | |
void | append(const QString &namespaceUri, const QString &name, const QString &value) |
void | append(const QString &qualifiedName, const QString &value) |
bool | hasAttribute(QAnyStringView qualifiedName) const |
bool | hasAttribute(QAnyStringView namespaceUri, QAnyStringView name) const |
QStringView | value(QAnyStringView namespaceUri, QAnyStringView name) const |
QStringView | value(QAnyStringView qualifiedName) const |
詳細説明
属性は、リーダーがstart element を報告したときにattributes() のQXmlStreamReader によって返されます。 このクラスは、writeAttributes() の引数としてQXmlStreamWriter とともに使用することもできます。
便利な関数value() は、ベクトルをループし、与えられた namespaceUri と属性名に対する属性値を返します。
新しい属性はappend() で追加できます。
メンバ関数のドキュメント
QXmlStreamAttributes::QXmlStreamAttributes()
QXmlStreamAttributes のコンストラクタ。
void QXmlStreamAttributes::append(const QString &namespaceUri, const QString &name, const QString &value)
namespaceUri で記述された名前空間に、name で新しい属性を追加し、value で値を指定します。namespaceUri は空でもよい。
void QXmlStreamAttributes::append(const QString &qualifiedName, const QString &value)
これはオーバーロードされた関数である。
修飾名qualifiedName と値value を持つ新しい属性を追加します。
bool QXmlStreamAttributes::hasAttribute(QAnyStringView qualifiedName) const
このQXmlStreamAttributes が、修飾名がqualifiedName である属性を持つ場合はtrue
を返し、そうでない場合はfalse
を返します。
これは名前空間を意識していないことに注意してください。例えば、このQXmlStreamAttributes が字句の名前が "xlink:href" である属性を含んでいる場合、xlink
接頭辞はどの名前空間にもバインドできるので、XLink 名前空間のhref
という名前の属性が存在することはわかりません。名前空間を意識したコードには、名前空間URIとローカル名をパラメータに取るオーバーロードを使用してください。
bool QXmlStreamAttributes::hasAttribute(QAnyStringView namespaceUri, QAnyStringView name) const
これはオーバーロードされた関数である。
このQXmlStreamAttributes が、名前空間 URI と名前がnamespaceUri とname に対応する属性を持っている場合はtrue
を返し、そうでない場合はfalse
を返します。
[noexcept]
QStringView QXmlStreamAttributes::value(QAnyStringView namespaceUri, QAnyStringView name) const
namespaceUri で記述された名前空間の属性name の値、または属性が定義されていない場合は空の文字列参照を返します。namespaceUri は空でも構いません。
注意: Qt 6.6 より前のバージョンでは、この関数はQString とQLatin1StringView の組み合わせを受け付けるオーバーロードセットとして実装されていました。
[noexcept]
QStringView QXmlStreamAttributes::value(QAnyStringView qualifiedName) const
これはオーバーロードされた関数です。
修飾名qualifiedName を持つ属性の値、または属性が定義されていない場合は空の文字列参照を返します。修飾名とは、XMLデータにおける属性の生の名前です。名前空間接頭辞の後にコロンが続き、その後に属性のローカル名が続きます。名前空間接頭辞は一意ではありません(同じ接頭辞が異なる名前空間を指すことも、異なる接頭辞が同じ名前空間を指すこともあります)ので、修飾名は使用せず、解決された namespaceUri と属性のローカル名を使用します。
注意: Qt 6.6 より前のバージョンでは、この関数はQString とQLatin1StringView のみを受け付けるオーバーロードセットとして実装されていました。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.