@@ -14,10 +14,12 @@ * file. */ #import "OFXMLNode.h" +OF_ASSUME_NONNULL_BEGIN + @class OFString; @class OFMutableString; #ifndef DOXYGEN @class OFArray OF_GENERIC(ObjectType); @class OFMutableArray OF_GENERIC(ObjectType); @@ -39,17 +41,19 @@ } #ifdef OF_HAVE_PROPERTIES @property (copy) OFString *name; # ifdef __cplusplus -@property (copy, getter=namespace, setter=setNamespace:) OFString *namespace_; +@property (copy, getter=namespace, setter=setNamespace:, nullable) + OFString *namespace_; # else -@property (copy) OFString *namespace; +@property (copy, nullable) OFString *namespace; # endif -@property (copy) OFString *defaultNamespace; -@property (readonly, copy) OFArray OF_GENERIC(OFXMLAttribute*) *attributes; -@property (copy) OFArray OF_GENERIC(OFXMLNode*) *children; +@property (copy, nullable) OFString *defaultNamespace; +@property (copy, readonly, nullable) OFArray OF_GENERIC(OFXMLAttribute*) + *attributes; +@property (copy, nullable) OFArray OF_GENERIC(OFXMLNode*) *children; #endif /*! * @brief Creates a new XML element with the specified name. * @@ -65,11 +69,11 @@ * @param stringValue The value for the element * @return A new autoreleased OFXMLElement with the specified element name and * value */ + (instancetype)elementWithName: (OFString*)name - stringValue: (OFString*)stringValue; + stringValue: (nullable OFString*)stringValue; /*! * @brief Creates a new XML element with the specified name and namespace. * * @param name The name for the element @@ -76,11 +80,11 @@ * @param namespace_ The namespace for the element * @return A new autoreleased OFXMLElement with the specified element name and * namespace */ + (instancetype)elementWithName: (OFString*)name - namespace: (OFString*)namespace_; + namespace: (nullable OFString*)namespace_; /*! * @brief Creates a new XML element with the specified name, namespace and * string value. * @@ -89,12 +93,12 @@ * @param stringValue The value for the element * @return A new autoreleased OFXMLElement with the specified element name, * namespace and value */ + (instancetype)elementWithName: (OFString*)name - namespace: (OFString*)namespace_ - stringValue: (OFString*)stringValue; + namespace: (nullable OFString*)namespace_ + stringValue: (nullable OFString*)stringValue; /*! * @brief Creates a new element with the specified element. * * @param element An OFXMLElement to initialize the OFXMLElement with @@ -138,11 +142,11 @@ * @param stringValue The value for the element * @return An initialized OFXMLElement with the specified element name and * value */ - initWithName: (OFString*)name - stringValue: (OFString*)stringValue; + stringValue: (nullable OFString*)stringValue; /*! * @brief Initializes an already allocated OFXMLElement with the specified name * and namespace. * @@ -150,11 +154,11 @@ * @param namespace_ The namespace for the element * @return An initialized OFXMLElement with the specified element name and * namespace */ - initWithName: (OFString*)name - namespace: (OFString*)namespace_; + namespace: (nullable OFString*)namespace_; /*! * @brief Initializes an already allocated OFXMLElement with the specified name, * namespace and value. * @@ -163,12 +167,12 @@ * @param stringValue The value for the element * @return An initialized OFXMLElement with the specified element name, * namespace and value */ - initWithName: (OFString*)name - namespace: (OFString*)namespace_ - stringValue: (OFString*)stringValue; + namespace: (nullable OFString*)namespace_ + stringValue: (nullable OFString*)stringValue; /*! * @brief Initializes an already allocated OFXMLElement with the specified * element. * @@ -215,39 +219,51 @@ /*! * @brief Sets the namespace of the element. * * @param namespace_ The new namespace */ -- (void)setNamespace: (OFString*)namespace_; +- (void)setNamespace: (nullable OFString*)namespace_; /*! * @brief Returns the namespace of the element. * * @return The namespace of the element */ -- (OFString*)namespace; +- (nullable OFString*)namespace; + +/*! + * @brief Sets a prefix for a namespace. + * + * @param prefix The prefix for the namespace + * @param namespace_ The namespace for which the prefix is set + */ +- (void)setPrefix: (OFString*)prefix + forNamespace: (OFString*)namespace_; + +/*! + * @brief Binds a prefix for a namespace. + * + * @param prefix The prefix for the namespace + * @param namespace_ The namespace for which the prefix is bound + */ +- (void)bindPrefix: (OFString*)prefix + forNamespace: (OFString*)namespace_; + +/*! + * @brief Sets the default namespace for the element to be used if there is no + * parent. + * + * @param defaultNamespace The default namespace for the element + */ +- (void)setDefaultNamespace: (nullable OFString*)defaultNamespace; /*! * @brief Returns an OFArray with the attributes of the element. * * @return An OFArray with the attributes of the element */ -- (OFArray OF_GENERIC(OFXMLAttribute*)*)attributes; - -/*! - * @brief Removes all children and adds the children from the specified array. - * - * @param children The new children to add - */ -- (void)setChildren: (OFArray OF_GENERIC(OFXMLNode*)*)children; - -/*! - * @brief Returns an array of OFXMLNodes with all children of the element. - * - * @return An array of OFXMLNodes with all children of the element - */ -- (OFArray OF_GENERIC(OFXMLNode*)*)children; +- (nullable OFArray OF_GENERIC(OFXMLAttribute*)*)attributes; /*! * @brief Adds the specified attribute. * * If an attribute with the same name and namespace already exists, it is not @@ -279,11 +295,11 @@ * @param name The name of the attribute * @param namespace_ The namespace of the attribute * @param stringValue The value of the attribute */ - (void)addAttributeWithName: (OFString*)name - namespace: (OFString*)namespace_ + namespace: (nullable OFString*)namespace_ stringValue: (OFString*)stringValue; /*! * @brief Returns the attribute with the specified name. * @@ -298,11 +314,11 @@ * @param attributeName The name of the attribute * @param attributeNS The namespace of the attribute * @return The attribute with the specified name and namespace */ - (OFXMLAttribute*)attributeForName: (OFString*)attributeName - namespace: (OFString*)attributeNS; + namespace: (nullable OFString*)attributeNS; /*! * @brief Removes the attribute with the specified name. * * @param attributeName The name of the attribute @@ -314,37 +330,25 @@ * * @param attributeName The name of the attribute * @param attributeNS The namespace of the attribute */ - (void)removeAttributeForName: (OFString*)attributeName - namespace: (OFString*)attributeNS; - -/*! - * @brief Sets a prefix for a namespace. - * - * @param prefix The prefix for the namespace - * @param namespace_ The namespace for which the prefix is set - */ -- (void)setPrefix: (OFString*)prefix - forNamespace: (OFString*)namespace_; - -/*! - * @brief Binds a prefix for a namespace. - * - * @param prefix The prefix for the namespace - * @param namespace_ The namespace for which the prefix is bound - */ -- (void)bindPrefix: (OFString*)prefix - forNamespace: (OFString*)namespace_; - -/*! - * @brief Sets the default namespace for the element to be used if there is no - * parent. - * - * @param defaultNamespace The default namespace for the element - */ -- (void)setDefaultNamespace: (OFString*)defaultNamespace; + namespace: (nullable OFString*)attributeNS; + +/*! + * @brief Removes all children and adds the children from the specified array. + * + * @param children The new children to add + */ +- (void)setChildren: (nullable OFArray OF_GENERIC(OFXMLNode*)*)children; + +/*! + * @brief Returns an array of OFXMLNodes with all children of the element. + * + * @return An array of OFXMLNodes with all children of the element + */ +- (nullable OFArray OF_GENERIC(OFXMLNode*)*)children; /*! * @brief Adds a child to the OFXMLElement. * * @param child An OFXMLNode which is added as a child @@ -413,11 +417,11 @@ * @brief Returns all children that have the specified namespace. * * @return All children that have the specified namespace */ - (OFArray OF_GENERIC(OFXMLElement*)*)elementsForNamespace: - (OFString*)elementNS; + (nullable OFString*)elementNS; /*! * @brief Returns the first child element with the specified name. * * @param elementName The name of the element @@ -439,19 +443,22 @@ * @param elementName The name of the element * @param elementNS The namespace of the element * @return The first child element with the specified name and namespace */ - (OFXMLElement*)elementForName: (OFString*)elementName - namespace: (OFString*)elementNS; + namespace: (nullable OFString*)elementNS; /*! * @brief Returns the child elements with the specified name and namespace. * * @param elementName The name of the elements * @param elementNS The namespace of the elements * @return The child elements with the specified name and namespace */ -- (OFArray OF_GENERIC(OFXMLElement*)*)elementsForName: (OFString*)elementName - namespace: (OFString*)elementNS; +- (OFArray OF_GENERIC(OFXMLElement*)*) + elementsForName: (OFString*)elementName + namespace: (nullable OFString*)elementNS; @end + +OF_ASSUME_NONNULL_END #import "OFXMLElement+Serialization.h"