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


C++ StringRef::get方法代码示例

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


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

示例1: getText

std::string Reader::getText(const std::string& name)
{
	StringRef existing = texts.momentaryRequest(name);
	if (existing)
		return *existing.get();

	StringRef result(new std::string(readString(name)));

	texts.momentaryPut(name, result);
	return *result.get();
}
开发者ID:dreamsxin,项目名称:Tsunagari,代码行数:11,代码来源:reader.cpp

示例2: list_threads

/*
 *   generate a human-readable status report of my threads 
 */
void TadsListenerThread::list_threads(NetString *buf)
{
    /* protect against concurrent access */
    mutex->lock();

    /* scan threads */
    for (TadsServerThread *cur = servers ; cur != 0 ; cur = cur->next_server)
    {
        /* report on this thread */
        StringRef *state = cur->get_state();
        buf->appendf("Thread ID=%d (thread object=%lx): %s<br>",
                     cur->thread_id, (unsigned long)cur, state->get());

        /* done with the state string */
        state->release_ref();
    }

    /* done with concurrent access protection */
    mutex->unlock();
}
开发者ID:cspiegel,项目名称:garglk,代码行数:23,代码来源:vmnet.cpp

示例3: process_request

/* 
 *   Process a request from our HTTP client.  The main server loop calls this
 *   when the socket has data ready to read.  
 */
int TadsHttpServerThread::process_request()
{
    StringRef *hdrs = new StringRef(1024);
    TadsHttpRequestHeader *hdr_list = 0, *hdr_tail = 0;
    TadsHttpRequest *req = 0;
    char *verb;
    size_t verb_len;
    char *resource_name;
    size_t res_name_len;
    int ok = FALSE;
    long ofs;
    char *p, *hbody;
    StringRef *body = 0;
    int overflow = FALSE;
    long hbodylen;
    const char *hcl, *hte;             /* content-length, transfer-encoding */

    /* 
     *   Read the header.  We read data into our buffer until we find a
     *   double CR-LF sequence, indicating the end of the header.  
     */
    if ((ofs = read_to_nl(hdrs, 0, 0, 4)) < 0)
        goto done;

    /* the body, if any, starts after the double line break */
    hbody = hdrs->get() + ofs;
    hbodylen = hdrs->getlen() - ofs;

    /* truncate the headers to the CR-LF-CR-LF sequence */
    hdrs->truncate(ofs - 2);

    /*
     *   Parse the main verb in the header - get the method and the resource
     *   ID.  The format is:
     *   
     *.     <space>* VERB <space>+ RESOURCE <space>+ HTTP-VERSION <CRLF>
     */
    p = hdrs->get();
    parse_tok(p, verb, verb_len);
    parse_tok(p, resource_name, res_name_len);

    /* now parse the remaining headers */
    TadsHttpRequestHeader::parse_headers(hdr_list, hdr_tail, FALSE, hdrs, 0);

    /* 
     *   Check to see if there's a message body.  There is if there's a
     *   content-length or transfer-encoding header.
     */
    hcl = hdr_list->find("content-length");
    hte = hdr_list->find("transfer-encoding");
    if (hcl != 0 || hte != 0)
    {
        /* 
         *   There's a content body.  If there's a content-length field,
         *   pre-allocate a chunk of memory, then read the number of bytes
         *   indicated.  If it's a chunked transfer, read it in pieces.  
         */
        if (hcl != 0)
        {
            /* get the length */
            long hclval = atol(hcl);

            /* if it's non-zero, read the content */
            if (hclval != 0)
            {
                /* if this exceeds the size limit, abort */
                if (upload_limit != 0 && hclval > upload_limit)
                {
                    /* set the overflow flag, discard the input, and abort */
                    overflow = TRUE;
                    read(0, 0, hclval, 5000);
                    goto done_with_upload;
                }

                /* allocate the buffer; it's initially empty */
                body = new StringRef(hclval);

                /* copy any portion of the body we've already read */
                if (hbodylen != 0)
                {
                    /* limit this to the declared size */
                    if (hbodylen > hclval)
                        hbodylen = hclval;

                    /* copy the data */
                    body->append(hbody, hbodylen);

                    /* deduct the remaining size */
                    hclval -= hbodylen;
                }

                /* read the body */
                if (hclval != 0
                    && read(body->getend(), hclval, hclval, 5000) < 0)
                {
                    send_simple(S_http_400, "text/html",
//.........这里部分代码省略.........
开发者ID:cspiegel,项目名称:garglk,代码行数:101,代码来源:vmnet.cpp


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