2023-02-11 20:49:42 +00:00
|
|
|
// This file Copyright © 2005-2023 Transmission authors and contributors.
|
2022-01-20 18:27:56 +00:00
|
|
|
// It may be used under the MIT (SPDX: MIT) license.
|
|
|
|
// License text can be found in the licenses/ folder.
|
2007-09-16 01:02:06 +00:00
|
|
|
|
2022-04-29 22:51:40 +00:00
|
|
|
#import <Foundation/Foundation.h>
|
2007-09-16 01:02:06 +00:00
|
|
|
|
|
|
|
@interface NSString (NSStringAdditions)
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
@property(nonatomic, class, readonly) NSString* ellipsis;
|
2022-06-29 04:20:42 +00:00
|
|
|
@property(nonatomic, readonly, copy) NSString* stringByAppendingEllipsis;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
+ (NSString*)stringForFileSize:(uint64_t)size;
|
|
|
|
+ (NSString*)stringForFilePartialSize:(uint64_t)partialSize fullSize:(uint64_t)fullSize;
|
2007-11-19 18:13:41 +00:00
|
|
|
|
2023-03-10 07:05:21 +00:00
|
|
|
// 4 significant digits
|
2021-08-15 09:41:48 +00:00
|
|
|
+ (NSString*)stringForSpeed:(CGFloat)speed;
|
2023-03-10 07:05:21 +00:00
|
|
|
// 4 significant digits
|
2021-08-15 09:41:48 +00:00
|
|
|
+ (NSString*)stringForSpeedAbbrev:(CGFloat)speed;
|
2023-03-10 07:05:21 +00:00
|
|
|
// 3 significant digits
|
|
|
|
+ (NSString*)stringForSpeedAbbrevCompact:(CGFloat)speed;
|
2021-08-15 09:41:48 +00:00
|
|
|
+ (NSString*)stringForRatio:(CGFloat)ratio;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
+ (NSString*)percentString:(CGFloat)progress longDecimals:(BOOL)longDecimals;
|
2010-06-24 00:00:43 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
// simple compare method for strings with numbers (works for IP addresses)
|
|
|
|
- (NSComparisonResult)compareNumeric:(NSString*)string;
|
2007-09-16 01:02:06 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
// like componentsSeparatedByCharactersInSet:, but excludes blank values
|
2022-05-14 19:00:55 +00:00
|
|
|
- (NSArray<NSString*>*)nonEmptyComponentsSeparatedByCharactersInSet:(NSCharacterSet*)separators;
|
2011-09-19 00:48:30 +00:00
|
|
|
|
2022-12-23 02:07:45 +00:00
|
|
|
+ (NSString*)convertedStringFromCString:(char const*)bytes;
|
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
@end
|
2022-10-31 14:37:34 +00:00
|
|
|
|
|
|
|
__attribute__((annotate("returns_localized_nsstring"))) static inline NSString* LocalizationNotNeeded(NSString* s)
|
|
|
|
{
|
|
|
|
return s;
|
|
|
|
}
|