Skip to content

Commit a0a6bab

Browse files
committed
- CLDEiOSParser
1 parent 5221e15 commit a0a6bab

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

cldeparser-ios/cldeparser-ios/CLDEiOSParser.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
//
88

99
#import <Foundation/Foundation.h>
10-
#include <memory>
1110

1211
struct Impl;
1312

1413
@interface CLDEiOSParser : NSObject {
15-
std::unique_ptr<Impl> _uptrImpl;
14+
struct Impl * _ptrImpl;
1615
}
1716

17+
-(void)printJson:(NSString*)jsonString;
18+
1819
@end

cldeparser-ios/cldeparser-ios/CLDEiOSParser.mm

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,24 @@ - (instancetype)init {
5959
self = [super init];
6060

6161
if(self){
62-
_uptrImpl.reset(new Impl());
62+
_ptrImpl = new Impl();
6363
}
6464

6565
return self;
6666
}
6767

68+
- (void)printJson:(NSString *)jsonString {
69+
try {
70+
auto sptrJsonEntity = _ptrImpl->Parse(std::string([jsonString UTF8String]));
71+
auto json = sptrJsonEntity->CopyToString();
72+
NSLog(@"%s", json.c_str());
73+
} catch (CLDEParser::Exceptions::Exception& ex) {
74+
NSLog(@"%s", ex.what());
75+
}
76+
}
77+
78+
- (void)dealloc {
79+
if(_ptrImpl != nullptr && _ptrImpl != NULL) delete _ptrImpl;
80+
}
81+
6882
@end

0 commit comments

Comments
 (0)