SecDbBackupBagIdentity.m
  1  // This file was automatically generated by protocompiler
  2  // DO NOT EDIT!
  3  // Compiled from SecDbBackupRecoverySet.proto
  4  
  5  #import "SecDbBackupBagIdentity.h"
  6  #import <ProtocolBuffer/PBConstants.h>
  7  #import <ProtocolBuffer/PBHashUtil.h>
  8  #import <ProtocolBuffer/PBDataReader.h>
  9  
 10  #if !__has_feature(objc_arc)
 11  # error This generated file depends on ARC but it is not enabled; turn on ARC, or use 'objc_use_arc' option to generate non-ARC code.
 12  #endif
 13  
 14  @implementation SecDbBackupBagIdentity
 15  
 16  - (BOOL)hasBaguuid
 17  {
 18      return _baguuid != nil;
 19  }
 20  @synthesize baguuid = _baguuid;
 21  - (BOOL)hasBaghash
 22  {
 23      return _baghash != nil;
 24  }
 25  @synthesize baghash = _baghash;
 26  
 27  - (NSString *)description
 28  {
 29      return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
 30  }
 31  
 32  - (NSDictionary *)dictionaryRepresentation
 33  {
 34      NSMutableDictionary *dict = [NSMutableDictionary dictionary];
 35      if (self->_baguuid)
 36      {
 37          [dict setObject:self->_baguuid forKey:@"baguuid"];
 38      }
 39      if (self->_baghash)
 40      {
 41          [dict setObject:self->_baghash forKey:@"baghash"];
 42      }
 43      return dict;
 44  }
 45  
 46  BOOL SecDbBackupBagIdentityReadFrom(__unsafe_unretained SecDbBackupBagIdentity *self, __unsafe_unretained PBDataReader *reader) {
 47      while (PBReaderHasMoreData(reader)) {
 48          uint32_t tag = 0;
 49          uint8_t aType = 0;
 50  
 51          PBReaderReadTag32AndType(reader, &tag, &aType);
 52  
 53          if (PBReaderHasError(reader))
 54              break;
 55  
 56          if (aType == TYPE_END_GROUP) {
 57              break;
 58          }
 59  
 60          switch (tag) {
 61  
 62              case 1 /* baguuid */:
 63              {
 64                  NSData *new_baguuid = PBReaderReadData(reader);
 65                  self->_baguuid = new_baguuid;
 66              }
 67              break;
 68              case 2 /* baghash */:
 69              {
 70                  NSData *new_baghash = PBReaderReadData(reader);
 71                  self->_baghash = new_baghash;
 72              }
 73              break;
 74              default:
 75                  if (!PBReaderSkipValueWithTag(reader, tag, aType))
 76                      return NO;
 77                  break;
 78          }
 79      }
 80      return !PBReaderHasError(reader);
 81  }
 82  
 83  - (BOOL)readFrom:(PBDataReader *)reader
 84  {
 85      return SecDbBackupBagIdentityReadFrom(self, reader);
 86  }
 87  - (void)writeTo:(PBDataWriter *)writer
 88  {
 89      /* baguuid */
 90      {
 91          if (self->_baguuid)
 92          {
 93              PBDataWriterWriteDataField(writer, self->_baguuid, 1);
 94          }
 95      }
 96      /* baghash */
 97      {
 98          if (self->_baghash)
 99          {
100              PBDataWriterWriteDataField(writer, self->_baghash, 2);
101          }
102      }
103  }
104  
105  - (void)copyTo:(SecDbBackupBagIdentity *)other
106  {
107      if (_baguuid)
108      {
109          other.baguuid = _baguuid;
110      }
111      if (_baghash)
112      {
113          other.baghash = _baghash;
114      }
115  }
116  
117  - (id)copyWithZone:(NSZone *)zone
118  {
119      SecDbBackupBagIdentity *copy = [[[self class] allocWithZone:zone] init];
120      copy->_baguuid = [_baguuid copyWithZone:zone];
121      copy->_baghash = [_baghash copyWithZone:zone];
122      return copy;
123  }
124  
125  - (BOOL)isEqual:(id)object
126  {
127      SecDbBackupBagIdentity *other = (SecDbBackupBagIdentity *)object;
128      return [other isMemberOfClass:[self class]]
129      &&
130      ((!self->_baguuid && !other->_baguuid) || [self->_baguuid isEqual:other->_baguuid])
131      &&
132      ((!self->_baghash && !other->_baghash) || [self->_baghash isEqual:other->_baghash])
133      ;
134  }
135  
136  - (NSUInteger)hash
137  {
138      return 0
139      ^
140      [self->_baguuid hash]
141      ^
142      [self->_baghash hash]
143      ;
144  }
145  
146  - (void)mergeFrom:(SecDbBackupBagIdentity *)other
147  {
148      if (other->_baguuid)
149      {
150          [self setBaguuid:other->_baguuid];
151      }
152      if (other->_baghash)
153      {
154          [self setBaghash:other->_baghash];
155      }
156  }
157  
158  @end
159