Add person name components formatter

This commit is contained in:
Gregory John Casamento 2019-09-15 22:17:28 -04:00
parent 74124bf7b1
commit 981fecc39b
6 changed files with 184 additions and 6 deletions

View file

@ -99,6 +99,7 @@
#import <Foundation/NSOrderedSet.h>
#import <Foundation/NSPathUtilities.h>
#import <Foundation/NSPersonNameComponents.h>
#import <Foundation/NSPersonNameComponentsFormatter.h>
#import <Foundation/NSPointerArray.h>
#import <Foundation/NSPointerFunctions.h>
#import <Foundation/NSPortCoder.h>

View file

@ -17,9 +17,6 @@ Missing headers:
<NSAppleEventDescriptor.h>
<NSAppleEventManager.h>
<NSAppleScript.h>
<NSFileCoordinator.h>*
<NSFilePresenter.h>*
<NSFileVersion.h>*
<NSHFSFileTypes.h>
<NSLinguisticTagger.h>
<NSObjectScripting.h>
@ -39,9 +36,6 @@ Missing headers:
-------------------------------------------------------------
Foundation:
<NSOrthography.h>
<NSFileCoordinator.h>
<NSFilePresenter.h>
<NSFileVersion.h>
<NSLinguisticTagger.h>
<NSAppleEventDescriptor.h>
<NSAppleEventManager.h>

View file

@ -24,6 +24,7 @@
#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>

View file

@ -0,0 +1,89 @@
/* Definition of class NSPersonNameComponents
Copyright (C) 2019 Free Software Foundation, Inc.
Implemented by: Gregory Casamento <greg.casamento@gmail.com>
Date: Sep 2019
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 __NSPersonNameComponentsFormatter_h_GNUSTEP_BASE_INCLUDE
#define __NSPersonNameComponentsFormatter_h_GNUSTEP_BASE_INCLUDE
#import <Foundation/NSFormatter.h>
#import <Foundation/NSPersonNameComponents.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_11,GS_API_LATEST)
// Style...
enum {
NSPersonNameComponentsFormatterStyleDefault = 0,
NSPersonNameComponentsFormatterStyleShort,
NSPersonNameComponentsFormatterStyleMedium,
NSPersonNameComponentsFormatterStyleLong,
NSPersonNameComponentsFormatterStyleAbbreviated
};
typedef NSUInteger NSPersonNameComponentsFormatterStyle;
// Options...
enum { NSPersonNameComponentsFormatterPhonetic = (1UL << 1) };
typedef NSUInteger NSPersonNameComponentsFormatterOptions;
@class NSString;
@interface NSPersonNameComponentsFormatter : NSFormatter
{
@private
BOOL _phonetic;
NSPersonNameComponentsFormatterStyle style;
}
// Designated init...
+ (NSString *) localizedStringFromPersonNameComponents: (NSPersonNameComponents *)components
style: (NSPersonNameComponentsFormatterStyle)nameFormatStyle
options: (NSPersonNameComponentsFormatterOptions)nameOptions;
// Setters
- (NSPersonNameComponentsFormatterStyle) style;
- (void) setStyle: (NSPersonNameComponentsFormatterStyle)style;
- (BOOL) isPhonetic;
- (void) setPhonetic: (BOOL)flag;
// Convenience methods...
- (NSString *) stringFromPersonNameComponents: (NSPersonNameComponents *)components;
- (NSAttributedString *) annotatedStringFromPersonNameComponents: (NSPersonNameComponents *)components;
- (NSPersonNameComponents *) personNameComponentsFromString: (NSString *)string;
- (BOOL)getObjectValue: (id *)obj
forString: (NSString *)string
errorDescription: (NSString **)error;
@end
// components for attributed strings;
GS_EXPORT NSString * const NSPersonNameComponentKey;
GS_EXPORT NSString * const NSPersonNameComponentGivenName;
GS_EXPORT NSString * const NSPersonNameComponentFamilyName;
GS_EXPORT NSString * const NSPersonNameComponentMiddleName;
GS_EXPORT NSString * const NSPersonNameComponentPrefix;
GS_EXPORT NSString * const NSPersonNameComponentSuffix;
GS_EXPORT NSString * const NSPersonNameComponentNickname;
GS_EXPORT NSString * const NSPersonNameComponentDelimiter;
#endif
#endif

View file

@ -263,6 +263,7 @@ NSOrderedSet.m \
NSPage.m \
NSPathUtilities.m \
NSPersonNameComponents.m \
NSPersonNameComponentsFormatter.m \
NSPipe.m \
NSPointerArray.m \
NSPointerFunctions.m \
@ -438,6 +439,7 @@ NSOperation.h \
NSOrderedSet.h \
NSPathUtilities.h \
NSPersonNameComponents.h \
NSPersonNameComponentsFormatter.h \
NSPointerArray.h \
NSPointerFunctions.h \
NSPortCoder.h \

View file

@ -0,0 +1,91 @@
/* Definition of class NSPersonNameComponents
Copyright (C) 2019 Free Software Foundation, Inc.
Implemented by: Gregory Casamento <greg.casamento@gmail.com>
Date: Sep 2019
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 "Foundation/NSPersonNameComponentsFormatter.h"
#import "Foundation/NSString.h"
#import "Foundation/NSPersonNameComponents.h"
@implementation NSPersonNameComponentsFormatter
// Designated init...
+ (NSString *) localizedStringFromPersonNameComponents: (NSPersonNameComponents *)components
style: (NSPersonNameComponentsFormatterStyle)nameFormatStyle
options: (NSPersonNameComponentsFormatterOptions)nameOptions
{
return nil;
}
// Setters
- (NSPersonNameComponentsFormatterStyle) style
{
return 0;
}
- (void) setStyle: (NSPersonNameComponentsFormatterStyle)style
{
}
- (BOOL) isPhonetic
{
return NO;
}
- (void) setPhonetic: (BOOL)flag
{
}
// Convenience methods...
- (NSString *) stringFromPersonNameComponents: (NSPersonNameComponents *)components
{
return nil;
}
- (NSAttributedString *) annotatedStringFromPersonNameComponents: (NSPersonNameComponents *)components
{
return nil;
}
- (NSPersonNameComponents *) personNameComponentsFromString: (NSString *)string
{
return nil;
}
- (BOOL)getObjectValue: (id *)obj
forString: (NSString *)string
errorDescription: (NSString **)error
{
return NO;
}
@end
// components for attributed strings;
NSString * const NSPersonNameComponentKey = @"NSPersonNameComponentKey";
NSString * const NSPersonNameComponentGivenName = @"NSPersonNameComponentGivenName";
NSString * const NSPersonNameComponentFamilyName = @"NSPersonNameComponentFamilyName";
NSString * const NSPersonNameComponentMiddleName = @"NSPersonNameComponentMiddleName";
NSString * const NSPersonNameComponentPrefix = @"NSPersonNameComponentPrefix";
NSString * const NSPersonNameComponentSuffix = @"NSPersonNameComponentSuffix";
NSString * const NSPersonNameComponentNickname = @"NSPersonNameComponentNickname";
NSString * const NSPersonNameComponentDelimiter = @"NSPersonNameComponentDelimiter";