[188] | 1 | /*
|
---|
| 2 | * The Apache Software License, Version 1.1
|
---|
| 3 | *
|
---|
| 4 | * Copyright (c) 1999-2000 The Apache Software Foundation. All rights
|
---|
| 5 | * reserved.
|
---|
| 6 | *
|
---|
| 7 | * Redistribution and use in source and binary forms, with or without
|
---|
| 8 | * modification, are permitted provided that the following conditions
|
---|
| 9 | * are met:
|
---|
| 10 | *
|
---|
| 11 | * 1. Redistributions of source code must retain the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer.
|
---|
| 13 | *
|
---|
| 14 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
| 15 | * notice, this list of conditions and the following disclaimer in
|
---|
| 16 | * the documentation and/or other materials provided with the
|
---|
| 17 | * distribution.
|
---|
| 18 | *
|
---|
| 19 | * 3. The end-user documentation included with the redistribution,
|
---|
| 20 | * if any, must include the following acknowledgment:
|
---|
| 21 | * "This product includes software developed by the
|
---|
| 22 | * Apache Software Foundation (http://www.apache.org/)."
|
---|
| 23 | * Alternately, this acknowledgment may appear in the software itself,
|
---|
| 24 | * if and wherever such third-party acknowledgments normally appear.
|
---|
| 25 | *
|
---|
| 26 | * 4. The names "Xerces" and "Apache Software Foundation" must
|
---|
| 27 | * not be used to endorse or promote products derived from this
|
---|
| 28 | * software without prior written permission. For written
|
---|
| 29 | * permission, please contact apache\@apache.org.
|
---|
| 30 | *
|
---|
| 31 | * 5. Products derived from this software may not be called "Apache",
|
---|
| 32 | * nor may "Apache" appear in their name, without prior written
|
---|
| 33 | * permission of the Apache Software Foundation.
|
---|
| 34 | *
|
---|
| 35 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
---|
| 36 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 37 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
| 38 | * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
---|
| 39 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
---|
| 40 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
---|
| 41 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
---|
| 42 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
| 43 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
| 44 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
---|
| 45 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
| 46 | * SUCH DAMAGE.
|
---|
| 47 | * ====================================================================
|
---|
| 48 | *
|
---|
| 49 | * This software consists of voluntary contributions made by many
|
---|
| 50 | * individuals on behalf of the Apache Software Foundation, and was
|
---|
| 51 | * originally based on software copyright (c) 1999, International
|
---|
| 52 | * Business Machines, Inc., http://www.ibm.com . For more information
|
---|
| 53 | * on the Apache Software Foundation, please see
|
---|
| 54 | * <http://www.apache.org/>.
|
---|
| 55 | */
|
---|
| 56 |
|
---|
| 57 | /*
|
---|
| 58 | * $Log: LocalFileInputSource.hpp,v $
|
---|
| 59 | * Revision 1.5 2004/01/29 11:46:29 cargilld
|
---|
| 60 | * Code cleanup changes to get rid of various compiler diagnostic messages.
|
---|
| 61 | *
|
---|
| 62 | * Revision 1.4 2003/12/01 23:23:25 neilg
|
---|
| 63 | * fix for bug 25118; thanks to Jeroen Witmond
|
---|
| 64 | *
|
---|
| 65 | * Revision 1.3 2003/05/16 21:36:55 knoaman
|
---|
| 66 | * Memory manager implementation: Modify constructors to pass in the memory manager.
|
---|
| 67 | *
|
---|
| 68 | * Revision 1.2 2002/11/04 15:00:21 tng
|
---|
| 69 | * C++ Namespace Support.
|
---|
| 70 | *
|
---|
| 71 | * Revision 1.1.1.1 2002/02/01 22:21:50 peiyongz
|
---|
| 72 | * sane_include
|
---|
| 73 | *
|
---|
| 74 | * Revision 1.7 2001/10/13 04:21:53 jasons
|
---|
| 75 | * This patch resolves bug #2409: undocumented XMLException in LocalFileInputSource::new()
|
---|
| 76 | *
|
---|
| 77 | * Revision 1.6 2000/12/14 18:49:53 tng
|
---|
| 78 | * Fix API document generation warning: "Warning: end of member group without matching begin"
|
---|
| 79 | *
|
---|
| 80 | * Revision 1.5 2000/02/24 20:00:22 abagchi
|
---|
| 81 | * Swat for removing Log from API docs
|
---|
| 82 | *
|
---|
| 83 | * Revision 1.4 2000/02/15 23:59:06 roddey
|
---|
| 84 | * More updated documentation of Framework classes.
|
---|
| 85 | *
|
---|
| 86 | * Revision 1.3 2000/02/15 01:21:30 roddey
|
---|
| 87 | * Some initial documentation improvements. More to come...
|
---|
| 88 | *
|
---|
| 89 | * Revision 1.2 2000/02/06 07:47:46 rahulj
|
---|
| 90 | * Year 2K copyright swat.
|
---|
| 91 | *
|
---|
| 92 | * Revision 1.1 2000/01/12 18:58:06 roddey
|
---|
| 93 | * Putting this back with the correct lower case extension.
|
---|
| 94 | *
|
---|
| 95 | * Revision 1.1 2000/01/12 00:13:26 roddey
|
---|
| 96 | * These were moved from internal/ to framework/, which was something that should have
|
---|
| 97 | * happened long ago. They are really framework type of classes.
|
---|
| 98 | *
|
---|
| 99 | * Revision 1.1.1.1 1999/11/09 01:08:10 twl
|
---|
| 100 | * Initial checkin
|
---|
| 101 | *
|
---|
| 102 | * Revision 1.2 1999/11/08 20:44:43 rahul
|
---|
| 103 | * Swat for adding in Product name and CVS comment log variable.
|
---|
| 104 | *
|
---|
| 105 | */
|
---|
| 106 |
|
---|
| 107 |
|
---|
| 108 | #if !defined(LOCALFILEINPUTSOURCE_HPP)
|
---|
| 109 | #define LOCALFILEINPUTSOURCE_HPP
|
---|
| 110 |
|
---|
| 111 | #include <xercesc/sax/InputSource.hpp>
|
---|
| 112 |
|
---|
| 113 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
| 114 |
|
---|
| 115 | class BinInputStream;
|
---|
| 116 |
|
---|
| 117 | /**
|
---|
| 118 | * This class is a derivative of the standard InputSource class. It provides
|
---|
| 119 | * for the parser access to data which is referenced via a local file path,
|
---|
| 120 | * as apposed to remote file or URL. This is the most efficacious mechanism
|
---|
| 121 | * by which local files can be parsed, since the parse knows that it refers
|
---|
| 122 | * to a local file and will make no other attempts to interpret the passed
|
---|
| 123 | * path.
|
---|
| 124 | *
|
---|
| 125 | * The path provided can either be a fully qualified path or a relative path.
|
---|
| 126 | * If relative, it will be completed either relative to a passed base path
|
---|
| 127 | * or relative to the current working directory of the process.
|
---|
| 128 | *
|
---|
| 129 | * As with all InputSource derivatives. The primary objective of an input
|
---|
| 130 | * source is to create an input stream via which the parser can spool in
|
---|
| 131 | * data from the referenced source.
|
---|
| 132 | */
|
---|
| 133 | class XMLPARSER_EXPORT LocalFileInputSource : public InputSource
|
---|
| 134 | {
|
---|
| 135 | public :
|
---|
| 136 | // -----------------------------------------------------------------------
|
---|
| 137 | // Constructors and Destructor
|
---|
| 138 | // -----------------------------------------------------------------------
|
---|
| 139 |
|
---|
| 140 | /** @name Constructors */
|
---|
| 141 | //@{
|
---|
| 142 |
|
---|
| 143 | /**
|
---|
| 144 | * A local file input source requires a path to the file to load. This
|
---|
| 145 | * can be provided either as a fully qualified path, a path relative to
|
---|
| 146 | * the current working directly, or a path relative to a provided base
|
---|
| 147 | * path.
|
---|
| 148 | *
|
---|
| 149 | * The completed path will become the system id of this input source.
|
---|
| 150 | * The constructors don't take any public id for local files, but you
|
---|
| 151 | * still set them via the parent class' setPublicId() method of course.
|
---|
| 152 | *
|
---|
| 153 | * This constructor takes an explicit base path and a possibly relative
|
---|
| 154 | * path. If the relative path is seen to be fully qualified, it is used
|
---|
| 155 | * as is. Otherwise, it is made relative to the passed base path.
|
---|
| 156 | *
|
---|
| 157 | * @param basePath The base path from which the passed relative path
|
---|
| 158 | * will be based, if the relative part is indeed
|
---|
| 159 | * relative.
|
---|
| 160 | *
|
---|
| 161 | * @param relativePath The relative part of the path. It can actually
|
---|
| 162 | * be fully qualified, in which case it is taken
|
---|
| 163 | * as is.
|
---|
| 164 | *
|
---|
| 165 | * @param manager Pointer to the memory manager to be used to
|
---|
| 166 | * allocate objects.
|
---|
| 167 | *
|
---|
| 168 | * @exception XMLException If the path is relative and doesn't properly
|
---|
| 169 | * resolve to a file.
|
---|
| 170 | */
|
---|
| 171 | LocalFileInputSource
|
---|
| 172 | (
|
---|
| 173 | const XMLCh* const basePath
|
---|
| 174 | , const XMLCh* const relativePath
|
---|
| 175 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
| 176 | );
|
---|
| 177 |
|
---|
| 178 | /**
|
---|
| 179 | * This constructor takes a single parameter which is the fully qualified
|
---|
| 180 | * or relative path. If it is fully qualified, it is taken as is. If it is
|
---|
| 181 | * relative, then it is completed relative to the current working directory
|
---|
| 182 | * (or the equivalent on the local host machine.)
|
---|
| 183 | *
|
---|
| 184 | * The completed path will become the system id of this input source.
|
---|
| 185 | * The constructors don't take any public id for local files, but you
|
---|
| 186 | * still set them via the parent class' setPublicId() method of course.
|
---|
| 187 | *
|
---|
| 188 | * @param filePath The relative or fully qualified path.
|
---|
| 189 | *
|
---|
| 190 | * @param manager Pointer to the memory manager to be used to
|
---|
| 191 | * allocate objects.
|
---|
| 192 | *
|
---|
| 193 | * @exception XMLException If the path is relative and doesn't properly
|
---|
| 194 | * resolve to a file.
|
---|
| 195 | */
|
---|
| 196 | LocalFileInputSource
|
---|
| 197 | (
|
---|
| 198 | const XMLCh* const filePath
|
---|
| 199 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
|
---|
| 200 | );
|
---|
| 201 | //@}
|
---|
| 202 |
|
---|
| 203 | /** @name Destructor */
|
---|
| 204 | //@{
|
---|
| 205 | ~LocalFileInputSource();
|
---|
| 206 | //@}
|
---|
| 207 |
|
---|
| 208 |
|
---|
| 209 | // -----------------------------------------------------------------------
|
---|
| 210 | // Virtual input source interface
|
---|
| 211 | // -----------------------------------------------------------------------
|
---|
| 212 |
|
---|
| 213 | /** @name Virtual methods */
|
---|
| 214 | //@{
|
---|
| 215 |
|
---|
| 216 | /**
|
---|
| 217 | * This method will return a binary input stream derivative that will
|
---|
| 218 | * parse from the local file indicatedby the system id.
|
---|
| 219 | *
|
---|
| 220 | * @return A dynamically allocated binary input stream derivative that
|
---|
| 221 | * can parse from the file indicated by the system id.
|
---|
| 222 | */
|
---|
| 223 | virtual BinInputStream* makeStream() const;
|
---|
| 224 |
|
---|
| 225 | //@}
|
---|
| 226 | private:
|
---|
| 227 | // -----------------------------------------------------------------------
|
---|
| 228 | // Unimplemented constructors and operators
|
---|
| 229 | // -----------------------------------------------------------------------
|
---|
| 230 | LocalFileInputSource(const LocalFileInputSource&);
|
---|
| 231 | LocalFileInputSource& operator=(const LocalFileInputSource&);
|
---|
| 232 |
|
---|
| 233 | };
|
---|
| 234 |
|
---|
| 235 | XERCES_CPP_NAMESPACE_END
|
---|
| 236 |
|
---|
| 237 | #endif
|
---|