forked from derekblair/ILPDFKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathILPDFArray.h
More file actions
120 lines (96 loc) · 5.25 KB
/
Copy pathILPDFArray.h
File metadata and controls
120 lines (96 loc) · 5.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// ILPDFArray.h
//
// Copyright (c) 2017 Derek Blair
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <Foundation/Foundation.h>
#import "ILPDFObject.h"
NS_ASSUME_NONNULL_BEGIN
/** The ILPDFArray class encapsulates a PDF array object contained in a ILPDFDocument.
Essentially, is is a wrapper class for a CGPDFArrayRef.
CGPDFArrayRef pdfARef = myCGPDFArrayRef;
ILPDFArray* pdfArray = [[ILPDFArray alloc] initWithArray:pdfARef];
ILPDFArray provides a range of methods that mirror those of NSArray. ILPDFArray may also
be instantiated based on a string representation of its contents without needing to be assoicated with
a parent document.
*/
@interface ILPDFArray : NSObject <NSFastEnumeration, ILPDFObject>
/**
The Core Graphics array reference, if it exists.
*/
@property (nonatomic, readonly, nullable) CGPDFArrayRef arr;
/**---------------------------------------------------------------------------------------
* @name Creating a ILPDFArray
* ---------------------------------------------------------------------------------------
*/
/** Creates a new instance of ILPDFArray wrapping a CGPDFArrayRef
@param parr A CGPDFArrayRef representing the PDF array.
@return A new ILPDFArray object. Initialization in memory occurs when the instance receives value based query.
*/
- (instancetype)initWithArray:(CGPDFArrayRef)parr NS_DESIGNATED_INITIALIZER;
/**---------------------------------------------------------------------------------------
* @name Rectangle Arrays
* ---------------------------------------------------------------------------------------
*/
/** Returns the rectangle when the array is interpreted as a rectangle array.
@return The NSValue boxed CGRect corresponding to the retangle array or nil of the array is invalid.
@discussion A 'Rect' array is a PDF Array that specifies a rectangle on page in default user space units. It consists of 4 real numbers that may be negative or positive and typically has a 'Rect' key when obtained from a parent ILPDFDictionary.
The CGRect returned specifies the same rectangle in user space units only it has its origin at top left like a rectangle on a UIView. The 'Rect' ILPDFArray has a format [left, bottom, right, top] and the return rect is obtained as
CGRectMake(MIN(left,right),MIN(bottom,top),fabsf(right-left),fabsf(top-bottom))
*/
- (nullable NSValue *)rect;
/**---------------------------------------------------------------------------------------
* @name Accessing Values
* ---------------------------------------------------------------------------------------
*/
/** Returns the value associated with a given index.
@param index The index for which to return the corresponding value
@return The value associated with index, or nil if no value is associated with index.
*/
- (nullable id)objectAtIndex:(NSUInteger)index;
/** Returns the first object.
@return The first object or nil if the array is empty.
*/
-(nullable id)firstObject;
/** Returns the last object.
@return The last object or nil if the array is empty.
*/
-(nullable id)lastObject;
/**---------------------------------------------------------------------------------------
* @name Counting Entries
* ---------------------------------------------------------------------------------------
*/
/** Returns the number of elements in the array.
@return The number of elements in the array.
*/
- (NSUInteger)count;
/**---------------------------------------------------------------------------------------
* @name Comparing Arrays
* ---------------------------------------------------------------------------------------
*/
/** Returns a Boolean value that indicates whether the contents of the receiving array are equal to the contents of another given array.
@param otherArray The array with which to compare the receiving array.
@return YES if the contents of otherArray are equal to the contents of the receiving array, otherwise NO.
@discussion Two arrays have equal contents if they each hold the same number of objects and objects at a given index in each array satisfy the isEqual: test.
*/
- (BOOL)isEqualToArray:(ILPDFArray *)otherArray;
////// This class supports indexed subscripting as in id<ILPDFObject> obj = pdfArray[index];
- (nullable id)objectAtIndexedSubscript:(NSUInteger)idx;
@end
NS_ASSUME_NONNULL_END