From 764ec513eecbebd12781bcc96ce81ed5e736ee92 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 14 Mar 2016 13:35:12 -0400 Subject: Move core/src/ up to core/. This CL moves the core/src/ files up to core/ and fixes up the include guards, includes and build files. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1800523005 . --- core/fxcodec/jbig2/JBig2_List.h | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 core/fxcodec/jbig2/JBig2_List.h (limited to 'core/fxcodec/jbig2/JBig2_List.h') diff --git a/core/fxcodec/jbig2/JBig2_List.h b/core/fxcodec/jbig2/JBig2_List.h new file mode 100644 index 0000000000..b021ac3375 --- /dev/null +++ b/core/fxcodec/jbig2/JBig2_List.h @@ -0,0 +1,54 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FXCODEC_JBIG2_JBIG2_LIST_H_ +#define CORE_FXCODEC_JBIG2_JBIG2_LIST_H_ + +#include + +#include + +// A poor man's ScopedVector for pointers of TYPE. +// Owns all the pointers contained within and deletes them on destruction. +template +class CJBig2_List { + public: + CJBig2_List() {} + explicit CJBig2_List(size_t count) { resize(count); } + + ~CJBig2_List() { clear(); } + + TYPE* get(size_t index) const { return m_vector[index]; } + TYPE* back() const { return m_vector.back(); } + size_t size() const { return m_vector.size(); } + + // Deletes all the pointers contained within. + void clear() { + for (size_t i = 0; i < m_vector.size(); ++i) + delete m_vector[i]; + m_vector.clear(); + } + + // Takes ownership of |pItem|. + void push_back(TYPE* pItem) { m_vector.push_back(pItem); } + + // Takes ownership of |pItem|. + void set(size_t index, TYPE* pItem) { + delete m_vector[index]; + m_vector[index] = pItem; + } + + void resize(size_t count) { + for (size_t i = count; i < size(); ++i) + delete m_vector[i]; + m_vector.resize(count); + } + + private: + std::vector m_vector; +}; + +#endif // CORE_FXCODEC_JBIG2_JBIG2_LIST_H_ -- cgit v1.2.3