yangsu@google.com | 1a2b4c1 | 2011-06-24 17:20:50 +0000 | [diff] [blame] | 1 | #ifndef SkStream_NSData_DEFINED |
| 2 | #define SkStream_NSData_DEFINED |
| 3 | |
| 4 | #import <UIKit/UIKit.h> |
| 5 | #include "SkStream.h" |
| 6 | |
| 7 | /** Returns an NSData with a copy of the stream's data. The caller must call |
| 8 | retain if it intends to keep the data object beyond the current stack-frame |
| 9 | (i.e. internally we're calling [NSData dataWithBytes...] |
| 10 | */ |
| 11 | NSData* NSData_dataWithStream(SkStream* stream); |
| 12 | |
| 13 | /** Returns an NSData from the named resource (from main bundle). |
| 14 | The caller must call retain if it intends to keep the data object beyond |
| 15 | the current stack-frame |
| 16 | (i.e. internally we're calling [NSData dataWithContentsOfMappedFile...] |
| 17 | */ |
| 18 | NSData* NSData_dataFromResource(const char name[], const char suffix[]); |
| 19 | |
| 20 | /** Wrap a stream around NSData. |
| 21 | */ |
| 22 | class SkStream_NSData : public SkMemoryStream { |
| 23 | public: |
| 24 | SkStream_NSData(NSData* data); |
| 25 | virtual ~SkStream_NSData(); |
| 26 | |
| 27 | static SkStream_NSData* CreateFromResource(const char name[], |
| 28 | const char suffix[]); |
| 29 | |
| 30 | private: |
| 31 | NSData* fNSData; |
| 32 | }; |
| 33 | |
| 34 | #endif |