//
//  CFFBaseDict.h
//  GSFontTools
//
//  Created by Georg Seifert on 01.08.11.
//  Copyright 2011 schriftgestaltung.de. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <GSFontTools/CFFVersion.h>

@class CFFIndexedStrings;
@class CFFGlobalSubrsIndex;
@class OTVarStore;
@class GSFileData;
@class GSFont;
@class GSXMLWriter;
@class TTFont;

@interface CFFBaseDict : NSObject

@property (nonatomic, readonly) CFFIndexedStrings *strings;
@property (nonatomic, retain) GSFileData *file;
@property (nonatomic) NSUInteger offset;
@property (assign) CFFVersion version;

@property (nonatomic, retain) CFFGlobalSubrsIndex *globalSubrs;
@property (nonatomic, retain) OTVarStore *varStore;
@property (nonatomic, retain) NSArray *order;

/// Contains the raw values keyed by operator names. It is populated by the `decompile` method.
/// @note Use the `setItem:forKey:` and `itemForKey:` methods to access the decompiled values.
@property (nonatomic, readonly) NSMutableDictionary *rawDict;

@property (strong) NSSet *skipNames;
@property (nonatomic, retain) NSArray *charset;  // TODO: Please check as this is never actually set directly

- (instancetype)initWithStrings:(CFFIndexedStrings *)strings
				 file:(GSFileData *)file
			   offset:(NSUInteger)Offset
		  globalSubrs:(CFFGlobalSubrsIndex *)globalSubrs
   glyphOrderProvider:(NSObject *)glyphOrderProvider
			  version:(CFFVersion)version
			 varStore:(OTVarStore *)varStore;

- (Class)decompilerClass;
- (Class)compilerClass;
- (void)decompile:(NSData *)data;
- (void)postDecompile;
- (id)compiler:(CFFIndexedStrings *)strings parent:(id)parent version:(CFFVersion)version;

- (id)defaultForName:(NSString *)name;
- (id)converterForName:(NSString *)name NS_RETURNS_RETAINED;

- (void)setItem:(id)item forKey:(NSString *)key;
- (id)itemForKey:(NSString *)key;

- (void)toXML:(GSXMLWriter *)writer;
- (void)fromXML:(NSString *)name attrs:(NSDictionary *)attrs content:(id)content;

@end
