xpcom/glue/nsArrayUtils.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/glue/nsArrayUtils.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,40 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsArrayUtils_h__
    1.10 +#define nsArrayUtils_h__
    1.11 +
    1.12 +#include "nsCOMPtr.h"
    1.13 +#include "nsIArray.h"
    1.14 +
    1.15 +// helper class for do_QueryElementAt
    1.16 +class NS_COM_GLUE nsQueryArrayElementAt : public nsCOMPtr_helper
    1.17 +  {
    1.18 +    public:
    1.19 +      nsQueryArrayElementAt(nsIArray* aArray, uint32_t aIndex,
    1.20 +                            nsresult* aErrorPtr)
    1.21 +          : mArray(aArray),
    1.22 +            mIndex(aIndex),
    1.23 +            mErrorPtr(aErrorPtr)
    1.24 +        {
    1.25 +          // nothing else to do here
    1.26 +        }
    1.27 +
    1.28 +      virtual nsresult NS_FASTCALL operator()(const nsIID& aIID, void**) const;
    1.29 +
    1.30 +    private:
    1.31 +      nsIArray*  mArray;
    1.32 +      uint32_t   mIndex;
    1.33 +      nsresult*  mErrorPtr;
    1.34 +  };
    1.35 +
    1.36 +inline
    1.37 +const nsQueryArrayElementAt
    1.38 +do_QueryElementAt(nsIArray* aArray, uint32_t aIndex, nsresult* aErrorPtr = 0)
    1.39 +  {
    1.40 +    return nsQueryArrayElementAt(aArray, aIndex, aErrorPtr);
    1.41 +  }
    1.42 +
    1.43 +#endif // nsArrayUtils_h__

mercurial