Xerces-C++: XMLNetAccessor.hpp Source File

- Main Page
- Related Pages
- Classes
- Files

# XMLNetAccessor.hpp

Go to the documentation of this file.

    00001 /*
    00002  * Licensed to the Apache Software Foundation (ASF) under one or more
    00003  * contributor license agreements.  See the NOTICE file distributed with
    00004  * this work for additional information regarding copyright ownership.
    00005  * The ASF licenses this file to You under the Apache License, Version 2.0
    00006  * (the "License"); you may not use this file except in compliance with
    00007  * the License.  You may obtain a copy of the License at
    00008  *
    00009  *      http://www.apache.org/licenses/LICENSE-2.0
    00010  *
    00011  * Unless required by applicable law or agreed to in writing, software
    00012  * distributed under the License is distributed on an "AS IS" BASIS,
    00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00014  * See the License for the specific language governing permissions and
    00015  * limitations under the License.
    00016  */
    00017
    00018 /*
    00019  * $Id: XMLNetAccessor.hpp 673960 2008-07-04 08:50:12Z borisk $
    00020  */
    00021
    00022 #if !defined(XERCESC_INCLUDE_GUARD_XMLNETACCESSOR_HPP)
    00023 #define XERCESC_INCLUDE_GUARD_XMLNETACCESSOR_HPP
    00024
    00025 #include <xercesc/util/XercesDefs.hpp>
    00026 #include <xercesc/util/XMLURL.hpp>
    00027 #include <xercesc/util/XMLException.hpp>
    00028
    00029 XERCES_CPP_NAMESPACE_BEGIN
    00030
    00031 class BinInputStream;
    00032
    00033 //  This class holds advanced informations about the HTTP connection
    00034 class XMLUTIL_EXPORT XMLNetHTTPInfo
    00035 {
    00036 public:
    00037     XMLNetHTTPInfo();
    00038
    00039     typedef enum {
    00040         GET,
    00041         PUT,
    00042         POST
    00043     } HTTPMethod;
    00044
    00045     // -----------------------------------------------------------------------
    00046     //  Data members
    00047     //
    00048     //  fHTTPMethod
    00049     //      The type of the HTTP request
    00050     //
    00051     //  fHeaders
    00052     //      The extra headers that will be sent as part of the request; the format is
    00053     //      Header1: Value\r\nHeader2: Value\r\n
    00054     //
    00055     //  fHeadersLen
    00056     //      The length of the string pointed by fHeaders, in bytes
    00057     //
    00058     //  fPayload
    00059     //      The extra data that will be sent after the headers; in the case of a PUT
    00060     //      operation, this is the content of the resource being posted. It can be binary data
    00061     //
    00062     //  fPayloadLen
    00063     //      The length of the binary buffer pointed by fPayload, in bytes
    00064     //
    00065     HTTPMethod      fHTTPMethod;
    00066     const char*     fHeaders;
    00067     XMLSize_t       fHeadersLen;
    00068     const char*     fPayload;
    00069     XMLSize_t       fPayloadLen;
    00070 };
    00071
    00072 inline XMLNetHTTPInfo::XMLNetHTTPInfo()
    00073 :fHTTPMethod(XMLNetHTTPInfo::GET),
    00074  fHeaders(0),
    00075  fHeadersLen(0),
    00076  fPayload(0),
    00077  fPayloadLen(0)
    00078 {
    00079 }
    00080
    00081
    00082 //
    00083 //  This class is an abstract interface via which the URL class accesses
    00084 //  net access services. When any source URL is not in effect a local file
    00085 //  path, then the URL class is used to look at it. Then the URL class can
    00086 //  be asked to make a binary input stream via which the referenced resource
    00087 //  can be read in.
    00088 //
    00089 //  The URL class will use an object derived from this class to create a
    00090 //  binary stream for the URL to return. The object it uses is provided by
    00091 //  the platform utils, and is actually provided by the per-platform init
    00092 //  code so each platform can decide what actual implementation it wants to
    00093 //  use.
    00094 //
    00095 class XMLUTIL_EXPORT XMLNetAccessor : public XMemory
    00096 {
    00097 public :
    00098     // -----------------------------------------------------------------------
    00099     //  Virtual destructor
    00100     // -----------------------------------------------------------------------
    00101     virtual ~XMLNetAccessor()
    00102     {
    00103     }
    00104
    00105
    00106     // -----------------------------------------------------------------------
    00107     //  The virtual net accessor interface
    00108     // -----------------------------------------------------------------------
    00109     virtual const XMLCh* getId() const = 0;
    00110
    00111     virtual BinInputStream* makeNew
    00112     (
    00113         const   XMLURL&                 urlSrc,
    00114         const   XMLNetHTTPInfo*         httpInfo=0
    00115     ) = 0;
    00116
    00117
    00118 protected :
    00119     // -----------------------------------------------------------------------
    00120     //  Hidden constructors
    00121     // -----------------------------------------------------------------------
    00122     XMLNetAccessor()
    00123     {
    00124     }
    00125
    00126
    00127 private :
    00128     // -----------------------------------------------------------------------
    00129     //  Unimplemented constructors and operators
    00130     // -----------------------------------------------------------------------
    00131     XMLNetAccessor(const XMLNetAccessor&);
    00132     XMLNetAccessor& operator=(const XMLNetAccessor&);
    00133 };
    00134
    00135 MakeXMLException(NetAccessorException, XMLUTIL_EXPORT)
    00136
    00137 XERCES_CPP_NAMESPACE_END
    00138
    00139 #endif