Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

218 lines (183 sloc) 8.53 kb
/*
* Copyright (c) 2008-2009 Brent Fulgham <bfulgham@gmail.org>. All rights reserved.
*
* This source code is a modified version of the CoreFoundation sources released by Apple Inc. under
* the terms of the APSL version 2.0 (see below).
*
* For information about changes from the original Apple source release can be found by reviewing the
* source control system for the project at https://sourceforge.net/svn/?group_id=246198.
*
* The original license information is as follows:
*
* Copyright (c) 2008 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/* CFXMLNode.h
Copyright (c) 1998-2007, Apple Inc. All rights reserved.
*/
#if !defined(__COREFOUNDATION_CFXMLNODE__)
#define __COREFOUNDATION_CFXMLNODE__ 1
#include <CoreFoundation/CFArray.h>
#include <CoreFoundation/CFDictionary.h>
#include <CoreFoundation/CFString.h>
#include <CoreFoundation/CFTree.h>
#include <CoreFoundation/CFURL.h>
CF_EXTERN_C_BEGIN
enum {
kCFXMLNodeCurrentVersion = 1
};
typedef const struct __CFXMLNode * CFXMLNodeRef;
typedef CFTreeRef CFXMLTreeRef;
/* An CFXMLNode describes an individual XML construct - like a tag, or a comment, or a string
of character data. Each CFXMLNode contains 3 main pieces of information - the node's type,
the data string, and a pointer to an additional data structure. The node's type ID is an enum
value of type CFXMLNodeTypeID. The data string is always a CFStringRef; the meaning of the
string is dependent on the node's type ID. The format of the additional data is also dependent
on the node's type; in general, there is a custom structure for each type that requires
additional data. See below for the mapping from type ID to meaning of the data string and
structure of the additional data. Note that these structures are versioned, and may change
as the parser changes. The current version can always be identified by kCFXMLNodeCurrentVersion;
earlier versions can be identified and used by passing earlier values for the version number
(although the older structures would have been removed from the header).
An CFXMLTree is simply a CFTree whose context data is known to be an CFXMLNodeRef. As
such, an CFXMLTree can be used to represent an entire XML document; the CFTree
provides the tree structure of the document, while the CFXMLNodes identify and describe
the nodes of the tree. An XML document can be parsed to a CFXMLTree, and a CFXMLTree
can generate the data for the equivalent XML document - see CFXMLParser.h for more
information on parsing XML.
*/
/* Type codes for the different possible XML nodes; this list may grow.*/
enum {
kCFXMLNodeTypeDocument = 1,
kCFXMLNodeTypeElement = 2,
kCFXMLNodeTypeAttribute = 3,
kCFXMLNodeTypeProcessingInstruction = 4,
kCFXMLNodeTypeComment = 5,
kCFXMLNodeTypeText = 6,
kCFXMLNodeTypeCDATASection = 7,
kCFXMLNodeTypeDocumentFragment = 8,
kCFXMLNodeTypeEntity = 9,
kCFXMLNodeTypeEntityReference = 10,
kCFXMLNodeTypeDocumentType = 11,
kCFXMLNodeTypeWhitespace = 12,
kCFXMLNodeTypeNotation = 13,
kCFXMLNodeTypeElementTypeDeclaration = 14,
kCFXMLNodeTypeAttributeListDeclaration = 15
};
typedef CFIndex CFXMLNodeTypeCode;
typedef struct {
CFDictionaryRef attributes;
CFArrayRef attributeOrder;
Boolean isEmpty;
char _reserved[3];
} CFXMLElementInfo;
typedef struct {
CFStringRef dataString;
} CFXMLProcessingInstructionInfo;
typedef struct {
CFURLRef sourceURL;
CFStringEncoding encoding;
} CFXMLDocumentInfo;
typedef struct {
CFURLRef systemID;
CFStringRef publicID;
} CFXMLExternalID;
typedef struct {
CFXMLExternalID externalID;
} CFXMLDocumentTypeInfo;
typedef struct {
CFXMLExternalID externalID;
} CFXMLNotationInfo;
typedef struct {
/* This is expected to change in future versions */
CFStringRef contentDescription;
} CFXMLElementTypeDeclarationInfo;
typedef struct {
/* This is expected to change in future versions */
CFStringRef attributeName;
CFStringRef typeString;
CFStringRef defaultString;
} CFXMLAttributeDeclarationInfo;
typedef struct {
CFIndex numberOfAttributes;
CFXMLAttributeDeclarationInfo *attributes;
} CFXMLAttributeListDeclarationInfo;
enum {
kCFXMLEntityTypeParameter, /* Implies parsed, internal */
kCFXMLEntityTypeParsedInternal,
kCFXMLEntityTypeParsedExternal,
kCFXMLEntityTypeUnparsed,
kCFXMLEntityTypeCharacter
};
typedef CFIndex CFXMLEntityTypeCode;
typedef struct {
CFXMLEntityTypeCode entityType;
CFStringRef replacementText; /* NULL if entityType is external or unparsed */
CFXMLExternalID entityID; /* entityID.systemID will be NULL if entityType is internal */
CFStringRef notationName; /* NULL if entityType is parsed */
} CFXMLEntityInfo;
typedef struct {
CFXMLEntityTypeCode entityType;
} CFXMLEntityReferenceInfo;
/*
dataTypeCode meaning of dataString format of infoPtr
=========== ===================== =================
kCFXMLNodeTypeDocument <currently unused> CFXMLDocumentInfo *
kCFXMLNodeTypeElement tag name CFXMLElementInfo *
kCFXMLNodeTypeAttribute <currently unused> <currently unused>
kCFXMLNodeTypeProcessingInstruction name of the target CFXMLProcessingInstructionInfo *
kCFXMLNodeTypeComment text of the comment NULL
kCFXMLNodeTypeText the text's contents NULL
kCFXMLNodeTypeCDATASection text of the CDATA NULL
kCFXMLNodeTypeDocumentFragment <currently unused> <currently unused>
kCFXMLNodeTypeEntity name of the entity CFXMLEntityInfo *
kCFXMLNodeTypeEntityReference name of the referenced entity CFXMLEntityReferenceInfo *
kCFXMLNodeTypeDocumentType name given as top-level element CFXMLDocumentTypeInfo *
kCFXMLNodeTypeWhitespace text of the whitespace NULL
kCFXMLNodeTypeNotation notation name CFXMLNotationInfo *
kCFXMLNodeTypeElementTypeDeclaration tag name CFXMLElementTypeDeclarationInfo *
kCFXMLNodeTypeAttributeListDeclaration tag name CFXMLAttributeListDeclarationInfo *
*/
CF_EXPORT
CFTypeID CFXMLNodeGetTypeID(void);
/* Creates a new node based on xmlType, dataString, and additionalInfoPtr. version (together with xmlType) determines the expected structure of additionalInfoPtr */
CF_EXPORT
CFXMLNodeRef CFXMLNodeCreate(CFAllocatorRef alloc, CFXMLNodeTypeCode xmlType, CFStringRef dataString, const void *additionalInfoPtr, CFIndex version);
/* Creates a copy of origNode (which may not be NULL). */
CF_EXPORT
CFXMLNodeRef CFXMLNodeCreateCopy(CFAllocatorRef alloc, CFXMLNodeRef origNode);
CF_EXPORT
CFXMLNodeTypeCode CFXMLNodeGetTypeCode(CFXMLNodeRef node);
CF_EXPORT
CFStringRef CFXMLNodeGetString(CFXMLNodeRef node);
CF_EXPORT
const void *CFXMLNodeGetInfoPtr(CFXMLNodeRef node);
CF_EXPORT
CFIndex CFXMLNodeGetVersion(CFXMLNodeRef node);
/* CFXMLTreeRef */
/* Creates a childless, parentless tree from node */
CF_EXPORT
CFXMLTreeRef CFXMLTreeCreateWithNode(CFAllocatorRef allocator, CFXMLNodeRef node);
/* Extracts and returns the node stored in xmlTree */
CF_EXPORT
CFXMLNodeRef CFXMLTreeGetNode(CFXMLTreeRef xmlTree);
CF_EXTERN_C_END
#endif /* ! __COREFOUNDATION_CFXMLNODE__ */
Jump to Line
Something went wrong with that request. Please try again.