/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
NS_IMETHODIMP
nsStringEnumeratorBase::StringIterator(nsIJSEnumerator** aRetVal) { auto result = MakeRefPtr<JSStringEnumerator>(this);
result.forget(aRetVal); return NS_OK;
}
// // nsStringEnumerator //
class nsStringEnumerator final : public nsSimpleEnumerator, public nsIStringEnumerator, public nsIUTF8StringEnumerator { public:
nsStringEnumerator(const nsTArray<nsString>* aArray, bool aOwnsArray)
: mArray(aArray), mIndex(0), mOwnsArray(aOwnsArray), mIsUnicode(true) {}
// have to declare nsIStringEnumerator manually, because of // overlapping method names
NS_IMETHOD GetNext(nsAString& aResult) override;
NS_DECL_NSISIMPLEENUMERATOR
private:
~nsStringEnumerator() { if (mOwnsArray) { // const-casting is safe here, because the NS_New* // constructors make sure mOwnsArray is consistent with // the constness of the objects if (mIsUnicode) { deleteconst_cast<nsTArray<nsString>*>(mArray);
} else { deleteconst_cast<nsTArray<nsCString>*>(mCArray);
}
}
}
union { const nsTArray<nsString>* mArray; const nsTArray<nsCString>* mCArray;
};
// the owner allows us to hold a strong reference to the object // that owns the array. Having a non-null value in mOwner implies // that mOwnsArray is false, because we rely on the real owner // to release the array
nsCOMPtr<nsISupports> mOwner; bool mOwnsArray; bool mIsUnicode;
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.