michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef txOwningArray_h__ michael@0: #define txOwningArray_h__ michael@0: michael@0: // Class acting like a nsTArray except that it deletes its objects michael@0: // on destruction. It does not however delete its objects on operations michael@0: // like RemoveElementsAt or on |array[i] = bar|. michael@0: michael@0: template michael@0: class txOwningArray : public nsTArray michael@0: { michael@0: public: michael@0: typedef nsTArray base_type; michael@0: typedef typename base_type::elem_type elem_type; michael@0: michael@0: ~txOwningArray() michael@0: { michael@0: elem_type* iter = base_type::Elements(); michael@0: elem_type* end = iter + base_type::Length(); michael@0: for (; iter < end; ++iter) { michael@0: delete *iter; michael@0: } michael@0: } michael@0: michael@0: }; michael@0: michael@0: #endif // txOwningArray_h__