30
30
val:: Int
31
31
end
32
32
33
- show (io:: IO , o:: CosObject ) = print (io, o. val)
34
-
35
- show (io:: IO , o:: CosNullType ) = print (io, " null" )
36
-
37
33
"""
38
34
A parsed data structure to ensure the object information is stored as an object.
39
35
This has no meaning without a associated CosDoc. When a reference object is hit
@@ -44,8 +40,6 @@ the object should be searched from the CosDoc and returned.
44
40
CosIndirectObjectRef (num:: Int , gen:: Int )= new ((num,gen))
45
41
end
46
42
47
- show (io:: IO , o:: CosIndirectObjectRef ) = @printf io " %d %d R" o. val[1 ] o. val[2 ]
48
-
49
43
# hash(o::CosIndirectObjectRef, h::UInt=zero(UInt)) = hash(o.val, h)
50
44
# isequal(r1::CosIndirectObjectRef, r2::CosIndirectObjectRef) = isequal(r1.val, r2.val)
51
45
57
51
58
52
get (o:: CosIndirectObject ) = get (o. obj)
59
53
60
- showref (io:: IO , o:: CosIndirectObject ) = @printf io " %d %d R" o. num o. gen
61
-
62
- showref (io:: IO , o:: CosObject )= show (io, o)
63
-
64
- function show (io:: IO , o:: CosIndirectObject )
65
- str = @sprintf " %d %d obj\n " o. num o. gen
66
- print (io, str)
67
- show (io, o. obj)
68
- end
69
-
70
54
@compat struct CosName <: CosObject
71
55
val:: Symbol
72
56
CosName (str:: String )= new (Symbol (" CosName_" ,str))
73
57
end
74
58
75
- function show (io:: IO , o:: CosName )
76
- val = String (o. val)
77
- val = split (val,' _' )[2 ]
78
- str = @sprintf " /%s" val
79
- print (io, str)
80
- end
81
-
82
59
@compat struct CosXString <: CosString
83
60
val:: Vector{UInt8}
84
61
CosXString (arr:: Vector{UInt8} )= new (arr)
85
62
end
86
63
87
- function show (io:: IO , o:: CosXString )
88
- str = @sprintf " %s" " <" * String (copy (o. val))* " >"
89
- print (io, str)
90
- end
91
-
92
64
Base. convert (:: Type{Vector{UInt8}} , xstr:: CosXString )=
93
65
(xstr. val |> String |> hex2bytes)
94
66
103
75
104
76
CosLiteralString (str:: AbstractString )= CosLiteralString (transcode (UInt8,str))
105
77
106
- function show (io:: IO , o:: CosLiteralString )
107
- str = @sprintf " %s" " (" * String (copy (o. val))* " )"
108
- print (io, str)
109
- end
110
-
111
78
Base. convert (:: Type{Vector{UInt8}} , str:: CosLiteralString )= copy (str. val)
112
79
113
80
Base. convert (:: Type{String} , str:: CosLiteralString )=
@@ -125,15 +92,6 @@ Base.convert(::Type{String}, str::CosLiteralString)=
125
92
CosArray ()= new (Array {CosObject,1} ())
126
93
end
127
94
128
- function show (io:: IO , o:: CosArray )
129
- print (io, ' [' )
130
- for obj in o. val
131
- showref (io, obj)
132
- print (io, ' ' )
133
- end
134
- print (io, ' ]' )
135
- end
136
-
137
95
get (o:: CosArray , isNative= false )= isNative ? map ((x)-> get (x),o. val) : o. val
138
96
length (o:: CosArray )= length (o. val)
139
97
@@ -146,18 +104,6 @@ get(dict::CosDict, name::CosName)=get(dict.val,name,CosNull)
146
104
147
105
get (o:: CosIndirectObject{CosDict} , name:: CosName ) = get (o. obj, name)
148
106
149
- function show (io:: IO , o:: CosDict )
150
- print (io, " <<\n " )
151
- for key in keys (o. val)
152
- print (io, " \t " )
153
- show (io, key)
154
- print (io, " \t " )
155
- showref (io, get (o,key))
156
- println (io, " " )
157
- end
158
- print (io, " >>" )
159
- end
160
-
161
107
"""
162
108
Set the value to object. If the object is CosNull the key is deleted.
163
109
"""
@@ -179,11 +125,6 @@ set!(o::CosIndirectObject{CosDict}, name::CosName, obj::CosObject) =
179
125
CosStream (d:: CosDict ,isInternal:: Bool = true )= new (d,isInternal)
180
126
end
181
127
182
- function show (io:: IO , stm:: CosStream )
183
- show (io, stm. extent);
184
- print (io, " stream\n ...\n endstream\n " )
185
- end
186
-
187
128
get (stm:: CosStream , name:: CosName ) = get (stm. extent, name)
188
129
189
130
get (o:: CosIndirectObject{CosStream} , name:: CosName ) = get (o. obj,name)
@@ -220,8 +161,6 @@ get(stm::CosStream) = decode(stm)
220
161
end
221
162
end
222
163
223
- show (io:: IO , os:: CosObjectStream ) = show (io, os. stm)
224
-
225
164
get (os:: CosObjectStream , name:: CosName ) = get (os. stm, name)
226
165
227
166
get (os:: CosIndirectObject{CosObjectStream} , name:: CosName ) = get (os. obj,name)
@@ -253,3 +192,50 @@ set!(os::CosIndirectObject{CosXRefStream}, name::CosName, obj::CosObject)=
253
192
set! (os. obj,name,obj)
254
193
255
194
get (os:: CosXRefStream ) = get (os. stm)
195
+
196
+ # All show methods
197
+
198
+ show (io:: IO , o:: CosObject ) = print (io, o. val)
199
+
200
+ showref (io:: IO , o:: CosObject ) = show (io, o)
201
+
202
+ show (io:: IO , o:: CosNullType ) = print (io, " null" )
203
+
204
+ show (io:: IO , o:: CosName ) = @printf io " /%s" split (String (o. val),' _' )[2 ]
205
+
206
+ show (io:: IO , o:: CosXString ) = @printf " %s" " <" * String (copy (o. val))* " >"
207
+
208
+ show (io:: IO , o:: CosLiteralString ) = @printf " %s" " (" * String (copy (o. val))* " )"
209
+
210
+ function show (io:: IO , o:: CosArray )
211
+ print (io, ' [' )
212
+ for obj in o. val
213
+ showref (io, obj)
214
+ print (io, ' ' )
215
+ end
216
+ print (io, ' ]' )
217
+ end
218
+
219
+ function show (io:: IO , o:: CosDict )
220
+ print (io, " <<\n " )
221
+ map (keys (o. val)) do key
222
+ print (io, ' \t ' )
223
+ show (io, key)
224
+ print (io, ' \t ' )
225
+ showref (io, get (o, key))
226
+ println (io, " " )
227
+ end
228
+ print (io, " >>" )
229
+ end
230
+
231
+ show (io:: IO , stm:: CosStream ) =
232
+ (show (io, stm. extent); print (io, " stream\n ...\n endstream\n " ))
233
+
234
+ show (io:: IO , os:: CosObjectStream ) = show (io, os. stm)
235
+
236
+ show (io:: IO , o:: CosIndirectObjectRef ) = @printf io " %d %d R" o. val[1 ] o. val[2 ]
237
+
238
+ showref (io:: IO , o:: CosIndirectObject ) = @printf io " %d %d R" o. num o. gen
239
+
240
+ show (io:: IO , o:: CosIndirectObject ) =
241
+ (@printf io " \n %d %d obj\n " o. num o. gen; show (io, o. obj); println (io, " \n endobj\n " ))
0 commit comments