GME  13
WinSockNetAccessor.cpp
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: WinSockNetAccessor.cpp 635984 2008-03-11 15:54:37Z borisk $
00020  */
00021 
00022 
00023 #define _WINSOCKAPI_
00024 
00025 #include <windows.h>
00026 
00027 #include <xercesc/util/XMLUniDefs.hpp>
00028 #include <xercesc/util/XMLUni.hpp>
00029 #include <xercesc/util/XMLExceptMsgs.hpp>
00030 #include <xercesc/util/NetAccessors/WinSock/BinHTTPURLInputStream.hpp>
00031 #include <xercesc/util/NetAccessors/WinSock/WinSockNetAccessor.hpp>
00032 
00033 XERCES_CPP_NAMESPACE_BEGIN
00034 
00035 const XMLCh WinSockNetAccessor::fgMyName[] =
00036 {
00037     chLatin_W, chLatin_i, chLatin_n, chLatin_S, chLatin_o, chLatin_c,
00038     chLatin_k, chLatin_N, chLatin_e, chLatin_t, chLatin_A, chLatin_c,
00039     chLatin_c, chLatin_e, chLatin_s, chLatin_s, chLatin_o, chLatin_r,
00040     chNull
00041 };
00042 
00043 WinSockNetAccessor::WinSockNetAccessor()
00044 {
00045 }
00046 
00047 
00048 WinSockNetAccessor::~WinSockNetAccessor()
00049 {
00050     // Cleanup code for the WinSock library here.
00051     BinHTTPURLInputStream::Cleanup();
00052 }
00053 
00054 
00055 BinInputStream* WinSockNetAccessor::makeNew(const XMLURL&  urlSource, const XMLNetHTTPInfo* httpInfo /*=0*/)
00056 {
00057     XMLURL::Protocols  protocol = urlSource.getProtocol();
00058     switch(protocol)
00059     {
00060         case XMLURL::HTTP:
00061         {
00062             BinHTTPURLInputStream* retStrm =
00063                 new (urlSource.getMemoryManager()) BinHTTPURLInputStream(urlSource, httpInfo);
00064             return retStrm;
00065             break;
00066         }
00067 
00068         //
00069         // These are the only protocols we support now. So throw and
00070         // unsupported protocol exception for the others.
00071         //
00072         default :
00073             ThrowXMLwithMemMgr(MalformedURLException, XMLExcepts::URL_UnsupportedProto, urlSource.getMemoryManager());
00074             break;
00075     }
00076     return 0;
00077 }
00078 
00079 XERCES_CPP_NAMESPACE_END
00080