SVGKSource.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. SVGKSource.h
  3. SVGKSource represents the info about where an SVG image's data came from ... from disk, from URL, from raw string - or anywhere
  4. ----
  5. NOTE: you should avoid instantiating SVGKSource directly; it is better to instantiate one of the subclasses, both because this
  6. allows faster / more direct reading of raw data, and because it preserves the information about "where" the SVG was loaded from.
  7. ----
  8. Once it has been parsed / loaded, that info is NOT PART OF the in-memory SVG any more - if you were to save the file, you could
  9. save it in a different location, with a different SVG Spec, etc.
  10. However, it's useful for debugging (and for optional "save this document in same place it was loaded from / same format"
  11. to store this info at runtime just in case it's needed later.
  12. Also, it helps during parsing to keep track of some document-level information
  13. */
  14. #import <Foundation/Foundation.h>
  15. @interface SVGKSource : NSObject <NSCopying>
  16. @property (nonatomic, strong) NSString* svgLanguageVersion; /**< <svg version=""> */
  17. @property (nonatomic, strong) NSInputStream* stream;
  18. /** If known, the amount of data in bytes contained in this source (e.g. the filesize for a
  19. file, or the Content-Length header for a URL). Otherwise "0" for "unknown" */
  20. @property (nonatomic) uint64_t approximateLengthInBytesOr0;
  21. /** Apple's NSDictionary has major design bugs, it does NOT support OOP programming;
  22. it is implemented on top of a C/C++ basic Strings table, and if you want to put objects
  23. in as keys, you have to generate a unique-but-stable string from each instead */
  24. @property(nonatomic,strong) NSString* keyForAppleDictionaries;
  25. /** This should ONLY be used by subclasses that are implementing NSCopying methods. All other
  26. uses are discouraged / dangerous. If you use this, you MUST manually set self.stream correctly */
  27. - (id) initForCopying;
  28. /**
  29. Subclasses convert their proprietary data into something that implements NSInputStream, which allows the
  30. base class to handle everything else
  31. */
  32. - (id)initWithInputSteam:(NSInputStream*)stream;
  33. - (SVGKSource *)sourceFromRelativePath:(NSString *)path;
  34. @end