/usr/local/include/OpenEXR/ImfHeader.h
Line | Count | Source |
1 | | // |
2 | | // SPDX-License-Identifier: BSD-3-Clause |
3 | | // Copyright (c) Contributors to the OpenEXR Project. |
4 | | // |
5 | | |
6 | | #ifndef INCLUDED_IMF_HEADER_H |
7 | | #define INCLUDED_IMF_HEADER_H |
8 | | |
9 | | //----------------------------------------------------------------------------- |
10 | | // |
11 | | // class Header |
12 | | // |
13 | | //----------------------------------------------------------------------------- |
14 | | |
15 | | #include "ImfForward.h" |
16 | | |
17 | | #include "IexBaseExc.h" |
18 | | #include "ImfCompression.h" |
19 | | #include "ImfLineOrder.h" |
20 | | #include "ImfName.h" |
21 | | #include "ImfTileDescription.h" |
22 | | |
23 | | #include "ImfAttribute.h" |
24 | | |
25 | | #include <Imath/ImathBox.h> |
26 | | #include <Imath/ImathVec.h> |
27 | | |
28 | | #include <cstdint> |
29 | | #include <iosfwd> |
30 | | #include <map> |
31 | | #include <string> |
32 | | |
33 | | OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
34 | | |
35 | | using std::string; |
36 | | |
37 | | class IMF_EXPORT_TYPE Header |
38 | | { |
39 | | public: |
40 | | //---------------------------------------------------------------- |
41 | | // Default constructor -- the display window and the data window |
42 | | // are both set to Box2i (V2i (0, 0), V2i (width-1, height-1). |
43 | | //---------------------------------------------------------------- |
44 | | |
45 | | IMF_EXPORT |
46 | | Header ( |
47 | | int width = 64, |
48 | | int height = 64, |
49 | | float pixelAspectRatio = 1, |
50 | | const IMATH_NAMESPACE::V2f& screenWindowCenter = |
51 | | IMATH_NAMESPACE::V2f (0, 0), |
52 | | float screenWindowWidth = 1, |
53 | | LineOrder lineOrder = INCREASING_Y, |
54 | | Compression = ZIP_COMPRESSION); |
55 | | |
56 | | //-------------------------------------------------------------------- |
57 | | // Constructor -- the data window is specified explicitly; the display |
58 | | // window is set to Box2i (V2i (0, 0), V2i (width-1, height-1). |
59 | | //-------------------------------------------------------------------- |
60 | | |
61 | | IMF_EXPORT |
62 | | Header ( |
63 | | int width, |
64 | | int height, |
65 | | const IMATH_NAMESPACE::Box2i& dataWindow, |
66 | | float pixelAspectRatio = 1, |
67 | | const IMATH_NAMESPACE::V2f& screenWindowCenter = |
68 | | IMATH_NAMESPACE::V2f (0, 0), |
69 | | float screenWindowWidth = 1, |
70 | | LineOrder lineOrder = INCREASING_Y, |
71 | | Compression = ZIP_COMPRESSION); |
72 | | |
73 | | //---------------------------------------------------------- |
74 | | // Constructor -- the display window and the data window are |
75 | | // both specified explicitly. |
76 | | //---------------------------------------------------------- |
77 | | |
78 | | IMF_EXPORT |
79 | | Header ( |
80 | | const IMATH_NAMESPACE::Box2i& displayWindow, |
81 | | const IMATH_NAMESPACE::Box2i& dataWindow, |
82 | | float pixelAspectRatio = 1, |
83 | | const IMATH_NAMESPACE::V2f& screenWindowCenter = |
84 | | IMATH_NAMESPACE::V2f (0, 0), |
85 | | float screenWindowWidth = 1, |
86 | | LineOrder lineOrder = INCREASING_Y, |
87 | | Compression = ZIP_COMPRESSION); |
88 | | |
89 | | //----------------- |
90 | | // Copy constructor |
91 | | //----------------- |
92 | | |
93 | | IMF_EXPORT |
94 | | Header (const Header& other); |
95 | | IMF_EXPORT |
96 | | Header (Header&& other); |
97 | | |
98 | | //----------- |
99 | | // Destructor |
100 | | //----------- |
101 | | |
102 | | IMF_EXPORT |
103 | | ~Header (); |
104 | | |
105 | | //----------- |
106 | | // Assignment |
107 | | //----------- |
108 | | |
109 | | IMF_EXPORT |
110 | | Header& operator= (const Header& other); |
111 | | IMF_EXPORT |
112 | | Header& operator= (Header&& other); |
113 | | |
114 | | //--------------------------------------------------------------- |
115 | | // Add an attribute: |
116 | | // |
117 | | // insert(n,attr) If no attribute with name n exists, a new |
118 | | // attribute with name n, and the same type as |
119 | | // attr, is added, and the value of attr is |
120 | | // copied into the new attribute. |
121 | | // |
122 | | // If an attribute with name n exists, and its |
123 | | // type is the same as attr, the value of attr |
124 | | // is copied into this attribute. |
125 | | // |
126 | | // If an attribute with name n exists, and its |
127 | | // type is different from attr, an IEX_NAMESPACE::TypeExc |
128 | | // is thrown. |
129 | | // |
130 | | //--------------------------------------------------------------- |
131 | | |
132 | | IMF_EXPORT |
133 | | void insert (const char name[], const Attribute& attribute); |
134 | | |
135 | | IMF_EXPORT |
136 | | void insert (const std::string& name, const Attribute& attribute); |
137 | | |
138 | | //--------------------------------------------------------------- |
139 | | // Remove an attribute: |
140 | | // |
141 | | // remove(n) If an attribute with name n exists, then it |
142 | | // is removed from the map of present attributes. |
143 | | // |
144 | | // If no attribute with name n exists, then this |
145 | | // functions becomes a 'no-op' |
146 | | // |
147 | | //--------------------------------------------------------------- |
148 | | |
149 | | IMF_EXPORT |
150 | | void erase (const char name[]); |
151 | | IMF_EXPORT |
152 | | void erase (const std::string& name); |
153 | | |
154 | | //------------------------------------------------------------------ |
155 | | // Access to existing attributes: |
156 | | // |
157 | | // [n] Returns a reference to the attribute |
158 | | // with name n. If no attribute with |
159 | | // name n exists, an IEX_NAMESPACE::ArgExc is thrown. |
160 | | // |
161 | | // typedAttribute<T>(n) Returns a reference to the attribute |
162 | | // with name n and type T. If no attribute |
163 | | // with name n exists, an IEX_NAMESPACE::ArgExc is |
164 | | // thrown. If an attribute with name n |
165 | | // exists, but its type is not T, an |
166 | | // IEX_NAMESPACE::TypeExc is thrown. |
167 | | // |
168 | | // findTypedAttribute<T>(n) Returns a pointer to the attribute with |
169 | | // name n and type T, or 0 if no attribute |
170 | | // with name n and type T exists. |
171 | | // |
172 | | //------------------------------------------------------------------ |
173 | | |
174 | | IMF_EXPORT |
175 | | Attribute& operator[] (const char name[]); |
176 | | IMF_EXPORT |
177 | | const Attribute& operator[] (const char name[]) const; |
178 | | |
179 | | IMF_EXPORT |
180 | | Attribute& operator[] (const std::string& name); |
181 | | IMF_EXPORT |
182 | | const Attribute& operator[] (const std::string& name) const; |
183 | | |
184 | | template <class T> T& typedAttribute (const char name[]); |
185 | | template <class T> const T& typedAttribute (const char name[]) const; |
186 | | |
187 | | template <class T> T& typedAttribute (const std::string& name); |
188 | | template <class T> const T& typedAttribute (const std::string& name) const; |
189 | | |
190 | | template <class T> T* findTypedAttribute (const char name[]); |
191 | | template <class T> const T* findTypedAttribute (const char name[]) const; |
192 | | |
193 | | template <class T> T* findTypedAttribute (const std::string& name); |
194 | | template <class T> |
195 | | const T* findTypedAttribute (const std::string& name) const; |
196 | | |
197 | | //--------------------------------------------- |
198 | | // Iterator-style access to existing attributes |
199 | | //--------------------------------------------- |
200 | | |
201 | | typedef std::map<Name, Attribute*> AttributeMap; |
202 | | |
203 | | class Iterator; |
204 | | class ConstIterator; |
205 | | |
206 | | IMF_EXPORT |
207 | | Iterator begin (); |
208 | | IMF_EXPORT |
209 | | ConstIterator begin () const; |
210 | | |
211 | | IMF_EXPORT |
212 | | Iterator end (); |
213 | | IMF_EXPORT |
214 | | ConstIterator end () const; |
215 | | |
216 | | IMF_EXPORT |
217 | | Iterator find (const char name[]); |
218 | | IMF_EXPORT |
219 | | ConstIterator find (const char name[]) const; |
220 | | |
221 | | IMF_EXPORT |
222 | | Iterator find (const std::string& name); |
223 | | IMF_EXPORT |
224 | | ConstIterator find (const std::string& name) const; |
225 | | |
226 | | //-------------------------------- |
227 | | // Access to predefined attributes |
228 | | //-------------------------------- |
229 | | |
230 | | IMF_EXPORT |
231 | | IMATH_NAMESPACE::Box2i& displayWindow (); |
232 | | IMF_EXPORT |
233 | | const IMATH_NAMESPACE::Box2i& displayWindow () const; |
234 | | |
235 | | IMF_EXPORT |
236 | | IMATH_NAMESPACE::Box2i& dataWindow (); |
237 | | IMF_EXPORT |
238 | | const IMATH_NAMESPACE::Box2i& dataWindow () const; |
239 | | |
240 | | IMF_EXPORT |
241 | | float& pixelAspectRatio (); |
242 | | IMF_EXPORT |
243 | | const float& pixelAspectRatio () const; |
244 | | |
245 | | IMF_EXPORT |
246 | | IMATH_NAMESPACE::V2f& screenWindowCenter (); |
247 | | IMF_EXPORT |
248 | | const IMATH_NAMESPACE::V2f& screenWindowCenter () const; |
249 | | |
250 | | IMF_EXPORT |
251 | | float& screenWindowWidth (); |
252 | | IMF_EXPORT |
253 | | const float& screenWindowWidth () const; |
254 | | |
255 | | IMF_EXPORT |
256 | | ChannelList& channels (); |
257 | | IMF_EXPORT |
258 | | const ChannelList& channels () const; |
259 | | |
260 | | IMF_EXPORT |
261 | | LineOrder& lineOrder (); |
262 | | IMF_EXPORT |
263 | | const LineOrder& lineOrder () const; |
264 | | |
265 | | IMF_EXPORT |
266 | | Compression& compression (); |
267 | | IMF_EXPORT |
268 | | const Compression& compression () const; |
269 | | |
270 | | //----------------------------------------------------- |
271 | | // The header object allows one to store a compression level to be |
272 | | // used when writing a file. |
273 | | // |
274 | | // NB: These are NOT attributes, and will not be written to the |
275 | | // file, but are instead ephemeral settings to be used for this |
276 | | // instance of the header object. |
277 | | // |
278 | | // ----------------------------------------------------- |
279 | | IMF_EXPORT |
280 | | void resetDefaultCompressionLevels (); |
281 | | IMF_EXPORT |
282 | | int& zipCompressionLevel (); |
283 | | IMF_EXPORT |
284 | | int zipCompressionLevel () const; |
285 | | IMF_EXPORT |
286 | | float& dwaCompressionLevel (); |
287 | | IMF_EXPORT |
288 | | float dwaCompressionLevel () const; |
289 | | IMF_EXPORT |
290 | | float& lossyHTJ2KQuality (); |
291 | | IMF_EXPORT |
292 | | float lossyHTJ2KQuality () const; |
293 | | // Valid levels are 1 through 22 (libzstd range). Values outside |
294 | | // that range are clamped. The library default is 5. |
295 | | IMF_EXPORT |
296 | | int& zstdCompressionLevel (); |
297 | | IMF_EXPORT |
298 | | int zstdCompressionLevel () const; |
299 | | IMF_EXPORT |
300 | | |
301 | | //----------------------------------------------------- |
302 | | // Access to required attributes for multipart files |
303 | | // They are optional to non-multipart files and mandatory |
304 | | // for multipart files. |
305 | | //----------------------------------------------------- |
306 | | IMF_EXPORT |
307 | | void setName (const string& name); |
308 | | |
309 | | IMF_EXPORT |
310 | | string& name (); |
311 | | IMF_EXPORT |
312 | | const string& name () const; |
313 | | |
314 | | IMF_EXPORT |
315 | | bool hasName () const; |
316 | | |
317 | | IMF_EXPORT |
318 | | void setType (const string& Type); |
319 | | |
320 | | IMF_EXPORT |
321 | | string& type (); |
322 | | IMF_EXPORT |
323 | | const string& type () const; |
324 | | |
325 | | IMF_EXPORT |
326 | | bool hasType () const; |
327 | | |
328 | | IMF_EXPORT |
329 | | void setVersion (const int version); |
330 | | |
331 | | IMF_EXPORT |
332 | | int& version (); |
333 | | IMF_EXPORT |
334 | | const int& version () const; |
335 | | |
336 | | IMF_EXPORT |
337 | | bool hasVersion () const; |
338 | | |
339 | | // |
340 | | // the chunkCount attribute is set automatically when a file is written. |
341 | | // There is no need to set it manually |
342 | | // |
343 | | IMF_EXPORT |
344 | | void setChunkCount (int chunks); |
345 | | IMF_EXPORT |
346 | | bool hasChunkCount () const; |
347 | | IMF_EXPORT |
348 | | const int& chunkCount () const; |
349 | | IMF_EXPORT |
350 | | int& chunkCount (); |
351 | | |
352 | | // |
353 | | // for multipart files, return whether the file has a view string attribute |
354 | | // (for the deprecated single part multiview format EXR, see ImfMultiView.h) |
355 | | // |
356 | | IMF_EXPORT |
357 | | void setView (const string& view); |
358 | | IMF_EXPORT |
359 | | bool hasView () const; |
360 | | IMF_EXPORT |
361 | | string& view (); |
362 | | IMF_EXPORT |
363 | | const string& view () const; |
364 | | |
365 | | //---------------------------------------------------------------------- |
366 | | // Tile Description: |
367 | | // |
368 | | // The tile description is a TileDescriptionAttribute whose name |
369 | | // is "tiles". The "tiles" attribute must be present in any tiled |
370 | | // image file. When present, it describes various properties of the |
371 | | // tiles that make up the file. |
372 | | // |
373 | | // Convenience functions: |
374 | | // |
375 | | // setTileDescription(td) |
376 | | // calls insert ("tiles", TileDescriptionAttribute (td)) |
377 | | // |
378 | | // tileDescription() |
379 | | // returns typedAttribute<TileDescriptionAttribute>("tiles").value() |
380 | | // |
381 | | // hasTileDescription() |
382 | | // return findTypedAttribute<TileDescriptionAttribute>("tiles") != 0 |
383 | | // |
384 | | //---------------------------------------------------------------------- |
385 | | |
386 | | IMF_EXPORT |
387 | | void setTileDescription (const TileDescription& td); |
388 | | |
389 | | IMF_EXPORT |
390 | | TileDescription& tileDescription (); |
391 | | IMF_EXPORT |
392 | | const TileDescription& tileDescription () const; |
393 | | |
394 | | IMF_EXPORT |
395 | | bool hasTileDescription () const; |
396 | | |
397 | | //---------------------------------------------------------------------- |
398 | | // Preview image: |
399 | | // |
400 | | // The preview image is a PreviewImageAttribute whose name is "preview". |
401 | | // This attribute is special -- while an image file is being written, |
402 | | // the pixels of the preview image can be changed repeatedly by calling |
403 | | // OutputFile::updatePreviewImage(). |
404 | | // |
405 | | // Convenience functions: |
406 | | // |
407 | | // setPreviewImage(p) |
408 | | // calls insert ("preview", PreviewImageAttribute (p)) |
409 | | // |
410 | | // previewImage() |
411 | | // returns typedAttribute<PreviewImageAttribute>("preview").value() |
412 | | // |
413 | | // hasPreviewImage() |
414 | | // return findTypedAttribute<PreviewImageAttribute>("preview") != 0 |
415 | | // |
416 | | //---------------------------------------------------------------------- |
417 | | |
418 | | IMF_EXPORT |
419 | | void setPreviewImage (const PreviewImage& p); |
420 | | |
421 | | IMF_EXPORT |
422 | | PreviewImage& previewImage (); |
423 | | IMF_EXPORT |
424 | | const PreviewImage& previewImage () const; |
425 | | |
426 | | IMF_EXPORT |
427 | | bool hasPreviewImage () const; |
428 | | |
429 | | //------------------------------------------------------------- |
430 | | // Sanity check -- examines the header, and throws an exception |
431 | | // if it finds something wrong (empty display window, negative |
432 | | // pixel aspect ratio, unknown compression scheme etc...) |
433 | | // |
434 | | // set isTiled to true if you are checking a tiled/multi-res |
435 | | // header |
436 | | //------------------------------------------------------------- |
437 | | |
438 | | IMF_EXPORT |
439 | | void sanityCheck (bool isTiled = false, bool isMultipartFile = false) const; |
440 | | |
441 | | //---------------------------------------------------------------- |
442 | | // Maximum image size and maximum tile size: |
443 | | // |
444 | | // sanityCheck() will throw an exception if the width or height of |
445 | | // the data window exceeds the maximum image width or height, or |
446 | | // if the size of a tile exceeds the maximum tile width or height. |
447 | | // |
448 | | // At program startup the maximum image and tile width and height |
449 | | // are set to zero, meaning that width and height are unlimited. |
450 | | // |
451 | | // Limiting image and tile width and height limits how much memory |
452 | | // will be allocated when a file is opened. This can help protect |
453 | | // applications from running out of memory while trying to read |
454 | | // a damaged image file. |
455 | | //---------------------------------------------------------------- |
456 | | |
457 | | IMF_EXPORT |
458 | | static void setMaxImageSize (int maxWidth, int maxHeight); |
459 | | IMF_EXPORT |
460 | | static void setMaxTileSize (int maxWidth, int maxHeight); |
461 | | IMF_EXPORT |
462 | | static void getMaxImageSize (int& maxWidth, int& maxHeight); |
463 | | IMF_EXPORT |
464 | | static void getMaxTileSize (int& maxWidth, int& maxHeight); |
465 | | |
466 | | // |
467 | | // Check if the header reads nothing. |
468 | | // |
469 | | IMF_EXPORT |
470 | | bool readsNothing (); |
471 | | |
472 | | //------------------------------------------------------------------ |
473 | | // Input and output: |
474 | | // |
475 | | // If the header contains a preview image attribute, then writeTo() |
476 | | // returns the position of that attribute in the output stream; this |
477 | | // information is used by OutputFile::updatePreviewImage(). |
478 | | // If the header contains no preview image attribute, then writeTo() |
479 | | // returns 0. |
480 | | //------------------------------------------------------------------ |
481 | | |
482 | | IMF_EXPORT |
483 | | uint64_t writeTo ( |
484 | | OPENEXR_IMF_INTERNAL_NAMESPACE::OStream& os, |
485 | | bool isTiled = false) const; |
486 | | |
487 | | IMF_EXPORT |
488 | | void readFrom (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream& is, int& version); |
489 | | |
490 | | private: |
491 | | AttributeMap _map; |
492 | | |
493 | | bool _readsNothing; |
494 | | }; |
495 | | |
496 | | //---------- |
497 | | // Iterators |
498 | | //---------- |
499 | | |
500 | | class IMF_EXPORT_TYPE Header::Iterator |
501 | | { |
502 | | public: |
503 | | Iterator (); |
504 | | Iterator (const Header::AttributeMap::iterator& i); |
505 | | |
506 | | Iterator& operator++ (); |
507 | | Iterator operator++ (int); |
508 | | |
509 | | const char* name () const; |
510 | | Attribute& attribute () const; |
511 | | |
512 | | private: |
513 | | friend class Header::ConstIterator; |
514 | | |
515 | | Header::AttributeMap::iterator _i; |
516 | | }; |
517 | | |
518 | | class IMF_EXPORT_TYPE Header::ConstIterator |
519 | | { |
520 | | public: |
521 | | ConstIterator (); |
522 | | ConstIterator (const Header::AttributeMap::const_iterator& i); |
523 | | ConstIterator (const Header::Iterator& other); |
524 | | |
525 | | ConstIterator& operator++ (); |
526 | | ConstIterator operator++ (int); |
527 | | |
528 | | const char* name () const; |
529 | | const Attribute& attribute () const; |
530 | | |
531 | | private: |
532 | | friend bool operator== (const ConstIterator&, const ConstIterator&); |
533 | | friend bool operator!= (const ConstIterator&, const ConstIterator&); |
534 | | |
535 | | Header::AttributeMap::const_iterator _i; |
536 | | }; |
537 | | |
538 | | //------------------------------------------------------------------------ |
539 | | // Library initialization: |
540 | | // |
541 | | // In a multithreaded program, staticInitialize() must be called once |
542 | | // during startup, before the program accesses any other functions or |
543 | | // classes in the OpenEXR library. Calling staticInitialize() in this |
544 | | // way avoids races during initialization of the library's global |
545 | | // variables. |
546 | | // |
547 | | // Single-threaded programs are not required to call staticInitialize(); |
548 | | // initialization of the library's global variables happens automatically. |
549 | | // |
550 | | //------------------------------------------------------------------------ |
551 | | |
552 | | IMF_EXPORT void staticInitialize (); |
553 | | |
554 | | //----------------- |
555 | | // Inline Functions |
556 | | //----------------- |
557 | | |
558 | | inline Header::Iterator::Iterator () : _i () |
559 | | { |
560 | | // empty |
561 | | } |
562 | | |
563 | | inline Header::Iterator::Iterator (const Header::AttributeMap::iterator& i) |
564 | | : _i (i) |
565 | | { |
566 | | // empty |
567 | | } |
568 | | |
569 | | inline Header::Iterator& |
570 | | Header::Iterator::operator++ () |
571 | 0 | { |
572 | 0 | ++_i; |
573 | 0 | return *this; |
574 | 0 | } |
575 | | |
576 | | inline Header::Iterator |
577 | | Header::Iterator::operator++ (int) |
578 | 0 | { |
579 | 0 | Iterator tmp = *this; |
580 | 0 | ++_i; |
581 | 0 | return tmp; |
582 | 0 | } |
583 | | |
584 | | inline const char* |
585 | | Header::Iterator::name () const |
586 | 0 | { |
587 | 0 | return *_i->first; |
588 | 0 | } |
589 | | |
590 | | inline Attribute& |
591 | | Header::Iterator::attribute () const |
592 | 0 | { |
593 | 0 | return *_i->second; |
594 | 0 | } |
595 | | |
596 | | inline Header::ConstIterator::ConstIterator () : _i () |
597 | | { |
598 | | // empty |
599 | | } |
600 | | |
601 | | inline Header::ConstIterator::ConstIterator ( |
602 | | const Header::AttributeMap::const_iterator& i) |
603 | | : _i (i) |
604 | | { |
605 | | // empty |
606 | | } |
607 | | |
608 | | inline Header::ConstIterator::ConstIterator (const Header::Iterator& other) |
609 | | : _i (other._i) |
610 | | { |
611 | | // empty |
612 | | } |
613 | | |
614 | | inline Header::ConstIterator& |
615 | | Header::ConstIterator::operator++ () |
616 | | { |
617 | | ++_i; |
618 | | return *this; |
619 | | } |
620 | | |
621 | | inline Header::ConstIterator |
622 | | Header::ConstIterator::operator++ (int) |
623 | 0 | { |
624 | 0 | ConstIterator tmp = *this; |
625 | 0 | ++_i; |
626 | 0 | return tmp; |
627 | 0 | } |
628 | | |
629 | | inline const char* |
630 | | Header::ConstIterator::name () const |
631 | | { |
632 | | return *_i->first; |
633 | | } |
634 | | |
635 | | inline const Attribute& |
636 | | Header::ConstIterator::attribute () const |
637 | | { |
638 | | return *_i->second; |
639 | | } |
640 | | |
641 | | inline bool |
642 | | operator== (const Header::ConstIterator& x, const Header::ConstIterator& y) |
643 | | { |
644 | | return x._i == y._i; |
645 | | } |
646 | | |
647 | | inline bool |
648 | | operator!= (const Header::ConstIterator& x, const Header::ConstIterator& y) |
649 | | { |
650 | | return !(x == y); |
651 | | } |
652 | | |
653 | | //--------------------- |
654 | | // Template definitions |
655 | | //--------------------- |
656 | | |
657 | | template <class T> |
658 | | T& |
659 | | Header::typedAttribute (const char name[]) |
660 | | { |
661 | | Attribute* attr = &(*this)[name]; |
662 | | T* tattr = dynamic_cast<T*> (attr); |
663 | | |
664 | | if (tattr == 0) throw IEX_NAMESPACE::TypeExc ("Unexpected attribute type."); |
665 | | |
666 | | return *tattr; |
667 | | } |
668 | | |
669 | | template <class T> |
670 | | const T& |
671 | | Header::typedAttribute (const char name[]) const |
672 | | { |
673 | | const Attribute* attr = &(*this)[name]; |
674 | | const T* tattr = dynamic_cast<const T*> (attr); |
675 | | |
676 | | if (tattr == 0) throw IEX_NAMESPACE::TypeExc ("Unexpected attribute type."); |
677 | | |
678 | | return *tattr; |
679 | | } |
680 | | |
681 | | template <class T> |
682 | | T& |
683 | | Header::typedAttribute (const std::string& name) |
684 | | { |
685 | | return typedAttribute<T> (name.c_str ()); |
686 | | } |
687 | | |
688 | | template <class T> |
689 | | const T& |
690 | | Header::typedAttribute (const std::string& name) const |
691 | | { |
692 | | return typedAttribute<T> (name.c_str ()); |
693 | | } |
694 | | |
695 | | template <class T> |
696 | | T* |
697 | | Header::findTypedAttribute (const char name[]) |
698 | | { |
699 | | AttributeMap::iterator i = _map.find (name); |
700 | | return (i == _map.end ()) ? 0 : dynamic_cast<T*> (i->second); |
701 | | } |
702 | | |
703 | | template <class T> |
704 | | const T* |
705 | | Header::findTypedAttribute (const char name[]) const |
706 | 72.0k | { |
707 | 72.0k | AttributeMap::const_iterator i = _map.find (name); |
708 | 72.0k | return (i == _map.end ()) ? 0 : dynamic_cast<const T*> (i->second); |
709 | 72.0k | } Imf_3_5::TypedAttribute<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > const* Imf_3_5::Header::findTypedAttribute<Imf_3_5::TypedAttribute<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >(char const*) const Line | Count | Source | 706 | 45.2k | { | 707 | 45.2k | AttributeMap::const_iterator i = _map.find (name); | 708 | 45.2k | return (i == _map.end ()) ? 0 : dynamic_cast<const T*> (i->second); | 709 | 45.2k | } |
Imf_3_5::TypedAttribute<float> const* Imf_3_5::Header::findTypedAttribute<Imf_3_5::TypedAttribute<float> >(char const*) const Line | Count | Source | 706 | 14.1k | { | 707 | 14.1k | AttributeMap::const_iterator i = _map.find (name); | 708 | 14.1k | return (i == _map.end ()) ? 0 : dynamic_cast<const T*> (i->second); | 709 | 14.1k | } |
Imf_3_5::OpaqueAttribute const* Imf_3_5::Header::findTypedAttribute<Imf_3_5::OpaqueAttribute>(char const*) const Line | Count | Source | 706 | 3.47k | { | 707 | 3.47k | AttributeMap::const_iterator i = _map.find (name); | 708 | 3.47k | return (i == _map.end ()) ? 0 : dynamic_cast<const T*> (i->second); | 709 | 3.47k | } |
Imf_3_5::TypedAttribute<Imf_3_5::Chromaticities> const* Imf_3_5::Header::findTypedAttribute<Imf_3_5::TypedAttribute<Imf_3_5::Chromaticities> >(char const*) const Line | Count | Source | 706 | 2.75k | { | 707 | 2.75k | AttributeMap::const_iterator i = _map.find (name); | 708 | 2.75k | return (i == _map.end ()) ? 0 : dynamic_cast<const T*> (i->second); | 709 | 2.75k | } |
Imf_3_5::TypedAttribute<std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > const* Imf_3_5::Header::findTypedAttribute<Imf_3_5::TypedAttribute<std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > >(char const*) const Line | Count | Source | 706 | 6.45k | { | 707 | 6.45k | AttributeMap::const_iterator i = _map.find (name); | 708 | 6.45k | return (i == _map.end ()) ? 0 : dynamic_cast<const T*> (i->second); | 709 | 6.45k | } |
|
710 | | |
711 | | template <class T> |
712 | | T* |
713 | | Header::findTypedAttribute (const std::string& name) |
714 | | { |
715 | | return findTypedAttribute<T> (name.c_str ()); |
716 | | } |
717 | | |
718 | | template <class T> |
719 | | const T* |
720 | | Header::findTypedAttribute (const std::string& name) const |
721 | | { |
722 | | return findTypedAttribute<T> (name.c_str ()); |
723 | | } |
724 | | |
725 | | OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
726 | | |
727 | | #endif |