本文整理汇总了C++中NPT_String::Trim方法的典型用法代码示例。如果您正苦于以下问题:C++ NPT_String::Trim方法的具体用法?C++ NPT_String::Trim怎么用?C++ NPT_String::Trim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NPT_String
的用法示例。
在下文中一共展示了NPT_String::Trim方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
/*----------------------------------------------------------------------
| NPT_LogManager::ParseConfig
+---------------------------------------------------------------------*/
NPT_Result
NPT_LogManager::ParseConfig(const char* config,
NPT_Size config_size)
{
const char* cursor = config;
const char* line = config;
const char* separator = NULL;
NPT_String key;
NPT_String value;
/* parse all entries */
while (cursor <= config+config_size) {
/* separators are newlines, ';' or end of buffer */
if ( cursor == config+config_size ||
*cursor == '\n' ||
*cursor == '\r' ||
*cursor == ';') {
/* newline or end of buffer */
if (separator && line[0] != '#') {
/* we have a property */
key.Assign(line, (NPT_Size)(separator-line));
value.Assign(line+(separator+1-line), (NPT_Size)(cursor-(separator+1)));
key.Trim(" \t");
value.Trim(" \t");
SetConfigValue((const char*)key, (const char*)value);
}
line = cursor+1;
separator = NULL;
} else if (*cursor == '=' && separator == NULL) {
separator = cursor;
}
cursor++;
}
return NPT_SUCCESS;
}
示例2: httpConnectorOnNewClient
void FrontEnd::httpConnectorOnNewClient(HttpServerTask *task, Interface *intf, NPT_Socket *client)
{
NPT_Result nr;
NPT_InputStreamReference inputStream0;
nr = client->GetInputStream(inputStream0);
if (NPT_FAILED(nr)) {
return;
}
NPT_OutputStreamReference outputStream;
nr = client->GetOutputStream(outputStream);
if (NPT_FAILED(nr)) {
return;
}
NPT_BufferedInputStreamReference inputStream(new NPT_BufferedInputStream(inputStream0));
NPT_HttpRequest *req;
nr = NPT_HttpRequest::Parse(*inputStream.AsPointer(), NULL, req);
if (NPT_FAILED(nr)) {
return;
}
// TODO: validate "HOST" ???
RequestContext reqCtx;
reqCtx.clientHint = CH_Unknown;
reqCtx.transferMode = TM_None;
reqCtx.getcontentFeaturesReq = false;
NPT_HttpHeader *hdrUserAgent = req->GetHeaders().GetHeader(NPT_HTTP_HEADER_USER_AGENT);
if (hdrUserAgent) {
if (hdrUserAgent->GetValue().Find("xbox", 0, true) >= 0) {
NPT_LOG_INFO_1("XBox found [User-Agent: %s]", hdrUserAgent->GetValue().GetChars());
reqCtx.clientHint = CH_XBox;
}
}
NPT_HttpHeader *hdrTransferMode = req->GetHeaders().GetHeader("transferMode.dlna.org");
if (hdrTransferMode) {
const NPT_String& transferMode = hdrTransferMode->GetValue();
if (transferMode.Compare("Streaming", true) == 0) {
reqCtx.transferMode = TM_Streaming;
} else if (transferMode.Compare("Interactive", true) == 0) {
reqCtx.transferMode = TM_Interactive;
} else if (transferMode.Compare("Background", true) == 0) {
reqCtx.transferMode = TM_Background;
} else {
reqCtx.transferMode = TM_Unknown;
}
}
NPT_HttpHeader *hdrGetContentFeatures = req->GetHeaders().GetHeader("getcontentFeatures.dlna.org");
if (hdrGetContentFeatures) {
NPT_String getContentFeatures = hdrGetContentFeatures->GetValue();
if (getContentFeatures.Trim().Compare("1") == 0) {
reqCtx.getcontentFeaturesReq = true;
}
}
NPT_SocketInfo si;
client->GetInfo(si);
onHttpRequestHeader(si, req);
PtrHolder<NPT_HttpRequest> req1(req);
NPT_String reqPath(req->GetUrl().GetPath());
NPT_TimeStamp ts;
NPT_System::GetCurrentTimeStamp(ts);
NPT_String dateStr = NPT_DateTime(ts).ToString(NPT_DateTime::FORMAT_RFC_1123);
NPT_HttpResponse *resp = new NPT_HttpResponse(200, "OK", NPT_HTTP_PROTOCOL_1_1);
PtrHolder<NPT_HttpResponse> resp1(resp);
resp->GetHeaders().SetHeader(NPT_HTTP_HEADER_SERVER, m_serverHeader);
resp->GetHeaders().SetHeader("Date", dateStr);
resp->GetHeaders().SetHeader(NPT_HTTP_HEADER_CONTENT_LENGTH, "0");
resp->GetHeaders().SetHeader(NPT_HTTP_HEADER_CONTENT_TYPE, "text/xml");
HttpOutput *httpOutput = new HttpOutputImpl(this, si, outputStream);
PtrHolder<HttpOutput> httpOutput1(httpOutput);
{
ReadLocker locker(m_cpLock);
for (NPT_Ordinal i = 0; i < m_controlPointList.GetItemCount(); i++) {
NPT_List<ControlPointInfo*>::Iterator it = m_controlPointList.GetItem(i);
ControlPointInfo *info = *it;
if (reqPath.StartsWith(info->m_context.m_httpRoot)) {
NPT_InputStream *input = inputStream.AsPointer();
inputStream.Detach();
httpOutput1.detach();
resp1.detach();
req1.detach();
task->detach();
return info->m_controlPoint->processHttpRequest(&intf->m_context, reqPath.SubString(info->m_context.m_httpRoot.GetLength()), reqCtx, req, resp, input, httpOutput, client);
}
}
}
{
//.........这里部分代码省略.........