Files
MapLibreParticleLab/platform/darwin/src/NSData+MGLAdditions.mm
Fredrik Karlsson 546469459f [ios] #3979 compress telemetry events (#5490)
* [ios] #3979 wip gzip telemetry events

* [ios] expose compression from core instead of adding a new dependency

* [ios] #3979 Exposed decompress from mbgl and added a test case

* [ios] #3979 cleanup

* [ios] #3979 cleaned up test case

* [ios] #3979 cleanup

* [ios] #3979 gzip -> deflate
2016-07-05 22:46:04 +02:00

24 lines
671 B
Plaintext

#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