当前位置: 首页>>代码示例>>C++>>正文


C++ XMLURL::getMemoryManager方法代码示例

本文整理汇总了C++中XMLURL::getMemoryManager方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLURL::getMemoryManager方法的具体用法?C++ XMLURL::getMemoryManager怎么用?C++ XMLURL::getMemoryManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XMLURL的用法示例。


在下文中一共展示了XMLURL::getMemoryManager方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fBuffer

BinURLInputStream::BinURLInputStream(const XMLURL& urlSource)
      : fBuffer(0)
      , fBufferSize(0)
      , fBufferIndex(0)
      , fRemoteFileSize(0)
      , fAnchor(0)
      , fBytesProcessed(0)
      , fMemoryManager(urlSource.getMemoryManager())
{
    fBuffer = (XMLByte*) fMemoryManager->allocate
    (
        URLISBUFMAXSIZE * sizeof(XMLByte)
    );//new XMLByte[URLISBUFMAXSIZE];
    const XMLCh*  uri = urlSource.getURLText();
    char*   uriAsCharStar = localTranscode(uri, fMemoryManager);

    //
    // First find the size of the remote resource being asked for.
    // We use the ContentCounter stream provided by libWWW.
    //

    fAnchor = HTAnchor_findAddress(uriAsCharStar);
    HTRequest*   request = HTRequest_new();
    HTRequest_setOutputFormat(request, WWW_SOURCE);
    HTStream*    counterStrm = HTContentCounter(HTBlackHole(), request, 0xFFFF);
    BOOL  status = HTLoadToStream(uriAsCharStar, counterStrm, request);
    if (status == YES)
    {
        HTParentAnchor * anchor = HTRequest_anchor(request);
        fRemoteFileSize=HTAnchor_length(anchor);
        if(fRemoteFileSize < 0)
        {
            // Patch by Artur Klauser
            // When a redirection is processed in libWWW, it seems that
            // HTAnchor_length(anchor) == -1 on the original anchor, whereas
            // HTResponse_length(response) gives the correct content length of
            // the redirection target. This has confused fRemoteFileSize and it was
            // not checked for a -1 response at all.
            HTResponse * response = HTRequest_response (request);
            fRemoteFileSize = HTResponse_length(response);
            if (fRemoteFileSize < 0) {
                ThrowXMLwithMemMgr(NetAccessorException, XMLExcepts::NetAcc_LengthError, fMemoryManager);
            }
        }
    }

    // Cleanup, before you throw any errors.
    fMemoryManager->deallocate(uriAsCharStar);
    HTRequest_delete(request);
    // Don't know whether I am supposed to delete counterStrm.

    if (status == NO)
    {
        ThrowXMLwithMemMgr(NetAccessorException, XMLExcepts::NetAcc_LengthError, fMemoryManager);
    }
}
开发者ID:ksmyth,项目名称:xerces-c,代码行数:56,代码来源:BinURLInputStream.cpp

示例2: fMulti

CurlURLInputStream::CurlURLInputStream(const XMLURL& urlSource, const XMLNetHTTPInfo* httpInfo/*=0*/)
      : fMulti(0)
      , fEasy(0)
      , fMemoryManager(urlSource.getMemoryManager())
      , fURLSource(urlSource)
      , fURL(0)
      , fTotalBytesRead(0)
      , fWritePtr(0)
      , fBytesRead(0)
      , fBytesToRead(0)
      , fDataAvailable(false)
      , fBufferHeadPtr(fBuffer)
      , fBufferTailPtr(fBuffer)
      , m_log(logging::Category::getInstance(XMLTOOLING_LOGCAT".libcurl.NetAccessor"))
{
	// Allocate the curl multi handle
	fMulti = curl_multi_init();
	
	// Allocate the curl easy handle
	fEasy = curl_easy_init();
	
	// Get the text of the URL we're going to use
	fURL.reset(XMLString::transcode(fURLSource.getURLText(), fMemoryManager), fMemoryManager);

	m_log.debug("libcurl trying to fetch %s", fURL.get());

	// Set URL option
	curl_easy_setopt(fEasy, CURLOPT_URL, fURL.get());
	curl_easy_setopt(fEasy, CURLOPT_WRITEDATA, this);						// Pass this pointer to write function
	curl_easy_setopt(fEasy, CURLOPT_WRITEFUNCTION, staticWriteCallback);	// Our static write function
    curl_easy_setopt(fEasy, CURLOPT_CONNECTTIMEOUT, 30);
    curl_easy_setopt(fEasy, CURLOPT_TIMEOUT, 60);
    curl_easy_setopt(fEasy, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
    curl_easy_setopt(fEasy, CURLOPT_SSL_VERIFYHOST, 0);
    curl_easy_setopt(fEasy, CURLOPT_SSL_VERIFYPEER, 0);
    curl_easy_setopt(fEasy, CURLOPT_NOPROGRESS, 1);
    curl_easy_setopt(fEasy, CURLOPT_NOSIGNAL, 1);
    curl_easy_setopt(fEasy, CURLOPT_FAILONERROR, 1);
	
	// Add easy handle to the multi stack
	curl_multi_add_handle(fMulti, fEasy);
}
开发者ID:janetuk,项目名称:shibboleth-xmltooling,代码行数:42,代码来源:CurlURLInputStream.cpp

示例3: lock

BinHTTPURLInputStream::BinHTTPURLInputStream(const XMLURL& urlSource, const XMLNetHTTPInfo* httpInfo /*=0*/)
      : fSocketHandle(0)
      , fBytesProcessed(0)
{
    if(!fInitialized)
    {
        if (!fInitMutex)
        {
            XMLMutex* tmpMutex = new XMLMutex();
            if (XMLPlatformUtils::compareAndSwap((void**)&fInitMutex, tmpMutex, 0))
            {
                // Someone beat us to it, so let's clean up ours
                delete tmpMutex;
            }
         }
         XMLMutexLock lock(fInitMutex);
         if (!fInitialized)
         {
             Initialize(urlSource.getMemoryManager());
         }
    }

    fMemoryManager = urlSource.getMemoryManager();
    //
    // Pull all of the parts of the URL out of th urlSource object, and transcode them
    //   and transcode them back to ASCII.
    //
    const XMLCh*        hostName = urlSource.getHost();
    char*               hostNameAsCharStar = XMLString::transcode(hostName, urlSource.getMemoryManager());
    ArrayJanitor<char>  janBuf1(hostNameAsCharStar, urlSource.getMemoryManager());

    const XMLCh*        path = urlSource.getPath();
    char*               pathAsCharStar = XMLString::transcode(path, urlSource.getMemoryManager());
    ArrayJanitor<char>  janBuf2(pathAsCharStar, urlSource.getMemoryManager());

    const XMLCh*        fragment = urlSource.getFragment();
    char*               fragmentAsCharStar = 0;
    if (fragment)
        fragmentAsCharStar = XMLString::transcode(fragment, urlSource.getMemoryManager());
    ArrayJanitor<char>  janBuf3(fragmentAsCharStar, urlSource.getMemoryManager());

    const XMLCh*        query = urlSource.getQuery();
    char*               queryAsCharStar = 0;
    if (query)
        queryAsCharStar = XMLString::transcode(query, urlSource.getMemoryManager());
    ArrayJanitor<char>  janBuf4(queryAsCharStar, urlSource.getMemoryManager());		

    unsigned short      portNumber = (unsigned short) urlSource.getPortNum();

    //
    // Set up a socket.
    //
    struct hostent*     hostEntPtr = 0;
    struct sockaddr_in  sa;


    if ((hostEntPtr = gethostbyname(hostNameAsCharStar)) == NULL)
    {
        unsigned long  numAddress = inet_addr(hostNameAsCharStar);
        if (numAddress == INADDR_NONE)
        {
            // Call WSAGetLastError() to get the error number.
            ThrowXMLwithMemMgr1(NetAccessorException,
                     XMLExcepts::NetAcc_TargetResolution, hostName, fMemoryManager);
        }
        if ((hostEntPtr =
                gethostbyaddr((const char *) &numAddress,
                              sizeof(unsigned long), AF_INET)) == NULL)
        {
            // Call WSAGetLastError() to get the error number.
            ThrowXMLwithMemMgr1(NetAccessorException,
                     XMLExcepts::NetAcc_TargetResolution, hostName, fMemoryManager);
        }
    }

    memcpy((void *) &sa.sin_addr,
           (const void *) hostEntPtr->h_addr, hostEntPtr->h_length);
    sa.sin_family = hostEntPtr->h_addrtype;
    sa.sin_port = htons(portNumber);

    SOCKET s = socket(hostEntPtr->h_addrtype, SOCK_STREAM, 0);
    if (s == INVALID_SOCKET)
    {
        // Call WSAGetLastError() to get the error number.
        ThrowXMLwithMemMgr1(NetAccessorException,
                 XMLExcepts::NetAcc_CreateSocket, urlSource.getURLText(), fMemoryManager);
    }

    if (connect(s, (struct sockaddr *) &sa, sizeof(sa)) == SOCKET_ERROR)
    {
        // Call WSAGetLastError() to get the error number.
        ThrowXMLwithMemMgr1(NetAccessorException,
                 XMLExcepts::NetAcc_ConnSocket, urlSource.getURLText(), fMemoryManager);
    }


    // Set a flag so we know that the headers have not been read yet.
    bool fHeaderRead = false;

    // The port is open and ready to go.
//.........这里部分代码省略.........
开发者ID:js422,项目名称:PERL,代码行数:101,代码来源:BinHTTPURLInputStream.cpp

示例4: url

XERCES_CPP_NAMESPACE_BEGIN


CurlURLInputStream::CurlURLInputStream(const XMLURL& urlSource, const XMLNetHTTPInfo* httpInfo/*=0*/)
      : fMulti(0)
      , fEasy(0)
      , fMemoryManager(urlSource.getMemoryManager())
      , fURLSource(urlSource)
      , fTotalBytesRead(0)
      , fWritePtr(0)
      , fBytesRead(0)
      , fBytesToRead(0)
      , fDataAvailable(false)
      , fBufferHeadPtr(fBuffer)
      , fBufferTailPtr(fBuffer)
      , fPayload(0)
      , fPayloadLen(0)
      , fContentType(0)
{
	// Allocate the curl multi handle
	fMulti = curl_multi_init();

	// Allocate the curl easy handle
	fEasy = curl_easy_init();

	// Set URL option
    TranscodeToStr url(fURLSource.getURLText(), "ISO8859-1", fMemoryManager);
	curl_easy_setopt(fEasy, CURLOPT_URL, (char*)url.str());

    // Set up a way to recieve the data
	curl_easy_setopt(fEasy, CURLOPT_WRITEDATA, this);						// Pass this pointer to write function
	curl_easy_setopt(fEasy, CURLOPT_WRITEFUNCTION, staticWriteCallback);	// Our static write function

	// Do redirects
	curl_easy_setopt(fEasy, CURLOPT_FOLLOWLOCATION, (long)1);
	curl_easy_setopt(fEasy, CURLOPT_MAXREDIRS, (long)6);

    // Add username and password if authentication is required
    const XMLCh *username = urlSource.getUser();
    const XMLCh *password = urlSource.getPassword();
    if(username && password) {
        XMLBuffer userPassBuf(256, fMemoryManager);
        userPassBuf.append(username);
        userPassBuf.append(chColon);
        userPassBuf.append(password);

        TranscodeToStr userPass(userPassBuf.getRawBuffer(), "ISO8859-1", fMemoryManager);

        curl_easy_setopt(fEasy, CURLOPT_HTTPAUTH, (long)CURLAUTH_ANY);
        curl_easy_setopt(fEasy, CURLOPT_USERPWD, (char*)userPass.str());
    }

    if(httpInfo) {
        // Set the correct HTTP method
        switch(httpInfo->fHTTPMethod) {
        case XMLNetHTTPInfo::GET:
            break;
        case XMLNetHTTPInfo::PUT:
            curl_easy_setopt(fEasy, CURLOPT_UPLOAD, (long)1);
            break;
        case XMLNetHTTPInfo::POST:
            curl_easy_setopt(fEasy, CURLOPT_POST, (long)1);
            break;
        }

        // Add custom headers
        if(httpInfo->fHeaders) {
            struct curl_slist *headersList = 0;

            const char *headersBuf = httpInfo->fHeaders;
            const char *headersBufEnd = httpInfo->fHeaders + httpInfo->fHeadersLen;

            const char *headerStart = headersBuf;
            while(headersBuf < headersBufEnd) {
                if(*headersBuf == '\r' && (headersBuf + 1) < headersBufEnd &&
                   *(headersBuf + 1) == '\n') {

                    XMLSize_t length = headersBuf - headerStart;
                    ArrayJanitor<char> header((char*)fMemoryManager->allocate((length + 1) * sizeof(char)),
                                              fMemoryManager);
                    memcpy(header.get(), headerStart, length);
                    header.get()[length] = 0;

                    headersList = curl_slist_append(headersList, header.get());

                    headersBuf += 2;
                    headerStart = headersBuf;
                    continue;
                }
                ++headersBuf;
            }
            curl_easy_setopt(fEasy, CURLOPT_HTTPHEADER, headersList);
            curl_slist_free_all(headersList);
        }

        // Set up the payload
        if(httpInfo->fPayload) {
            fPayload = httpInfo->fPayload;
            fPayloadLen = httpInfo->fPayloadLen;
            curl_easy_setopt(fEasy, CURLOPT_READDATA, this);
//.........这里部分代码省略.........
开发者ID:AmesianX,项目名称:Sigil,代码行数:101,代码来源:CurlURLInputStream.cpp

示例5: url

UnixHTTPURLInputStream::UnixHTTPURLInputStream(const XMLURL& urlSource, const XMLNetHTTPInfo* httpInfo/*=0*/)
    : BinHTTPInputStreamCommon(urlSource.getMemoryManager()),
      fSocket(0)
{
    //
    //  Convert the hostName to the platform's code page for gethostbyname and
    //  inet_addr functions.
    //

    MemoryManager *memoryManager = urlSource.getMemoryManager();

    const XMLCh*        hostName = urlSource.getHost();

    if (hostName == 0)
      ThrowXMLwithMemMgr1(NetAccessorException,
                          XMLExcepts::File_CouldNotOpenFile,
                          urlSource.getURLText(),
                          memoryManager);

    char*               hostNameAsCharStar = XMLString::transcode(hostName, memoryManager);
    ArrayJanitor<char>  janHostNameAsCharStar(hostNameAsCharStar, memoryManager);

    XMLURL url(urlSource);
    int redirectCount = 0;
    SocketJanitor janSock(0);

    do {
        //
        // Set up a socket.
        //

#if HAVE_GETADDRINFO
        struct addrinfo hints, *res, *ai;

        CharBuffer portBuffer(10, memoryManager);
        portBuffer.appendDecimalNumber(url.getPortNum());

        memset(&hints, 0, sizeof(struct addrinfo));
        hints.ai_family = PF_UNSPEC;
        hints.ai_socktype = SOCK_STREAM;
        int n = getaddrinfo(hostNameAsCharStar,portBuffer.getRawBuffer(),&hints, &res);
        if(n != 0)
        {
            hints.ai_flags = AI_NUMERICHOST;
            n = getaddrinfo(hostNameAsCharStar,portBuffer.getRawBuffer(),&hints, &res);
            if(n != 0)
                ThrowXMLwithMemMgr1(NetAccessorException, XMLExcepts::NetAcc_TargetResolution, hostName, memoryManager);
        }
        janSock.reset();
        for (ai = res; ai != NULL; ai = ai->ai_next) {
            // Open a socket with the correct address family for this address.
            fSocket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
            if (fSocket < 0)
                continue;
            janSock.reset(&fSocket);
            if (connect(fSocket, ai->ai_addr, ai->ai_addrlen) < 0)
            {
                freeaddrinfo(res);
                ThrowXMLwithMemMgr1(NetAccessorException,
                         XMLExcepts::NetAcc_ConnSocket, url.getURLText(), memoryManager);
            }
            break;
        }
        freeaddrinfo(res);
        if (fSocket < 0)
        {
            ThrowXMLwithMemMgr1(NetAccessorException,
                     XMLExcepts::NetAcc_CreateSocket, url.getURLText(), memoryManager);
        }
#else
        struct hostent *hostEntPtr = 0;
        struct sockaddr_in sa;

        // Use the hostName in the local code page ....
        if((hostEntPtr = gethostbyname(hostNameAsCharStar)) == NULL)
        {
            unsigned long  numAddress = inet_addr(hostNameAsCharStar);
            if ((hostEntPtr =
                    gethostbyaddr((char *) &numAddress,
                        sizeof(unsigned long), AF_INET)) == NULL)
            {
                ThrowXMLwithMemMgr1(NetAccessorException,
                    XMLExcepts::NetAcc_TargetResolution, hostName, memoryManager);
            }
        }

        memset(&sa, '\0', sizeof(sockaddr_in));  // iSeries fix ??
        memcpy((void *) &sa.sin_addr,
            (const void *) hostEntPtr->h_addr, hostEntPtr->h_length);
        sa.sin_family = hostEntPtr->h_addrtype;
        sa.sin_port = htons((unsigned short)url.getPortNum());

        janSock.reset();
        fSocket = socket(hostEntPtr->h_addrtype, SOCK_STREAM, 0);
        if(fSocket < 0)
        {
            ThrowXMLwithMemMgr1(NetAccessorException,
                XMLExcepts::NetAcc_CreateSocket, url.getURLText(), memoryManager);
        }
        janSock.reset(&fSocket);
//.........这里部分代码省略.........
开发者ID:ideasiii,项目名称:ControllerPlatform,代码行数:101,代码来源:UnixHTTPURLInputStream.cpp

示例6: fSocket

XERCES_CPP_NAMESPACE_BEGIN


UnixHTTPURLInputStream::UnixHTTPURLInputStream(const XMLURL& urlSource, const XMLNetHTTPInfo* httpInfo/*=0*/)
      : fSocket(0)
      , fBytesProcessed(0)
      , fMemoryManager(urlSource.getMemoryManager())
{

    //
    //  Constants in ASCII to send/check in the HTTP request/response
    //

    const char GET[] =
    {
        chLatin_G, chLatin_E, chLatin_T, chSpace, chNull
    };

    const char PUT[] =
    {
        chLatin_P, chLatin_U, chLatin_T, chSpace, chNull
    };

    const char POST[] =
    {
        chLatin_P, chLatin_O, chLatin_S, chLatin_T, chSpace, chNull
    };

    const char HTTP[] =
    {
        chLatin_H, chLatin_T, chLatin_T, chLatin_P, chNull
    };

    const char HTTP10[] =
    {
        chSpace, chLatin_H, chLatin_T, chLatin_T, chLatin_P, chForwardSlash, chDigit_1, chPeriod, chDigit_0, chCR, chLF, chNull
    };

    const char CRLF[] =
    {
        chCR, chLF, chNull
    };

    const char CRLF2X[] =
    {
        chCR, chLF, chCR, chLF, chNull
    };

    const char LF2X[] =
    {
        chLF, chLF, chNull
    };

    const char HOST[] =
    {
        chLatin_H, chLatin_o, chLatin_s, chLatin_t, chColon, chSpace, chNull
    };

    const char COLON[] =
    {
        chColon, chNull
    };

    const char resp200 [] =
    {
        chSpace, chDigit_2, chDigit_0, chDigit_0, chSpace, chNull
    };

    unsigned int charsEaten;
    unsigned int transSize;
    XMLTransService::Codes failReason;
    const unsigned int blockSize = 2048;
    const unsigned int bufSize = 5;
    static XMLCh portBuffer[bufSize+1];

    //
    // Pull all of the parts of the URL out of the urlSource object
    //

    const XMLCh*        hostName = urlSource.getHost();
    const XMLCh*        path = urlSource.getPath();
    const XMLCh*        fragment = urlSource.getFragment();
    const XMLCh*        query = urlSource.getQuery();                        

    //
    //  Convert the hostName to the platform's code page for gethostbyname and
    //  inet_addr functions.
    //

    char*               hostNameAsCharStar = XMLString::transcode(hostName, fMemoryManager);
    ArrayJanitor<char>  janBuf1(hostNameAsCharStar, fMemoryManager);

    //
    //  Convert all the parts of the urlSource object to ASCII so they can be
    //  sent to the remote host in that format
    //

    transSize = XMLString::stringLen(hostName)+1;
    char*               hostNameAsASCII = (char*) fMemoryManager->allocate
    (
//.........这里部分代码省略.........
开发者ID:js422,项目名称:PERL,代码行数:101,代码来源:UnixHTTPURLInputStream.cpp


注:本文中的XMLURL::getMemoryManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。