Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-10 10:23:45

0001 //========================================================================
0002 //
0003 // Array.h
0004 //
0005 // Copyright 1996-2003 Glyph & Cog, LLC
0006 //
0007 //========================================================================
0008 
0009 //========================================================================
0010 //
0011 // Modified under the Poppler project - http://poppler.freedesktop.org
0012 //
0013 // All changes made under the Poppler project to this file are licensed
0014 // under GPL version 2 or later
0015 //
0016 // Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>
0017 // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
0018 // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
0019 // Copyright (C) 2017-2019, 2021 Albert Astals Cid <aacid@kde.org>
0020 // Copyright (C) 2017 Adrian Johnson <ajohnson@redneon.com>
0021 // Copyright (C) 2018, 2019 Adam Reichold <adam.reichold@t-online.de>
0022 //
0023 // To see a description of the changes please see the Changelog file that
0024 // came with your tarball or type make ChangeLog if you are building from git
0025 //
0026 //========================================================================
0027 
0028 #ifndef ARRAY_H
0029 #define ARRAY_H
0030 
0031 #include <atomic>
0032 #include <mutex>
0033 #include <vector>
0034 
0035 #include "poppler-config.h"
0036 #include "poppler_private_export.h"
0037 #include "Object.h"
0038 
0039 class XRef;
0040 
0041 //------------------------------------------------------------------------
0042 // Array
0043 //------------------------------------------------------------------------
0044 
0045 class POPPLER_PRIVATE_EXPORT Array
0046 {
0047 public:
0048     // Constructor.
0049     explicit Array(XRef *xrefA);
0050 
0051     // Destructor.
0052     ~Array();
0053 
0054     Array(const Array &) = delete;
0055     Array &operator=(const Array &) = delete;
0056 
0057     // Get number of elements.
0058     int getLength() const { return elems.size(); }
0059 
0060     // Copy array with new xref
0061     Array *copy(XRef *xrefA) const;
0062 
0063     Array *deepCopy() const;
0064 
0065     // Add an element
0066     // elem becomes a dead object after this call
0067     void add(Object &&elem);
0068 
0069     // Remove an element by position
0070     void remove(int i);
0071 
0072     // Accessors.
0073     Object get(int i, int recursion = 0) const;
0074     // Same as above but if the returned object is a fetched Ref returns such Ref in returnRef, otherwise returnRef is Ref::INVALID()
0075     Object get(int i, Ref *returnRef, int recursion = 0) const;
0076     const Object &getNF(int i) const;
0077     bool getString(int i, GooString *string) const;
0078 
0079 private:
0080     friend class Object; // for incRef/decRef
0081 
0082     // Reference counting.
0083     int incRef() { return ++ref; }
0084     int decRef() { return --ref; }
0085 
0086     XRef *xref; // the xref table for this PDF file
0087     std::vector<Object> elems; // array of elements
0088     std::atomic_int ref; // reference count
0089     mutable std::recursive_mutex mutex;
0090 };
0091 
0092 #endif