iterator Class
class QJsonObject::iteratorQJsonObject::iterator クラスは、QJsonObject 用の STL スタイルの非 const イテレータを提供します。詳細...
- 継承メンバを含む全メンバのリスト
- iterator はQt の JSON Support の一部です。
このクラスは強く比較可能です。
このクラスはQJsonObject::const_iterator と強く比較可能です。
パブリック型
パブリック関数
iterator() | |
QString | key() const |
QJsonValueRef | value() const |
QJsonValueRef | operator*() const |
QJsonObject::iterator | operator+(qsizetype j) const |
QJsonObject::iterator & | operator++() |
QJsonObject::iterator | operator++(int) |
QJsonObject::iterator & | operator+=(qsizetype j) |
qsizetype | operator-(QJsonObject::iterator other) const |
QJsonObject::iterator | operator-(qsizetype j) const |
QJsonObject::iterator & | operator--() |
QJsonObject::iterator | operator--(int) |
QJsonObject::iterator & | operator-=(qsizetype j) |
QJsonValueRef * | operator->() |
const QJsonValueConstRef * | operator->() const |
QJsonValueRef | operator[](qsizetype j) const |
関連する非メンバー
bool | operator!=(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs) |
bool | operator!=(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs) |
bool | operator<(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs) |
bool | operator<(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs) |
bool | operator<=(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs) |
bool | operator<=(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs) |
bool | operator==(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs) |
bool | operator==(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs) |
bool | operator>(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs) |
bool | operator>(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs) |
bool | operator>=(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs) |
bool | operator>=(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs) |
詳細説明
QJsonObject::iterator を使用すると、 を繰り返し処理したり、特定のキーの下に格納されている値 (キーではなく) を変更したりすることができます。const を繰り返し処理する場合は、 を使用する必要があります。イテレータを使用して を変更する必要がない限り、const 以外に を使用するのが一般的です。const イテレータのほうが若干高速で、コードの可読性も向上します。QJsonObject QJsonObject QJsonObject::const_iterator QJsonObject QJsonObject QJsonObject::const_iterator
デフォルトのQJsonObject::iterator コンストラクタは、初期化されていないイテレータを作成します。QJsonObject::begin ()、QJsonObject::end ()、QJsonObject::find ()のようなQJsonObject 関数を使用して初期化しなければなりません。
同じオブジェクトに複数のイテレータを使用することができます。ただし、オブジェクトが変更されると、既存のイテレータはぶら下がった状態になります。
QJsonObject::const_iterator 、QtのJSONサポート、ゲームの保存と読み込みも参照してください 。
メンバ型のドキュメント
iterator::iterator_category
std::random_access_iterator_tagの同義語で、このイテレータがランダムアクセスイテレータであることを示します。
注意: Qt 5.6 より前のバージョンでは、誤ってstd::bidirectional_iterator_tag に設定されていました。
メンバ関数ドキュメント
iterator::iterator()
初期化されていないイテレータを構築します。
key()、value()、 operator++() などの関数を、初期化されていないイテレータで呼び出してはいけません。operator=() を使用して値を代入してから使用してください。
QJsonObject::begin() およびQJsonObject::end()も参照してください 。
QString iterator::key() const
現在のアイテムのキーを返します。
イテレータを通して項目のキーを変更する直接的な方法はありませんが、QJsonObject::erase() の後にQJsonObject::insert() を呼び出すことで可能です。
value()も参照 。
QJsonValueRef iterator::value() const
現在の項目の値への変更可能な参照を返します。
項目の値を変更するには、代入の左辺で value() を使用します。
戻り値は、QJsonArray およびQJsonObject のヘルパー・クラスであるQJsonValueRef 型です。QJsonValueRef 型のオブジェクトを取得すると、それをQJsonValue への参照と同じように使用できます。これに代入すると、その代入は、参照を取得したQJsonArray またはQJsonObject の要素に適用されます。
QJsonValueRef iterator::operator*() const
現在の項目の値への変更可能な参照を返します。
value() と同じ。
戻り値は、QJsonArray およびQJsonObject のヘルパー・クラスであるQJsonValueRef 型です。QJsonValueRef QJsonArray QJsonObject 型のオブジェクトを取得すると、それをあたかも への参照であるかのように使用することができます。QJsonValue
key()も参照 。
QJsonObject::iterator iterator::operator+(qsizetype j) const
このイテレータからj 前方の位置のアイテムへのイテレータを返します。j が負の場合、イテレータは後方に進みます。
operator-()も参照 。
QJsonObject::iterator &iterator::operator++()
++i
前置演算子++
は、イテレータをオブジェクトの次の項目に進め、新しい現在の項目へのイテレータを返す。
この関数をQJsonObject::end() で呼び出すと、未定義の結果になります。
operator--()も参照してください 。
QJsonObject::iterator iterator::operator++(int)
これはオーバーロードされた関数である。
ポストフィックス++
演算子i++
は、イテレータをオブジェクトの次の項目に進め、それ以前の現在の項目へのイテレータを返します。
QJsonObject::iterator &iterator::operator+=(qsizetype j)
イテレータをj アイテム分進めます。j が負の場合、イテレータは後退する。
operator-=() およびoperator+()も参照のこと 。
qsizetype iterator::operator-(QJsonObject::iterator other) const
other が指すアイテムとこのイテレータが指すアイテムの間のアイテム数を返します。
QJsonObject::iterator iterator::operator-(qsizetype j) const
このイテレータからj 後方の位置のアイテムへのイテレータを返します。j が負の場合、イテレータは前方に進みます。
operator+()も参照 。
QJsonObject::iterator &iterator::operator--()
接頭辞--
演算子--i
は、直前の項目をカレントにし、新しいカレント項目を指すイテレータを返す。
この関数をQJsonObject::begin() で呼び出すと、未定義の結果になります。
operator++()も参照 。
QJsonObject::iterator iterator::operator--(int)
これはオーバーロードされた関数である。
ポストフィックス--
演算子、i--
は、直前の項目をカレントとし、直前のカレント項目を指すイテレータを返します。
QJsonObject::iterator &iterator::operator-=(qsizetype j)
イテレータをj アイテム分戻します。j が負の場合、イテレータは前に進みます。
operator+=() およびoperator-()も参照 。
QJsonValueRef *iterator::operator->()
現在のアイテムへの変更可能な参照へのポインタを返します。
const QJsonValueConstRef *iterator::operator->() const
現在のアイテムへの定数参照へのポインタを返します。
QJsonValueRef iterator::operator[](qsizetype j) const
このイテレータが指すアイテム(位置*this + j
のアイテム)からオフセットj にあるアイテムへの変更可能な参照を返します。
この関数は、QJsonObject イテレータを C++ ポインタのように動作させるために用意されています。
戻り値は、QJsonArray およびQJsonObject のヘルパー・クラスであるQJsonValueRef 型です。QJsonValueRef 型のオブジェクトを取得すると、それをQJsonValue への参照であるかのように使用できます。これに代入すると、その代入は、参照を取得したQJsonArray またはQJsonObject の要素に適用されます。
operator+()も参照してください 。
関連する非メンバー
[noexcept]
bool operator==(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs)
[noexcept]
bool operator==(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs)
lhs がイテレータrhs と同じアイテムを指している場合はtrue
を返し、そうでない場合はfalse
を返す。
operator!=()も参照 。
[noexcept]
bool operator!=(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs)
[noexcept]
bool operator!=(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs)
lhs がイテレータrhs と異なるアイテムを指している場合はtrue
を返し、そうでない場合はfalse
を返す。
operator==()も参照 。
[noexcept]
bool operator<(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs)
[noexcept]
bool operator<(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs)
lhs イテレータが指すアイテムが、rhs イテレータが指すアイテムより小さい場合、true
を返す。
[noexcept]
bool operator<=(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs)
[noexcept]
bool operator<=(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs)
lhs イテレータが指すアイテムが、rhs イテレータが指すアイテム以下である場合、true
を返す。
[noexcept]
bool operator>(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs)
[noexcept]
bool operator>(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs)
lhs イテレータが指すアイテムが、rhs イテレータが指すアイテムより大きい場合、true
を返す。
[noexcept]
bool operator>=(const QJsonObject::iterator &lhs, const QJsonObject::const_iterator &rhs)
[noexcept]
bool operator>=(const QJsonObject::iterator &lhs, const QJsonObject::iterator &rhs)
lhs イテレータが指すアイテムが、rhs イテレータが指すアイテム以上であれば、true
を返す。
© 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.