SECC2MPError.m   [plain text]

// This file was automatically generated by protocompiler
// DO NOT EDIT!
// Compiled from C2Metric.proto

#import "SECC2MPError.h"
#import <ProtocolBuffer/PBConstants.h>
#import <ProtocolBuffer/PBHashUtil.h>
#import <ProtocolBuffer/PBDataReader.h>

#import "SECC2MPError.h"

#if !__has_feature(objc_arc)
# 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.
#endif

@implementation SECC2MPError

- (BOOL)hasErrorDomain
{
return _errorDomain != nil;
}
@synthesize errorDomain = _errorDomain;
@synthesize errorCode = _errorCode;
- (void)setErrorCode:(int64_t)v
{
_has.errorCode = YES;
_errorCode = v;
}
- (void)setHasErrorCode:(BOOL)f
{
_has.errorCode = f;
}
- (BOOL)hasErrorCode
{
return _has.errorCode;
}
- (BOOL)hasErrorDescription
{
return _errorDescription != nil;
}
@synthesize errorDescription = _errorDescription;
- (BOOL)hasUnderlyingError
{
return _underlyingError != nil;
}
@synthesize underlyingError = _underlyingError;

- (NSString *)description
{
return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
}

- (NSDictionary *)dictionaryRepresentation
{
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
if (self->_errorDomain)
{
[dict setObject:self->_errorDomain forKey:@"error_domain"];
}
if (self->_has.errorCode)
{
[dict setObject:[NSNumber numberWithLongLong:self->_errorCode] forKey:@"error_code"];
}
if (self->_errorDescription)
{
[dict setObject:self->_errorDescription forKey:@"error_description"];
}
if (self->_underlyingError)
{
[dict setObject:[_underlyingError dictionaryRepresentation] forKey:@"underlying_error"];
}
return dict;
}

BOOL SECC2MPErrorReadFrom(__unsafe_unretained SECC2MPError *self, __unsafe_unretained PBDataReader *reader) {
while (PBReaderHasMoreData(reader)) {
uint32_t tag = 0;
uint8_t aType = 0;

PBReaderReadTag32AndType(reader, &tag, &aType);

if (PBReaderHasError(reader))
break;

if (aType == TYPE_END_GROUP) {
break;
}

switch (tag) {

case 1 /* errorDomain */:
{
NSString *new_errorDomain = PBReaderReadString(reader);
self->_errorDomain = new_errorDomain;
}
break;
case 2 /* errorCode */:
{
self->_has.errorCode = YES;
self->_errorCode = PBReaderReadInt64(reader);
}
break;
case 3 /* errorDescription */:
{
NSString *new_errorDescription = PBReaderReadString(reader);
self->_errorDescription = new_errorDescription;
}
break;
case 4 /* underlyingError */:
{
SECC2MPError *new_underlyingError = [[SECC2MPError alloc] init];
self->_underlyingError = new_underlyingError;
PBDataReaderMark mark_underlyingError;
BOOL markError = !PBReaderPlaceMark(reader, &mark_underlyingError);
if (markError)
{
return NO;
}
BOOL inError = !SECC2MPErrorReadFrom(new_underlyingError, reader);
if (inError)
{
return NO;
}
PBReaderRecallMark(reader, &mark_underlyingError);
}
break;
default:
if (!PBReaderSkipValueWithTag(reader, tag, aType))
return NO;
break;
}
}
return !PBReaderHasError(reader);
}

- (BOOL)readFrom:(PBDataReader *)reader
{
return SECC2MPErrorReadFrom(self, reader);
}
- (void)writeTo:(PBDataWriter *)writer
{
/* errorDomain */
{
if (self->_errorDomain)
{
PBDataWriterWriteStringField(writer, self->_errorDomain, 1);
}
}
/* errorCode */
{
if (self->_has.errorCode)
{
PBDataWriterWriteInt64Field(writer, self->_errorCode, 2);
}
}
/* errorDescription */
{
if (self->_errorDescription)
{
PBDataWriterWriteStringField(writer, self->_errorDescription, 3);
}
}
/* underlyingError */
{
if (self->_underlyingError != nil)
{
PBDataWriterWriteSubmessage(writer, self->_underlyingError, 4);
}
}
}

- (void)copyTo:(SECC2MPError *)other
{
if (_errorDomain)
{
other.errorDomain = _errorDomain;
}
if (self->_has.errorCode)
{
other->_errorCode = _errorCode;
other->_has.errorCode = YES;
}
if (_errorDescription)
{
other.errorDescription = _errorDescription;
}
if (_underlyingError)
{
other.underlyingError = _underlyingError;
}
}

- (id)copyWithZone:(NSZone *)zone
{
SECC2MPError *copy = [[[self class] allocWithZone:zone] init];
copy->_errorDomain = [_errorDomain copyWithZone:zone];
if (self->_has.errorCode)
{
copy->_errorCode = _errorCode;
copy->_has.errorCode = YES;
}
copy->_errorDescription = [_errorDescription copyWithZone:zone];
copy->_underlyingError = [_underlyingError copyWithZone:zone];
return copy;
}

- (BOOL)isEqual:(id)object
{
SECC2MPError *other = (SECC2MPError *)object;
return [other isMemberOfClass:[self class]]
&&
((!self->_errorDomain && !other->_errorDomain) || [self->_errorDomain isEqual:other->_errorDomain])
&&
((self->_has.errorCode && other->_has.errorCode && self->_errorCode == other->_errorCode) || (!self->_has.errorCode && !other->_has.errorCode))
&&
((!self->_errorDescription && !other->_errorDescription) || [self->_errorDescription isEqual:other->_errorDescription])
&&
((!self->_underlyingError && !other->_underlyingError) || [self->_underlyingError isEqual:other->_underlyingError])
;
}

- (NSUInteger)hash
{
return 0
^
[self->_errorDomain hash]
^
(self->_has.errorCode ? PBHashInt((NSUInteger)self->_errorCode) : 0)
^
[self->_errorDescription hash]
^
[self->_underlyingError hash]
;
}

- (void)mergeFrom:(SECC2MPError *)other
{
if (other->_errorDomain)
{
[self setErrorDomain:other->_errorDomain];
}
if (other->_has.errorCode)
{
self->_errorCode = other->_errorCode;
self->_has.errorCode = YES;
}
if (other->_errorDescription)
{
[self setErrorDescription:other->_errorDescription];
}
if (self->_underlyingError && other->_underlyingError)
{
[self->_underlyingError mergeFrom:other->_underlyingError];
}
else if (!self->_underlyingError && other->_underlyingError)
{
[self setUnderlyingError:other->_underlyingError];
}
}

@end