transmission/macosx/NSStringAdditions.h

39 lines
1.3 KiB
C
Raw Normal View History

// This file Copyright © 2005-2023 Transmission authors and contributors.
// 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)
@property(nonatomic, class, readonly) NSString* ellipsis;
@property(nonatomic, readonly, copy) NSString* stringByAppendingEllipsis;
2007-09-16 01:02:06 +00:00
+ (NSString*)stringForFileSize:(uint64_t)size;
+ (NSString*)stringForFilePartialSize:(uint64_t)partialSize fullSize:(uint64_t)fullSize;
// 4 significant digits
+ (NSString*)stringForSpeed:(CGFloat)speed;
// 4 significant digits
+ (NSString*)stringForSpeedAbbrev:(CGFloat)speed;
// 3 significant digits
+ (NSString*)stringForSpeedAbbrevCompact:(CGFloat)speed;
+ (NSString*)stringForRatio:(CGFloat)ratio;
2007-09-16 01:02:06 +00:00
+ (NSString*)percentString:(CGFloat)progress longDecimals:(BOOL)longDecimals;
// simple compare method for strings with numbers (works for IP addresses)
- (NSComparisonResult)compareNumeric:(NSString*)string;
2007-09-16 01:02:06 +00:00
// like componentsSeparatedByCharactersInSet:, but excludes blank values
- (NSArray<NSString*>*)nonEmptyComponentsSeparatedByCharactersInSet:(NSCharacterSet*)separators;
2011-09-19 00:48:30 +00:00
+ (NSString*)convertedStringFromCString:(char const*)bytes;
2007-09-16 01:02:06 +00:00
@end
__attribute__((annotate("returns_localized_nsstring"))) static inline NSString* LocalizationNotNeeded(NSString* s)
{
return s;
}