Revision: 29866
http://sourceforge.net/p/bibdesk/svn/29866
Author: hofman
Date: 2025-11-21 17:19:43 +0000 (Fri, 21 Nov 2025)
Log Message:
-----------
add some lightweight generics to parser classes
Modified Paths:
--------------
trunk/bibdesk/BDSKAsynchronousWebParser.h
trunk/bibdesk/BDSKAuthenticationHandler.h
trunk/bibdesk/BDSKDOIParser.h
trunk/bibdesk/BDSKDownloader.h
trunk/bibdesk/BDSKMARCParser.h
trunk/bibdesk/BDSKMathSciNetParser.h
trunk/bibdesk/BDSKPubMedXMLParser.h
trunk/bibdesk/BDSKSoapBinding.h
trunk/bibdesk/BDSKStringParser.h
trunk/bibdesk/BDSKWebParser.h
trunk/bibdesk/BDSKZentralblattParser.h
Modified: trunk/bibdesk/BDSKAsynchronousWebParser.h
===================================================================
--- trunk/bibdesk/BDSKAsynchronousWebParser.h 2025-11-21 16:52:53 UTC (rev
29865)
+++ trunk/bibdesk/BDSKAsynchronousWebParser.h 2025-11-21 17:19:43 UTC (rev
29866)
@@ -50,8 +50,10 @@
#pragma mark -
+@class BibItem;
+
@interface BDSKAsynchronousWebParser : BDSKWebParser
<BDSKCitationDownloadDelegate> {
- NSMutableArray *downloads;
+ NSMutableArray<BDSKCitationDownload *> *downloads;
}
// A default implementation of -startCitationDownloads and
+canParseDocument:fromURL:
@@ -70,7 +72,7 @@
// Main method to get items from the downloaded citations
// The default parses the bibtex string returned from
-bibTeXStringFromDownload: for a single item
// Subclasses can also override this for custom handling of the download data
-- (nullable NSArray *)itemsFromDownload:(BDSKCitationDownload *)download
error:(NSError **)outError;
+- (nullable NSArray<BibItem *> *)itemsFromDownload:(BDSKCitationDownload
*)download error:(NSError **)outError;
// Helper method to return the bibtex string from the download, defaults to
the string property
// Subclasses can override this to do some cleaning
Modified: trunk/bibdesk/BDSKAuthenticationHandler.h
===================================================================
--- trunk/bibdesk/BDSKAuthenticationHandler.h 2025-11-21 16:52:53 UTC (rev
29865)
+++ trunk/bibdesk/BDSKAuthenticationHandler.h 2025-11-21 17:19:43 UTC (rev
29866)
@@ -41,9 +41,11 @@
NS_ASSUME_NONNULL_BEGIN
+@class BDSKAuthenticationController;
+
@interface BDSKAuthenticationHandler : NSObject {
- NSMapTable *controllers;
- NSMapTable *queues;
+ NSMapTable<id, BDSKAuthenticationController *> *controllers;
+ NSMapTable<id, NSMutableArray<NSDictionary<NSString *, id> *> *> *queues;
}
@property (class, nonatomic, readonly) BDSKAuthenticationHandler
*sharedHandler;
Modified: trunk/bibdesk/BDSKDOIParser.h
===================================================================
--- trunk/bibdesk/BDSKDOIParser.h 2025-11-21 16:52:53 UTC (rev 29865)
+++ trunk/bibdesk/BDSKDOIParser.h 2025-11-21 17:19:43 UTC (rev 29866)
@@ -42,7 +42,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface BDSKDOIParser : NSObject <BDSKStringParser>
-+ (nullable NSArray *)itemsFromString:(NSString *)itemString owner:(nullable
id<BDSKOwner>)owner error:(NSError **)outError;
++ (nullable NSArray<BibItem *> *)itemsFromString:(NSString *)itemString
owner:(nullable id<BDSKOwner>)owner error:(NSError **)outError;
+ (void)itemsFromString:(NSString *)itemString owner:(id<BDSKOwner>)owner
completionHandler:(void (^ _Nullable)(NSArray *publications))completionHandler;
@end
Modified: trunk/bibdesk/BDSKDownloader.h
===================================================================
--- trunk/bibdesk/BDSKDownloader.h 2025-11-21 16:52:53 UTC (rev 29865)
+++ trunk/bibdesk/BDSKDownloader.h 2025-11-21 17:19:43 UTC (rev 29866)
@@ -44,7 +44,7 @@
@protocol BDSKDownloadDelegate;
@interface BDSKDownloader : NSObject <NSURLSessionDelegate> {
- NSMapTable *downloads;
+ NSMapTable<NSURLSessionTask *, BDSKDownload *> *downloads;
NSURLSession *session;
}
Modified: trunk/bibdesk/BDSKMARCParser.h
===================================================================
--- trunk/bibdesk/BDSKMARCParser.h 2025-11-21 16:52:53 UTC (rev 29865)
+++ trunk/bibdesk/BDSKMARCParser.h 2025-11-21 17:19:43 UTC (rev 29866)
@@ -42,7 +42,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface BDSKMARCParser: NSObject <BDSKStringParser>
-+ (nullable NSArray *)itemsFromMARCXMLString:(NSString *)itemString
error:(NSError **)outError;
++ (nullable NSArray<BibItem *> *)itemsFromMARCXMLString:(NSString *)itemString
error:(NSError **)outError;
@end
NS_ASSUME_NONNULL_END
Modified: trunk/bibdesk/BDSKMathSciNetParser.h
===================================================================
--- trunk/bibdesk/BDSKMathSciNetParser.h 2025-11-21 16:52:53 UTC (rev
29865)
+++ trunk/bibdesk/BDSKMathSciNetParser.h 2025-11-21 17:19:43 UTC (rev
29866)
@@ -42,8 +42,8 @@
NS_ASSUME_NONNULL_BEGIN
@interface BDSKMathSciNetParser : BDSKAsynchronousWebParser
-+ (nullable NSArray *)bibTeXRequestsForMRIDs:(NSArray *)IDs
serverName:(nullable NSString *)serverName;
-+ (nullable NSArray *)itemsFromDownload:(BDSKCitationDownload *)download
parser:(BDSKWebParser *)parser error:(NSError **)outError;
++ (nullable NSArray<BibItem *> *)bibTeXRequestsForMRIDs:(NSArray *)IDs
serverName:(nullable NSString *)serverName;
++ (nullable NSArray<BibItem *> *)itemsFromDownload:(BDSKCitationDownload
*)download parser:(BDSKWebParser *)parser error:(NSError **)outError;
@end
NS_ASSUME_NONNULL_END
Modified: trunk/bibdesk/BDSKPubMedXMLParser.h
===================================================================
--- trunk/bibdesk/BDSKPubMedXMLParser.h 2025-11-21 16:52:53 UTC (rev 29865)
+++ trunk/bibdesk/BDSKPubMedXMLParser.h 2025-11-21 17:19:43 UTC (rev 29866)
@@ -43,7 +43,7 @@
@interface BDSKPubMedXMLParser: NSObject <BDSKStringParser>
-+ (nullable NSArray *)itemsFromData:(NSData *)itemData error:(NSError
**)outError;
++ (nullable NSArray<BibItem *> *)itemsFromData:(NSData *)itemData
error:(NSError **)outError;
@end
Modified: trunk/bibdesk/BDSKSoapBinding.h
===================================================================
--- trunk/bibdesk/BDSKSoapBinding.h 2025-11-21 16:52:53 UTC (rev 29865)
+++ trunk/bibdesk/BDSKSoapBinding.h 2025-11-21 17:19:43 UTC (rev 29866)
@@ -12,11 +12,13 @@
- (nullable NSWindow *)soapOperationWindowForAuthenticationSheet;
@end
+@protocol BDSKSoapElement;
+
@interface BDSKSoapBinding : NSObject {
NSURL *address;
NSString *namespaceURI;
NSTimeInterval defaultTimeout;
- NSMutableArray *cookies;
+ NSMutableArray<NSHTTPCookie *> *cookies;
BOOL logXMLInOut;
NSString *authUsername;
NSString *authPassword;
@@ -28,11 +30,11 @@
@property (nonatomic, nullable, copy) NSString *namespaceURI;
@property (nonatomic) BOOL logXMLInOut;
@property (nonatomic) NSTimeInterval defaultTimeout;
-@property (nonatomic, nullable, strong) NSMutableArray *cookies;
+@property (nonatomic, nullable, strong) NSMutableArray<NSHTTPCookie *>
*cookies;
@property (nonatomic, nullable, strong) NSString *authUsername;
@property (nonatomic, nullable, strong) NSString *authPassword;
- (instancetype)initWithAddress:(NSString *)anAddress namespaceURI:(NSString
*)aNamespaceURI;
-- (NSString *)serializedEnvelopeUsingHeaderElements:(nullable NSDictionary
*)headerElements bodyElements:(nullable NSDictionary *)bodyElements;
+- (NSString *)serializedEnvelopeUsingHeaderElements:(nullable
NSDictionary<NSString *, id<BDSKSoapElement>> *)headerElements
bodyElements:(nullable NSDictionary<NSString *, id<BDSKSoapElement>>
*)bodyElements;
- (NSURLRequest *)requestUsingBody:(NSString *)body soapAction:(NSString
*)soapAction;
- (void)addCookie:(NSHTTPCookie *)toAdd;
@end
@@ -39,8 +41,8 @@
@interface BDSKSoapBindingOperation : NSObject {
BDSKSoapBinding *binding;
- NSDictionary *bodyElements;
- NSDictionary *responseClasses;
+ NSDictionary<NSString *, id<BDSKSoapElement>> *bodyElements;
+ NSDictionary<NSString *, Class> *responseClasses;
NSString *soapAction;
__weak id<BDSKSoapBindingOperationDelegate> delegate;
BDSKDownload *download;
@@ -48,12 +50,12 @@
}
@property (nonatomic, strong) BDSKSoapBinding *binding;
-@property (nonatomic, strong) NSDictionary *bodyElements;
-@property (nonatomic, strong) NSDictionary *responseClasses;
+@property (nonatomic, strong) NSDictionary<NSString *, id<BDSKSoapElement>>
*bodyElements;
+@property (nonatomic, strong) NSDictionary<NSString *, Class> *responseClasses;
@property (nonatomic, strong) NSString *soapAction;
@property (nonatomic, nullable, weak) id<BDSKSoapBindingOperationDelegate>
delegate;
@property (nonatomic, nullable, strong) BDSKDownload *download;
-- (instancetype)initWithBinding:(BDSKSoapBinding *)aBinding delegate:(nullable
id<BDSKSoapBindingOperationDelegate>)aDelegate soapAction:(NSString
*)aSoapAction bodyElements:(NSDictionary *)aBodyElements
responseClasses:(NSDictionary *)aResponseClasses NS_DESIGNATED_INITIALIZER;
+- (instancetype)initWithBinding:(BDSKSoapBinding *)aBinding delegate:(nullable
id<BDSKSoapBindingOperationDelegate>)aDelegate soapAction:(NSString
*)aSoapAction bodyElements:(NSDictionary<NSString *, id<BDSKSoapElement>>
*)aBodyElements responseClasses:(NSDictionary<NSString *, Class>
*)aResponseClasses NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithParameters:(BDSKSoapElement *)parameters
delegate:(nullable id<BDSKSoapBindingOperationDelegate>)aDelegate;
- (instancetype)init NS_UNAVAILABLE;
- (void)start;
Modified: trunk/bibdesk/BDSKStringParser.h
===================================================================
--- trunk/bibdesk/BDSKStringParser.h 2025-11-21 16:52:53 UTC (rev 29865)
+++ trunk/bibdesk/BDSKStringParser.h 2025-11-21 17:19:43 UTC (rev 29866)
@@ -59,6 +59,7 @@
BDSKStringTypeDOI
};
+@class BibItem;
@protocol BDSKOwner;
@interface BDSKStringParser : NSObject
@@ -65,15 +66,15 @@
// passing BDSKStringTypeUnknown will use the appropriate -contentStringType
+ (BOOL)canParseString:(NSString *)string ofType:(BDSKStringType)stringType;
// only for non-BibTeX string types
-+ (nullable NSArray *)itemsFromString:(NSString *)string
ofType:(BDSKStringType)stringType error:(NSError **)outError;
++ (nullable NSArray<BibItem *> *)itemsFromString:(NSString *)string
ofType:(BDSKStringType)stringType error:(NSError **)outError;
// all string types including BibTeX
-+ (nullable NSArray *)itemsFromString:(NSString *)string
ofType:(BDSKStringType)stringType owner:(nullable id <BDSKOwner>)owner
error:(NSError **)outError;
++ (nullable NSArray<BibItem *> *)itemsFromString:(NSString *)string
ofType:(BDSKStringType)stringType owner:(nullable id <BDSKOwner>)owner
error:(NSError **)outError;
@end
@protocol BDSKStringParser <NSObject>
+ (BOOL)canParseString:(NSString *)string;
-+ (nullable NSArray *)itemsFromString:(NSString *)string error:(NSError
**)outError;
++ (nullable NSArray<BibItem *> *)itemsFromString:(NSString *)string
error:(NSError **)outError;
@end
Modified: trunk/bibdesk/BDSKWebParser.h
===================================================================
--- trunk/bibdesk/BDSKWebParser.h 2025-11-21 16:52:53 UTC (rev 29865)
+++ trunk/bibdesk/BDSKWebParser.h 2025-11-21 17:19:43 UTC (rev 29866)
@@ -50,6 +50,8 @@
BDSKParserFeatureGeneric = 2
};
+@class BibItem;
+
@protocol BDSKWebParserDelegate;
@interface BDSKWebParser : NSObject {
@@ -63,10 +65,10 @@
+ (nullable BDSKWebParser *)parserForDocument:(DOMDocument *)domDocument
fromURL:(NSURL *)url shouldMonitor:(BOOL * _Nullable)shouldMonitor;
// Returns all parser classes of a specific feature
-@property (class, nonatomic, readonly) NSArray *parsers;
-@property (class, nonatomic, readonly) NSArray *publicParsers;
-@property (class, nonatomic, readonly) NSArray *subscriptionParsers;
-@property (class, nonatomic, readonly) NSArray *genericParsers;
+@property (class, nonatomic, readonly) NSArray<Class> *parsers;
+@property (class, nonatomic, readonly) NSArray<Class> *publicParsers;
+@property (class, nonatomic, readonly) NSArray<Class> *subscriptionParsers;
+@property (class, nonatomic, readonly) NSArray<Class> *genericParsers;
#pragma mark Concrete web parser
@@ -85,7 +87,7 @@
- (void)cancel;
// whether the parsershould finish with success, can be overridden by
subclasses returning items async
-- (BOOL)canFinishWithItems:(nullable NSArray *)items success:(BOOL *)success;
+- (BOOL)canFinishWithItems:(nullable NSArray<BibItem *> *)items success:(BOOL
*)success;
// this must be implemented by subclasses
+ (BOOL)canParseDocument:(DOMDocument *)domDocument fromURL:(NSURL *)url;
@@ -95,7 +97,7 @@
// main method for subclasses to implement for synchronous parsing
// *outError may be nil even when returning nil
-- (nullable NSArray *)itemsAndReturnError:(NSError **)outError;
+- (nullable NSArray<BibItem *> *)itemsAndReturnError:(NSError **)outError;
// main method for subclasses to implement for asynchronous parsing
// is called only when the previous method returns an empty array
- (void)startCitationDownloads;
@@ -112,7 +114,7 @@
@end
@protocol BDSKWebParserDelegate <BDSKOwner>
-- (void)webParser:(BDSKWebParser *)parser didFindItems:(NSArray *)items;
+- (void)webParser:(BDSKWebParser *)parser didFindItems:(NSArray<BibItem *>
*)items;
- (void)webParser:(BDSKWebParser *)parser didFinishWithSuccess:(BOOL)success
error:(nullable NSError *)error;
@end
Modified: trunk/bibdesk/BDSKZentralblattParser.h
===================================================================
--- trunk/bibdesk/BDSKZentralblattParser.h 2025-11-21 16:52:53 UTC (rev
29865)
+++ trunk/bibdesk/BDSKZentralblattParser.h 2025-11-21 17:19:43 UTC (rev
29866)
@@ -42,8 +42,8 @@
NS_ASSUME_NONNULL_BEGIN
@interface BDSKZentralblattParser : BDSKAsynchronousWebParser
-+ (nullable NSArray *)bibTeXRequestsForZMathIDs:(NSArray *)IDs
serverName:(nullable NSString *)serverName;
-+ (nullable NSArray *)itemsFromDownload:(BDSKCitationDownload *)download
parser:(BDSKWebParser *)parser error:(NSError **)outError;
++ (nullable NSArray<BibItem *> *)bibTeXRequestsForZMathIDs:(NSArray *)IDs
serverName:(nullable NSString *)serverName;
++ (nullable NSArray<BibItem *> *)itemsFromDownload:(BDSKCitationDownload
*)download parser:(BDSKWebParser *)parser error:(NSError **)outError;
@end
NS_ASSUME_NONNULL_END
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit