// (C)opyright 2018-04-25 Dirk Holtwick, holtwick.it. All rights reserved.

#import <Foundation/Foundation.h>

/*   A dictionary like object that allows to define custom dynamic properties
 *   for typed and easy access. Only simple types like string, number, array and
 *   dictionary are supported. It is mainly thought to be a convenience class that
 *   can be serialized easily to JSON and other formats.
 *
 *   MAKE SURE to add @dynamic for any property you define in a subclass of SeaObject!
 */

@interface SeaObject : NSObject <NSCopying>

@property (nonatomic, assign) BOOL needsSave;
@property (nonatomic, readonly) NSUInteger count;
@property (nonatomic, readonly) NSEnumerator *keyEnumerator;
@property (nonatomic, readonly) NSArray<NSString *> *allKeys;
@property (nonatomic, copy) NSDictionary *jsonDictionary;

- (instancetype)initWithDictionary:(NSDictionary *)dict;
- (void)configure;

- (id)objectForKey:(id)aKey;
- (void)setObject:(id)anObject forKey:(id<NSCopying>)aKey;
- (void)removeObjectForKey:(id)key;
- (void)setObject:(id)obj forKeyedSubscript:(NSString *)key;
- (id)objectForKeyedSubscript:(NSString *)key;

- (BOOL)writeAsJSON:(id)path; 
- (BOOL)readAsJSON:(id)path; 

@end