mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
Add copy and coder methods.
This commit is contained in:
parent
2d565bb30a
commit
3b546ff753
6 changed files with 281 additions and 2 deletions
|
@ -98,6 +98,7 @@
|
|||
#import <Foundation/NSOperation.h>
|
||||
#import <Foundation/NSOrderedSet.h>
|
||||
#import <Foundation/NSPathUtilities.h>
|
||||
#import <Foundation/NSPersonNameComponents.h>
|
||||
#import <Foundation/NSPointerArray.h>
|
||||
#import <Foundation/NSPointerFunctions.h>
|
||||
#import <Foundation/NSPortCoder.h>
|
||||
|
|
|
@ -69,7 +69,9 @@ typedef NSUInteger NSFileVersionReplacingOptions;
|
|||
- (id<NSCoding>) persistentIdentifier;
|
||||
|
||||
- (BOOL) removeAndReturnError: (NSError **)outError;
|
||||
- (NSURL *) replaceItemAtURL: (NSURL *)url options:(NSFileVersionReplacingOptions)options error:(NSError **)error;
|
||||
- (NSURL *) replaceItemAtURL: (NSURL *)url
|
||||
options: (NSFileVersionReplacingOptions)options
|
||||
error: (NSError **)error;
|
||||
|
||||
@end
|
||||
|
||||
|
|
65
Headers/Foundation/NSPersonNameComponents.h
Normal file
65
Headers/Foundation/NSPersonNameComponents.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
/* Definition of class NSPersonNameComponents
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
|
||||
Implemented by: Gregory Casamento <greg.casamento@gmail.com>
|
||||
Date: Sep 2019
|
||||
Original File by: Daniel Ferreira
|
||||
|
||||
This file is part of the GNUstep Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef __NSPersonNameComponents_h_GNUSTEP_BASE_INCLUDE
|
||||
#define __NSPersonNameComponents_h_GNUSTEP_BASE_INCLUDE
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_7,GS_API_LATEST)
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
@class NSString;
|
||||
|
||||
@interface NSPersonNameComponents : NSObject <NSCopying, NSCoding>
|
||||
{
|
||||
@private
|
||||
NSString *_namePrefix;
|
||||
NSString *_givenName;
|
||||
NSString *_middleName;
|
||||
NSString *_familyName;
|
||||
NSString *_nameSuffix;
|
||||
NSString *_nickname;
|
||||
NSPersonNameComponents *_phoneticRepresentation;
|
||||
}
|
||||
|
||||
- (NSString *) namePrefix;
|
||||
- (void) setNamePrefix: (NSString *)namePrefix;
|
||||
- (NSString *) givenName;
|
||||
- (void) setGivenName: (NSString *)givenName;
|
||||
- (NSString *) middleName;
|
||||
- (void) setMiddleName: (NSString *)middleName;
|
||||
- (NSString *) familyName;
|
||||
- (void) setFamilyName: (NSString *)familyName;
|
||||
- (NSString *) nameSuffix;
|
||||
- (void) setNameSuffix: (NSString *)nameSuffix;
|
||||
- (NSString *) nickname;
|
||||
- (void) setNickname: (NSString *)nickname;
|
||||
|
||||
- (NSPersonNameComponents *) phoneticRepresentation;
|
||||
- (void) setPhoneticRepresentation: (NSPersonNameComponents *)pr;
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -262,6 +262,7 @@ NSOperation.m \
|
|||
NSOrderedSet.m \
|
||||
NSPage.m \
|
||||
NSPathUtilities.m \
|
||||
NSPersonNameComponents.m \
|
||||
NSPipe.m \
|
||||
NSPointerArray.m \
|
||||
NSPointerFunctions.m \
|
||||
|
@ -436,6 +437,7 @@ NSObject.h \
|
|||
NSOperation.h \
|
||||
NSOrderedSet.h \
|
||||
NSPathUtilities.h \
|
||||
NSPersonNameComponents.h \
|
||||
NSPointerArray.h \
|
||||
NSPointerFunctions.h \
|
||||
NSPortCoder.h \
|
||||
|
|
|
@ -72,7 +72,9 @@
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (NSURL *) replaceItemAtURL: (NSURL *)url options:(NSFileVersionReplacingOptions)options error:(NSError **)error
|
||||
- (NSURL *) replaceItemAtURL: (NSURL *)url
|
||||
options: (NSFileVersionReplacingOptions)options
|
||||
error: (NSError **)error
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
|
207
Source/NSPersonNameComponents.m
Normal file
207
Source/NSPersonNameComponents.m
Normal file
|
@ -0,0 +1,207 @@
|
|||
/* Definition of class NSPersonNameComponents
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
|
||||
Implemented by: Gregory Casamento <greg.casamento@gmail.com>
|
||||
Date: Sep 2019
|
||||
Original File by: Daniel Ferreira
|
||||
|
||||
This file is part of the GNUstep Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#import "common.h"
|
||||
#import "Foundation/NSCoder.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSPersonNameComponents.h"
|
||||
|
||||
@implementation NSPersonNameComponents
|
||||
|
||||
- (instancetype) init
|
||||
{
|
||||
if((self = [super init]) != nil)
|
||||
{
|
||||
_namePrefix = nil;
|
||||
_givenName = nil;
|
||||
_middleName = nil;
|
||||
_familyName = nil;
|
||||
_nameSuffix = nil;
|
||||
_nickname = nil;
|
||||
_phoneticRepresentation = nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype) initWithCoder: (NSCoder *)aCoder
|
||||
{
|
||||
if((self = [self init]) != nil)
|
||||
{
|
||||
if([aCoder allowsKeyedCoding])
|
||||
{
|
||||
_namePrefix = [aCoder decodeObjectForKey: @"namePrefix"];
|
||||
_givenName = [aCoder decodeObjectForKey: @"givenName"];
|
||||
_middleName = [aCoder decodeObjectForKey: @"middleName"];
|
||||
_familyName = [aCoder decodeObjectForKey: @"familyName"];
|
||||
_nameSuffix = [aCoder decodeObjectForKey: @"nameSuffix"];
|
||||
_nickname = [aCoder decodeObjectForKey: @"nickname"];
|
||||
_phoneticRepresentation = [aCoder decodeObjectForKey: @"phoneticRepresentation"];
|
||||
}
|
||||
else
|
||||
{
|
||||
_namePrefix = [aCoder decodeObject];
|
||||
_givenName = [aCoder decodeObject];
|
||||
_middleName = [aCoder decodeObject];
|
||||
_familyName = [aCoder decodeObject];
|
||||
_nameSuffix = [aCoder decodeObject];
|
||||
_nickname = [aCoder decodeObject];
|
||||
_phoneticRepresentation = [aCoder decodeObject];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *)aCoder
|
||||
{
|
||||
if([aCoder allowsKeyedCoding])
|
||||
{
|
||||
[aCoder encodeObject: _namePrefix
|
||||
forKey: @"namePrefix"];
|
||||
[aCoder encodeObject: _givenName
|
||||
forKey: @"givenName"];
|
||||
[aCoder encodeObject: _middleName
|
||||
forKey: @"middleName"];
|
||||
[aCoder encodeObject: _familyName
|
||||
forKey: @"familyName"];
|
||||
[aCoder encodeObject: _nameSuffix
|
||||
forKey: @"nameSuffix"];
|
||||
[aCoder encodeObject: _nameSuffix
|
||||
forKey: @"nameSuffix"];
|
||||
[aCoder encodeObject: _phoneticRepresentation
|
||||
forKey: @"phoneticRepresentation"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[aCoder encodeObject: _namePrefix];
|
||||
[aCoder encodeObject: _givenName];
|
||||
[aCoder encodeObject: _middleName];
|
||||
[aCoder encodeObject: _familyName];
|
||||
[aCoder encodeObject: _nameSuffix];
|
||||
[aCoder encodeObject: _nameSuffix];
|
||||
[aCoder encodeObject: _phoneticRepresentation];
|
||||
}
|
||||
}
|
||||
|
||||
- (instancetype) copyWithZone: (NSZone *)zone
|
||||
{
|
||||
NSPersonNameComponents *copy =
|
||||
[[NSPersonNameComponents allocWithZone: zone] init];
|
||||
|
||||
[copy setNamePrefix: [self namePrefix]];
|
||||
[copy setGivenName: [self givenName]];
|
||||
[copy setMiddleName: [self middleName]];
|
||||
[copy setFamilyName: [self familyName]];
|
||||
[copy setNameSuffix: [self nameSuffix]];
|
||||
[copy setNickname: [self nickname]];
|
||||
[copy setPhoneticRepresentation: [self phoneticRepresentation]];
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_namePrefix);
|
||||
RELEASE(_givenName);
|
||||
RELEASE(_middleName);
|
||||
RELEASE(_familyName);
|
||||
RELEASE(_nameSuffix);
|
||||
RELEASE(_nickname);
|
||||
RELEASE(_phoneticRepresentation);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSString *) namePrefix
|
||||
{
|
||||
return _namePrefix;
|
||||
}
|
||||
|
||||
- (void) setNamePrefix: (NSString *)namePrefix
|
||||
{
|
||||
ASSIGNCOPY(_namePrefix, namePrefix);
|
||||
}
|
||||
|
||||
- (NSString *) givenName
|
||||
{
|
||||
return _givenName;
|
||||
}
|
||||
|
||||
- (void) setGivenName: (NSString *)givenName
|
||||
{
|
||||
ASSIGNCOPY(_givenName, givenName);
|
||||
}
|
||||
|
||||
- (NSString *) middleName
|
||||
{
|
||||
return _middleName;
|
||||
}
|
||||
|
||||
- (void) setMiddleName: (NSString *)middleName
|
||||
{
|
||||
ASSIGNCOPY(_middleName, middleName);
|
||||
}
|
||||
|
||||
- (NSString *) familyName
|
||||
{
|
||||
return _familyName;
|
||||
}
|
||||
|
||||
- (void) setFamilyName: (NSString *)familyName
|
||||
{
|
||||
ASSIGNCOPY(_familyName, familyName);
|
||||
}
|
||||
|
||||
- (NSString *) nameSuffix
|
||||
{
|
||||
return _nameSuffix;
|
||||
}
|
||||
|
||||
- (void) setNameSuffix: (NSString *)nameSuffix
|
||||
{
|
||||
ASSIGNCOPY(_nameSuffix, nameSuffix);
|
||||
}
|
||||
|
||||
- (NSString *) nickname
|
||||
{
|
||||
return _nickname;
|
||||
}
|
||||
|
||||
- (void) setNickname: (NSString *)nickname
|
||||
{
|
||||
ASSIGNCOPY(_nickname, nickname);
|
||||
}
|
||||
|
||||
- (NSPersonNameComponents *) phoneticRepresentation
|
||||
{
|
||||
return _phoneticRepresentation;
|
||||
}
|
||||
|
||||
- (void) setPhoneticRepresentation: (NSPersonNameComponents *)pr
|
||||
{
|
||||
ASSIGNCOPY(_phoneticRepresentation, pr);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue