summaryrefslogtreecommitdiff
path: root/platform/darwin/src/NSData+MGLAdditions.mm
blob: 97c3bb4a26cc1a2c7ba810db78daefb1efff4083 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#import "NSData+MGLAdditions.h"

#include <mbgl/util/compression.hpp>

@implementation NSData (MGLAdditions)

- (NSData *)mgl_compressedData
{
    std::string string(static_cast<const char*>(self.bytes), self.length);
    std::string compressed_string = mbgl::util::compress(string);

    return [NSData dataWithBytes:&compressed_string[0] length:compressed_string.length()];
}

- (NSData *)mgl_decompressedData
{
    std::string string(static_cast<const char*>(self.bytes), self.length);
    std::string decompressed_string = mbgl::util::decompress(string);

    return [NSData dataWithBytes:&decompressed_string[0] length:decompressed_string.length()];
}

@end