/*
 * This file is part of the YSSDWebImage package.
 * (c) Olivier Poitrey <rs@dailymotion.com>
 * (c) Fabrice Aneche
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

#import <Foundation/Foundation.h>
#import "YSSDWebImageCompat.h"

/**
 You can use switch case like normal enum. It's also recommended to add a default case. You should not assume anything about the raw value.
 For custom coder plugin, it can also extern the enum for supported format. See `YSSDImageCoder` for more detailed information.
 */
typedef NSInteger YSSDImageFormat NS_TYPED_EXTENSIBLE_ENUM;
static const YSSDImageFormat YSSDImageFormatUndefined = -1;
static const YSSDImageFormat YSSDImageFormatJPEG      = 0;
static const YSSDImageFormat YSSDImageFormatPNG       = 1;
static const YSSDImageFormat YSSDImageFormatGIF       = 2;
static const YSSDImageFormat YSSDImageFormatTIFF      = 3;
static const YSSDImageFormat YSSDImageFormatWebP      = 4;
static const YSSDImageFormat YSSDImageFormatHEIC      = 5;
static const YSSDImageFormat YSSDImageFormatHEIF      = 6;
static const YSSDImageFormat YSSDImageFormatPDF       = 7;
static const YSSDImageFormat YSSDImageFormatSVG       = 8;

/**
 NSData category about the image content type and UTI.
 */
@interface NSData (YSImageContentType)

/**
 *  Return image format
 *
 *  @param data the input image data
 *
 *  @return the image format as `YSSDImageFormat` (enum)
 */
+ (YSSDImageFormat)yssd_imageFormatForImageData:(nullable NSData *)data;

/**
 *  Convert YSSDImageFormat to UTType
 *
 *  @param format Format as YSSDImageFormat
 *  @return The UTType as CFStringRef
 *  @note For unknown format, `kUTTypeImage` abstract type will return
 */
+ (nonnull CFStringRef)yssd_UTTypeFromImageFormat:(YSSDImageFormat)format CF_RETURNS_NOT_RETAINED NS_SWIFT_NAME(yssd_UTType(from:));

/**
 *  Convert UTType to YSSDImageFormat
 *
 *  @param uttype The UTType as CFStringRef
 *  @return The Format as YSSDImageFormat
 *  @note For unknown type, `YSSDImageFormatUndefined` will return
 */
+ (YSSDImageFormat)yssd_imageFormatFromUTType:(nonnull CFStringRef)uttype;

@end
