blob: 0829a4f26faa0b0f8819c2d09ea46c93011401bb [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
2/*
3 * Copyright 2011 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
yangsu@google.com1a2b4c12011-06-24 17:20:50 +00008#ifndef SkStream_NSData_DEFINED
9#define SkStream_NSData_DEFINED
10
11#import <UIKit/UIKit.h>
12#include "SkStream.h"
13
14/** Returns an NSData with a copy of the stream's data. The caller must call
15 retain if it intends to keep the data object beyond the current stack-frame
16 (i.e. internally we're calling [NSData dataWithBytes...]
17 */
18NSData* NSData_dataWithStream(SkStream* stream);
19
20/** Returns an NSData from the named resource (from main bundle).
21 The caller must call retain if it intends to keep the data object beyond
22 the current stack-frame
23 (i.e. internally we're calling [NSData dataWithContentsOfMappedFile...]
24 */
25NSData* NSData_dataFromResource(const char name[], const char suffix[]);
26
27/** Wrap a stream around NSData.
28 */
29class SkStream_NSData : public SkMemoryStream {
30public:
31 SkStream_NSData(NSData* data);
32 virtual ~SkStream_NSData();
33
34 static SkStream_NSData* CreateFromResource(const char name[],
35 const char suffix[]);
36
37private:
38 NSData* fNSData;
39};
40
41#endif