]>
Commit | Line | Data |
---|---|---|
9ce05555 A |
1 | /* |
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. | |
7 | * | |
8 | * This file contains Original Code and/or Modifications of Original Code | |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
22 | * | |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* CFXMLInputStream.h | |
26 | Copyright (c) 2000-2003, Apple, Inc. All rights reserved. | |
27 | */ | |
28 | ||
29 | #if !defined(__COREFOUNDATION_CFXMLINPUTSTREAM__) | |
30 | #define __COREFOUNDATION_CFXMLINPUTSTREAM__ 1 | |
31 | ||
32 | #include <CoreFoundation/CFBase.h> | |
33 | #include "CFInternal.h" | |
34 | #include <CoreFoundation/CFString.h> | |
35 | #include <CoreFoundation/CFSet.h> | |
36 | #include <CoreFoundation/CFXMLNode.h> | |
37 | ||
38 | struct __CFXMLNode { | |
39 | // additionalData currently always points off the bottom of this struct; we could just eliminate it. Also, we may want to add a flags/version argument, and could use it to mark whether the node was the special one that CFXMLParser mucks with, as well as whether the allocator was "special" (could save us the alloc instance variable, below) -- REW, 3/8/2000 | |
40 | CFRuntimeBase _cfBase; | |
41 | CFIndex version; | |
42 | CFXMLNodeTypeCode dataTypeID; | |
43 | CFStringRef dataString; | |
44 | void *additionalData; | |
45 | }; | |
46 | ||
47 | struct __CFXMLInputStream { | |
48 | CFDataRef data; // The XML data | |
49 | CFURLRef url; // the source URL for the data | |
50 | CFStringEncoding encoding; // the data's encoding | |
51 | const UInt8 *currentByte; // pointer into data at the first byte not yet translated to a character | |
52 | ||
53 | UniChar *charBuffer; // the buffer of characters translated from data | |
54 | UniChar *currentChar; // pointer into charBuffer at the current stream location. MUST be NULL if there are no more characters in charBuffer to consume. | |
55 | UniChar *mark; // The point at which the mark was dropped. NULL if the mark is currently unset. | |
56 | UniChar *parserMark; // mark available only for the parser's use | |
57 | CFIndex bufferLength; // The number of meaningful characters in charBuffer | |
58 | CFIndex bufferCapacity; // The current maximum capacity of charBuffer in UniChars | |
59 | ||
60 | CFIndex charIndex, lineNum; // location in the file | |
61 | UInt32 flags; // See #defines below for bit flag meanings | |
62 | CFMutableSetRef nameSet; // set of all names we've encountered; used for uniquing | |
63 | CFMutableStringRef tempString; | |
64 | ||
65 | CFAllocatorRef allocator; // This is unfortunate; this is always the same as the parser's allocator. We'd like to get rid of it at some point, but that would mean adding an allocator to all the function calls, which means risking that the allocator passed in gets out-of-sync. Maybe once we have CFStreams, we can encapsulate it all in that. REW, 5/22/2000 | |
66 | }; | |
67 | ||
68 | // whether the stream has been opened for reading | |
69 | #define STREAM_OPEN 0x1 | |
70 | // whether the encoding matches ASCII over 0x0-0x7F | |
71 | #define ENCODING_MATCHES_ASCII 0x2 | |
72 | // whether the encoding is Unicode with the "natural" byte ordering | |
73 | #define ENCODING_IS_UNICODE_NATURAL 0x4 | |
74 | // whether the encoding is Unicode with the bytes swapped | |
75 | #define ENCODING_IS_UNICODE_SWAPPED 0x8 | |
76 | // whether the stream has encountered an error in encodings. | |
77 | #define ENCODING_COMPOSITION_ERROR 0x10 | |
78 | ||
79 | typedef struct __CFXMLInputStream _CFXMLInputStream; | |
80 | ||
81 | void _initializeInputStream(_CFXMLInputStream *stream, CFAllocatorRef alloc, CFURLRef dataSource, CFDataRef xmlData); | |
82 | Boolean _openInputStream(_CFXMLInputStream *stream); // None of the subsequent calls will work until the input stream has been opened | |
83 | void _freeInputStream(_CFXMLInputStream *stream); | |
84 | ||
85 | CFStringEncoding _inputStreamGetEncoding(_CFXMLInputStream *stream); | |
86 | CFIndex _inputStreamCurrentLocation(_CFXMLInputStream *stream); | |
87 | CFIndex _inputStreamCurrentLine(_CFXMLInputStream *stream); | |
88 | Boolean _inputStreamAtEOF(_CFXMLInputStream *stream); | |
89 | Boolean _inputStreamComposingErrorOccurred(_CFXMLInputStream *stream); | |
90 | ||
91 | Boolean _inputStreamPeekCharacter(_CFXMLInputStream *stream, UniChar *ch); | |
92 | Boolean _inputStreamGetCharacter(_CFXMLInputStream *stream, UniChar *ch); | |
93 | Boolean _inputStreamReturnCharacter(_CFXMLInputStream *stream, UniChar ch); | |
94 | void _inputStreamSetMark(_CFXMLInputStream *stream); | |
95 | void _inputStreamClearMark(_CFXMLInputStream *stream); | |
96 | void _inputStreamGetCharactersFromMark(_CFXMLInputStream *stream, CFMutableStringRef string); | |
97 | void _inputStreamBackUpToMark(_CFXMLInputStream *stream); | |
98 | void _inputStringInitialize(_CFXMLInputStream *stream, UniChar *characters, CFIndex length); | |
99 | CFIndex _inputStreamSkipWhitespace(_CFXMLInputStream *stream, CFMutableStringRef str); | |
100 | Boolean _inputStreamScanToCharacters(_CFXMLInputStream *stream, const UniChar *scanChars, CFIndex numChars, CFMutableStringRef str); | |
101 | Boolean _inputStreamMatchString(_CFXMLInputStream *stream, const UniChar *stringToMatch, CFIndex length); | |
102 | Boolean _inputStreamScanQuotedString(_CFXMLInputStream *stream, CFMutableStringRef str); | |
103 | Boolean _inputStreamScanXMLName(_CFXMLInputStream *stream, Boolean isNMToken, CFStringRef *str); | |
104 | ||
105 | /* Returns the character index within the current line of the current parse location */ | |
106 | /* To add someday -- CF_EXPORT | |
107 | CFIndex CFXMLParserGetOffsetInCurrentLine(CFXMLParserRef parser); */ | |
108 | ||
109 | #endif /* ! __COREFOUNDATION_CFXMLINPUTSTREAM__ */ | |
110 |