<commit_before>//
// TS{{_tbi.entityName}}.mm
// {{_project_}}
//

#import "TS{{_tbi.entityName}}.hh"
#import "{{_moduleC_}}Proto.pb.hh"
#import "PBObjc.hh"

@interface TS{{_tbi.entityName}} ()

@property (nonatomic, strong)NSData* protocolData;

@end

@implementation TS{{_tbi.entityName}}

-(instancetype) initWithProtocolData:(NSData*) data {
    return [self initWithData:data];
}
-(instancetype) initWithProtocolObj:(google::protobuf::Message*) pbmsg {
    // c++
    {{_module_}}::P{{_tbi.entityName}}* pbobj = ({{_module_}}::P{{_tbi.entityName}}*)pbmsg;
    //
{% for col in _tbi.columns %}
    if(pbobj->has_{{col.protobuf_name}}()){
        const {{col.cpp_type}} {{col.name}} = pbobj->{{col.protobuf_name}}();
        self.{{col.name}} = [PBObjc {{col.cpp_objc}}:{{col.name}}];
    }
{% endfor %}
    //
{% for col in _tbi.refs %}
{% if col.ref_type == 'repeated' %}
    for(int i=0; i<pbobj->{{col.ref_varName}}_size();i++){
        {{_tbm_[col.ref_obj.name]}}::P{{col.ref_obj.entityName}}* pbref = pbobj->mutable_{{col.ref_varName | lower}}(i);
        [self.{{col.ref_varName}} addObject:[[TS{{col.ref_obj.entityName}} alloc] initWithProtocolObj: pbref]];
    }
{% else %}
    if(pbobj->has_{{col.ref_varName | lower}}()){
        {{_tbm_[col.ref_obj.name]}}::P{{col.ref_obj.entityName}}* pbref = pbobj->mutable_{{col.ref_varName | lower}}();
        self.{{col.ref_varName}} = [[TS{{col.ref_obj.entityName}} alloc] initWithProtocolObj: pbref];
    }
{% endif %}
{% endfor %}
    //
    return self;
} 
-(NSData*) getProtocolData {
    return self.protocolData;
}

-(instancetype) initWithData:(NSData*) data {
    
    if(self = [super init]) {
        // c++
        {{_module_}}::P{{_tbi.entityName}}* pbmsg = [self deserialize:data];
        //
        self = [self initWithProtocolObj:pbmsg];
        // c++->objective C
        self.protocolData = data;
    }
    return self;
}

-(NSMutableDictionary*)asDict{<commit_msg>bootstrap<commit_after>//
// TS{{_tbi.entityName}}.mm
// {{_project_}}
//

#import "TS{{_tbi.entityName}}.hh"
#import "{{_moduleC_}}Proto.pb.hh"
#import "PBObjc.hh"

@interface TS{{_tbi.entityName}} ()

@property (nonatomic, strong)NSData* protocolData;

@end

@implementation TS{{_tbi.entityName}}

-(instancetype) initWithProtocolData:(NSData*) data {
    return [self initWithData:data];
}
-(instancetype) initWithProtocolObj:(google::protobuf::Message*) pbmsg {
    // c++
    if(self = [super init]) {
        // c++
        {{_module_}}::P{{_tbi.entityName}}* pbobj = ({{_module_}}::P{{_tbi.entityName}}*)pbmsg;
        //
        [self initValues:pbobj];
    }
    //
    return self;
} 
-(NSData*) getProtocolData {
    return self.protocolData;
}
-(void)initValues:({{_module_}}::P{{_tbi.entityName}}*) pbobj{
{% for col in _tbi.columns %}
    if(pbobj->has_{{col.protobuf_name}}()){
        const {{col.cpp_type}} {{col.name}} = pbobj->{{col.protobuf_name}}();
        self.{{col.name}} = [PBObjc {{col.cpp_objc}}:{{col.name}}];
    }
{% endfor %}
    //
{% for col in _tbi.refs %}
{% if col.ref_type == 'repeated' %}
    for(int i=0; i<pbobj->{{col.ref_varName}}_size();i++){
        {{_tbm_[col.ref_obj.name]}}::P{{col.ref_obj.entityName}}* pbref = pbobj->mutable_{{col.ref_varName | lower}}(i);
        [self.{{col.ref_varName}} addObject:[[TS{{col.ref_obj.entityName}} alloc] initWithProtocolObj: pbref]];
    }
{% else %}
    if(pbobj->has_{{col.ref_varName | lower}}()){
        {{_tbm_[col.ref_obj.name]}}::P{{col.ref_obj.entityName}}* pbref = pbobj->mutable_{{col.ref_varName | lower}}();
        self.{{col.ref_varName}} = [[TS{{col.ref_obj.entityName}} alloc] initWithProtocolObj: pbref];
    }
{% endif %}
{% endfor %}
}
-(instancetype) initWithData:(NSData*) data {
    
    if(self = [super init]) {
        // c++
        {{_module_}}::P{{_tbi.entityName}}* pbmsg = [self deserialize:data];
        //
        [self initValues:pbmsg];
        // c++->objective C
        self.protocolData = data;
    }
    return self;
}

-(NSMutableDictionary*)asDict{
{'fraction_non_alphanumeric': 0.21602787456445993, 'fraction_numerical': 0.0004977600796416127, 'mean_word_length': 3.6142365097588978, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3616011', 'n_tokens_mistral': 1558, 'n_tokens_neox': 1498, 'n_words': 214}