Index: src/Makefile ================================================================== --- src/Makefile +++ src/Makefile @@ -64,19 +64,19 @@ base64.m \ of_asprintf.m \ of_strptime.m \ unicode.m -INCLUDES := ${SRCS:.m=.h} \ - OFCollection.h \ - OFJSONEncoding.h \ - OFSerialization.h \ - ObjFW.h \ - asprintf.h \ - ${ATOMIC_H} \ - macros.h \ - objfw-defs.h \ +INCLUDES := ${SRCS:.m=.h} \ + OFCollection.h \ + OFJSONRepresentation.h \ + OFSerialization.h \ + ObjFW.h \ + asprintf.h \ + ${ATOMIC_H} \ + macros.h \ + objfw-defs.h \ ${THREADING_H} SRCS += OFArray_adjacent.m \ OFArray_adjacentSubarray.m \ OFCountedSet_hashtable.m \ Index: src/OFArray.h ================================================================== --- src/OFArray.h +++ src/OFArray.h @@ -25,11 +25,11 @@ #import "OFObject.h" #import "OFCollection.h" #import "OFEnumerator.h" #import "OFSerialization.h" -#import "OFJSONEncoding.h" +#import "OFJSONRepresentation.h" @class OFString; #ifdef OF_HAVE_BLOCKS typedef void (^of_array_enumeration_block_t)(id object, size_t index, @@ -41,11 +41,11 @@ /** * \brief An abstract class for storing objects in an array. */ @interface OFArray: OFObject + OFSerialization, OFJSONRepresentation> #ifdef OF_HAVE_PROPERTIES @property (readonly) size_t count; #endif /** Index: src/OFDictionary.h ================================================================== --- src/OFDictionary.h +++ src/OFDictionary.h @@ -25,11 +25,11 @@ #import "OFObject.h" #import "OFCollection.h" #import "OFEnumerator.h" #import "OFSerialization.h" -#import "OFJSONEncoding.h" +#import "OFJSONRepresentation.h" @class OFArray; #ifdef OF_HAVE_BLOCKS typedef void (^of_dictionary_enumeration_block_t)(id key, id object, @@ -45,11 +45,11 @@ * * Note: Fast enumeration on a dictionary enumerates through the keys of the * dictionary. */ @interface OFDictionary: OFObject + OFSerialization, OFJSONRepresentation> /** * \brief Creates a new OFDictionary. * * \return A new autoreleased OFDictionary */ DELETED src/OFJSONEncoding.h Index: src/OFJSONEncoding.h ================================================================== --- src/OFJSONEncoding.h +++ src/OFJSONEncoding.h @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011, 2012 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -@class OFString; - -/** - * \brief A category implemented by classes that support encoding to a JSON - * representation. - * - * \warning Although this method can be called directly on classes other than - * OFArray and OFDictionary, this will generate invalid JSON, as JSON - * requires all data to be encapsulated in an array or a dictionary! - */ -@protocol OFJSON -/** - * \brief Returns the JSON representation of the object as a string. - * - * \return The JSON representation of the object as a string. - */ -- (OFString*)JSONRepresentation; -@end ADDED src/OFJSONRepresentation.h Index: src/OFJSONRepresentation.h ================================================================== --- src/OFJSONRepresentation.h +++ src/OFJSONRepresentation.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011, 2012 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +@class OFString; + +/** + * \brief A protocol implemented by classes that support encoding to a JSON + * representation. + * + * \warning Although this method can be called directly on classes other than + * OFArray and OFDictionary, this will generate invalid JSON, as JSON + * requires all data to be encapsulated in an array or a dictionary! + */ +@protocol OFJSONRepresentation +/** + * \brief Returns the JSON representation of the object as a string. + * + * \return The JSON representation of the object as a string. + */ +- (OFString*)JSONRepresentation; +@end Index: src/OFNull.h ================================================================== --- src/OFNull.h +++ src/OFNull.h @@ -14,18 +14,18 @@ * file. */ #import "OFObject.h" #import "OFSerialization.h" -#import "OFJSONEncoding.h" +#import "OFJSONRepresentation.h" /** * \brief A class for representing null values in collections. */ -@interface OFNull: OFObject +@interface OFNull: OFObject /** * \brief Returns an OFNull singleton. * * \return An OFNull singleton */ + null; @end Index: src/OFNumber.h ================================================================== --- src/OFNumber.h +++ src/OFNumber.h @@ -23,11 +23,11 @@ #include #import "OFObject.h" #import "OFSerialization.h" -#import "OFJSONEncoding.h" +#import "OFJSONRepresentation.h" /** * \brief The type of a number. */ typedef enum of_number_type_t { @@ -60,11 +60,11 @@ } of_number_type_t; /** * \brief Provides a way to store a number in an object. */ -@interface OFNumber: OFObject +@interface OFNumber: OFObject { union of_number_value { BOOL bool_; signed char char_; signed short short_; Index: src/OFString.h ================================================================== --- src/OFString.h +++ src/OFString.h @@ -24,11 +24,11 @@ #include #include #import "OFObject.h" #import "OFSerialization.h" -#import "OFJSONEncoding.h" +#import "OFJSONRepresentation.h" #import "macros.h" @class OFConstantString; @@ -78,11 +78,11 @@ * for a constant string and get initialized on the first message! Therefore, * you should use the corresponding methods to get the ivars, which ensures the * constant string is initialized. */ @interface OFString: OFObject + OFSerialization, OFJSONRepresentation> #ifdef OF_HAVE_PROPERTIES @property (readonly) size_t length; #endif /**