本文整理汇总了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();
}
示例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();
}
示例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",
//.........这里部分代码省略.........