本文整理汇总了C++中xbox::VString::FromString方法的典型用法代码示例。如果您正苦于以下问题:C++ VString::FromString方法的具体用法?C++ VString::FromString怎么用?C++ VString::FromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xbox::VString
的用法示例。
在下文中一共展示了VString::FromString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddVirtualHost
XBOX::VError VVirtualHostManager::AddVirtualHost (const VVirtualHost *inVirtualHost)
{
XBOX::VError error = XBOX::VE_INVALID_PARAMETER;
if (NULL != inVirtualHost)
{
XBOX::VString pattern;
VVirtualHost * virtualHost = const_cast<VVirtualHost *>(inVirtualHost);
pattern.FromString (virtualHost->GetHostPattern());
if (!pattern.IsEmpty())
{
/* Severals project can use the same hostPattern but they can NOT have the same projectPattern */
error = _AddVirtualHost (fHostPatternsMap, virtualHost, pattern);
}
#if HTTP_SERVER_USE_PROJECT_PATTERNS
pattern.FromString (virtualHost->GetURLPattern());
if (!pattern.IsEmpty())
{
if (!_VirtualHostAlreadyExist (fURLPatternsMap, pattern))
{
error = _AddVirtualHost (fURLPatternsMap, virtualHost, pattern);
}
else
{
error = VE_HTTP_SERVER_VIRTUAL_HOST_ALREADY_EXIST;
}
}
#endif
if (error == VE_OK)
{
fVirtualHosts.push_back (virtualHost);
}
}
return error;
}
示例2: ParseHostString
void ParseHostString (const XBOX::VString& inHostString, XBOX::VString& outIPv4String, PortNumber& outPort)
{
XBOX::VIndex pos = inHostString.FindUniChar (CHAR_COLON);
if (pos > 0)
{
XBOX::VString portString;
inHostString.GetSubString (1, pos - 1, outIPv4String);
inHostString.GetSubString (pos + 1, inHostString.GetLength() - pos, portString);
outPort = portString.GetLong();
}
else
{
outIPv4String.FromString (inHostString);
outPort = DEFAULT_LISTENING_PORT;
}
}
示例3: _WriteWLF_ELF
//.........这里部分代码省略.........
fRequestsBuffer.AppendUniChar (CHAR_QUOTATION_MARK);
break;
case LOG_TOKEN_USER: //The User Name if there was a Web User entry for a realm.
string.Clear();
inHTTPResponse.GetRequest().GetAuthenticationInfos()->GetUserName (string);
_WriteUsername (string, fRequestsBuffer);
break;
case LOG_TOKEN_REFERER: //HTTP request's "Referer" header field, sending the URL that referred to the current page. www.google.com
string.Clear();
inHTTPResponse.GetRequest().GetHTTPHeaders().GetHeaderValue (STRING_HEADER_REFERER, string);
if (!string.IsEmpty())
fRequestsBuffer.AppendString (string);
else
fRequestsBuffer.AppendUniChar (CHAR_HYPHEN_MINUS);
break;
case LOG_TOKEN_CS_REFERER: //HTTP request's "Referer" header field, sending the URL that referred to the current page. www.google.com
string.Clear();
inHTTPResponse.GetRequest().GetHTTPHeaders().GetHeaderValue (STRING_HEADER_REFERER, string);
fRequestsBuffer.AppendUniChar (CHAR_QUOTATION_MARK);
fRequestsBuffer.AppendString (string);
fRequestsBuffer.AppendUniChar (CHAR_QUOTATION_MARK);
break;
case LOG_TOKEN_ELF_CS_HOST: // = LOG_TOKEN_HOSTFIELD. The "HOST" field of the HTTP request
fRequestsBuffer.AppendUniChar (CHAR_QUOTATION_MARK);
fRequestsBuffer.AppendString (inHTTPResponse.GetRequest().GetHost());
fRequestsBuffer.AppendUniChar (CHAR_QUOTATION_MARK);
break;
case LOG_TOKEN_ELF_URI:
string.FromString (inHTTPResponse.GetRequest().GetURL());
if (!string.IsEmpty())
fRequestsBuffer.AppendString (string);
else
fRequestsBuffer.AppendUniChar (CHAR_HYPHEN_MINUS);
break;
case LOG_TOKEN_URL:
case LOG_TOKEN_ELF_CS_URI_STEM: // Path portion of the HTTP request. "/status/stat.html"
string.FromString (inHTTPResponse.GetRequest().GetURLPath());
if (!string.IsEmpty())
fRequestsBuffer.AppendString (string);
else
fRequestsBuffer.AppendUniChar (CHAR_HYPHEN_MINUS);
break;
case LOG_TOKEN_SEARCH_ARGS: // The search arguments to the URL (text after a question mark)
string.FromString (inHTTPResponse.GetRequest().GetURLQuery());
fRequestsBuffer.AppendString (string);
break;
case LOG_TOKEN_ELF_CS_URI_QUERY: // Search argument portion of the HTTP request. "first=last&last=first"
string.FromString (inHTTPResponse.GetRequest().GetURLQuery());
if (!string.IsEmpty())
fRequestsBuffer.AppendString (string);
else
fRequestsBuffer.AppendUniChar (CHAR_HYPHEN_MINUS);
break;
case LOG_TOKEN_CONNECTION_ID: // A number that is unique for each connection for this invocation of the server. Typically socket number.
{
sLONG rawSocket = inHTTPResponse.GetRawSocket();
if (rawSocket > 0)
示例4: GetFilePathFromURL
XBOX::VError VVirtualFolder::GetFilePathFromURL (const XBOX::VString& inURL, XBOX::VString& outLocationPath)
{
if (!fLocalFolder)
{
XBOX::VString URL (inURL);
sLONG pos = HTTPServerTools::FindASCIIVString (URL, fName);
if (pos > 0)
URL.Remove (1, pos + fName.GetLength() - 1);
if ((URL.GetLength() == 1) && (URL.GetUniChar (1) == CHAR_SOLIDUS) && (!fIndexFileName.IsEmpty()))
URL.AppendString (fIndexFileName);
outLocationPath.FromString (fLocationPath);
if (outLocationPath.GetUniChar (outLocationPath.GetLength()) == CHAR_SOLIDUS)
outLocationPath.Truncate (outLocationPath.GetLength() - 1);
outLocationPath.AppendString (URL);
return VE_HTTP_PROTOCOL_FOUND;
}
XBOX::VError error = XBOX::VE_FILE_NOT_FOUND;
XBOX::VFilePath path (fFolder->GetPath());
XBOX::VString pathString (inURL);
XBOX::VString folder;
XBOX::VString docName;
if ((pathString.GetLength() == 1) && (pathString.GetUniChar (1) == CHAR_SOLIDUS))
{
docName.FromString (fIndexFileName);
}
else
{
bool notDone = true;
sLONG folderLen = 0;
sLONG pos = 0;
sLONG curPos = 0;
// YT 16-Nov-2011 - ACI0073914
if (pathString.FindUniChar (CHAR_COLON) > 0) // ':'
pathString.ExchangeAll (CHAR_COLON, CHAR_SOLIDUS);
if (pathString.FindUniChar (CHAR_REVERSE_SOLIDUS) > 0) // '\'
pathString.ExchangeAll (CHAR_REVERSE_SOLIDUS, CHAR_SOLIDUS);
while (notDone)
{
if ((pos = pathString.FindUniChar (CHAR_SOLIDUS, curPos + 1)) > 0) // '/'
{
HTTPServerTools::GetSubString (pathString, curPos, pos - 2, folder);
folderLen = folder.GetLength();
if (folderLen > 0)
{
/* If URL first folder equals Virtual Folder Name or Project Pattern... Do nothing... */
if ((curPos == 1) && !fName.IsEmpty() && HTTPServerTools::EqualASCIIVString (fName, folder))
;
/* YT 24-Feb-2011 - ACI0069901 - Project Pattern is already removed from URL in VHTTPResponse::_UpdateRequestURL()
else if ((curPos == 1) && !fProjectPattern.IsEmpty() && HTTPServerTools::EqualASCIIVString (fProjectPattern, folder))
{
pathString.SubString (curPos + fProjectPattern.GetLength() + 1, pathString.GetLength() - fProjectPattern.GetLength() + 1); // YT 24-Nov-2010 - ACI0068942 - Remove Project Pattern from URL...
folderLen = 0;
curPos = -1;
}
*/
else if ((folderLen == 2) && (folder[0] == CHAR_FULL_STOP) && (folder[1] == CHAR_FULL_STOP)) // ".."
path = path.ToParent();
else if ((folderLen == 1) && (folder[0] == CHAR_FULL_STOP)) // "."
; // unchanged
else
path = path.ToSubFolder (folder);
curPos += (folderLen + 1);
}
else
curPos += 1;
}
else
notDone = false;
if (curPos >= pathString.GetLength())
break;
}
if (curPos < pathString.GetLength())
HTTPServerTools::GetSubString (pathString, curPos, pathString.GetLength() - 1, docName);
}
/* if URL does not include a filename, try using the index file name set in prefs */
if (docName.IsEmpty())
docName.FromString (fIndexFileName);
path = path.ToSubFile (docName);
/*
at this stage path should contain a full path pointing to the wanted file
check that this is inside the web folder (if it's a web connection)
*/
// SECURITY CHECK - change it with great care
if (path.GetPath().BeginsWith (fFolder->GetPath().GetPath()))
{
//.........这里部分代码省略.........
示例5: SaveToBag
XBOX::VError VHTTPServerProjectSettings::SaveToBag (XBOX::VValueBag *outBag)
{
if (NULL == outBag)
return XBOX::VE_INVALID_PARAMETER;
XBOX::VValueBag *projectSettings = new XBOX::VValueBag ();
if (projectSettings)
{
XBOX::VString ipString;
XBOX::VString authTypeString;
#if WITH_DEPRECATED_IPV4_API
ServerNetTools::GetIPAdress (fListeningAddress, ipString);
#else
ipString.FromString (fListeningAddress);
#endif
HTTPServerTools::GetAuthenticationMethodName (fAuthType, authTypeString);
projectSettings->SetLong (RIASettingsKeys::Project::refCount, GetRefCount());
projectSettings->SetString (RIASettingsKeys::Project::listen, ipString);
projectSettings->SetString (RIASettingsKeys::Project::hostName, fHostName);
#if HTTP_SERVER_USE_PROJECT_PATTERNS
projectSettings->SetString (RIASettingsKeys::Project::pattern, fProjectPattern);
#endif
projectSettings->SetString (RIASettingsKeys::Project::realm, fRealm);
projectSettings->SetString (RIASettingsKeys::Project::authType, authTypeString);
outBag->AddElement (RIASettingsKeys::Project::kXmlElement, projectSettings);
XBOX::ReleaseRefCountable (&projectSettings);
}
XBOX::VValueBag *httpSettings = new XBOX::VValueBag ();
if (httpSettings)
{
XBOX::VString posixPath;
httpSettings->SetLong (RIASettingsKeys::HTTP::port, fPort);
httpSettings->SetBool (RIASettingsKeys::HTTP::allowSSL, fAllowSSL);
httpSettings->SetBool (RIASettingsKeys::HTTP::SSLMandatory, fSSLMandatory);
httpSettings->SetLong (RIASettingsKeys::HTTP::SSLPort, fSSLPort);
if (fSSLCertificatesFolderPath.IsValid())
{
fSSLCertificatesFolderPath.GetPosixPath (posixPath);
httpSettings->SetString (RIASettingsKeys::HTTP::SSLCertificatePath, posixPath);
}
XBOX::VString charSetName;
VTextConverters::Get()->GetNameFromCharSet (fDefaultCharSet, charSetName);
httpSettings->SetString (RIASettingsKeys::HTTP::standardSet, charSetName);
/* cache settings */
httpSettings->SetBool (RIASettingsKeys::HTTP::useCache, fEnableCache);
httpSettings->SetLong (RIASettingsKeys::HTTP::pageCacheSize, fCacheMaxSize);
httpSettings->SetLong (RIASettingsKeys::HTTP::cachedObjectMaxSize, fCachedObjectMaxSize);
/* compression settings */
httpSettings->SetBool (RIASettingsKeys::HTTP::allowCompression, fEnableCompression);
httpSettings->SetLong (RIASettingsKeys::HTTP::compressionMinThreshold, fCompressionMinThreshold);
httpSettings->SetLong (RIASettingsKeys::HTTP::compressionMaxThreshold, fCompressionMaxThreshold);
/* Keep-Alive settings */
httpSettings->SetBool (RIASettingsKeys::HTTP::acceptKeepAliveConnections, fEnableKeepAlive);
httpSettings->SetLong (RIASettingsKeys::HTTP::maximumTimeout, fKeepAliveTimeout);
httpSettings->SetLong (RIASettingsKeys::HTTP::maximumRequestsByConnection, fKeepAliveMaxConnections);
/* Log settings */
XBOX::VString logFormatName;
HTTPServerTools::GetLogFormatName ((EHTTPServerLogFormat)fLogFormat, logFormatName);
posixPath.Clear();
fLogFolderPath.GetPosixPath (posixPath);
httpSettings->SetString (RIASettingsKeys::HTTP::logFormat, logFormatName);
httpSettings->SetString (RIASettingsKeys::HTTP::logPath, posixPath);
httpSettings->SetString (RIASettingsKeys::HTTP::logFileName, fLogFileName);
httpSettings->SetLong (RIASettingsKeys::HTTP::logMaxSize, GetLogMaxSize());
/* Log Tokens settings */
XBOX::VBagArray *logTokenSettings = new XBOX::VBagArray ();
if (NULL != logTokenSettings)
{
XBOX::VTaskLock lock (&fLogTokensVectorLock);
XBOX::VString tokenName;
for (VectorOfLogToken::const_iterator it = fLogTokensVector.begin(); it != fLogTokensVector.end(); ++it)
{
XBOX::VValueBag *bag = new XBOX::VValueBag ();
if (NULL != bag)
{
HTTPServerTools::GetLogTokenName (*it, tokenName);
bag->SetString (RIASettingsKeys::HTTP::Log::field, tokenName);
logTokenSettings->AddTail (bag);
bag->Release();
}
}
if (logTokenSettings->GetCount())
httpSettings->SetElements (RIASettingsKeys::HTTP::Log::kXmlElement, logTokenSettings);
XBOX::ReleaseRefCountable (&logTokenSettings);
}
//.........这里部分代码省略.........
示例6: FromString
void VHTTPCookie::FromString (const XBOX::VString& inString)
{
XBOX::VectorOfVString stringValues;
XBOX::VString string;
XBOX::VString nameString;
XBOX::VString valueString;
Clear();
inString.GetSubStrings (CHAR_SEMICOLON, stringValues, false, true);
for (VectorOfVString::iterator it = stringValues.begin(); it != stringValues.end(); ++it)
{
sLONG pos = 0;
string.FromString (*it);
if ((pos = HTTPTools::FindASCIICString (string, "secure")) == 1)
{
SetSecure (true);
}
else if ((pos = HTTPTools::FindASCIICString (string, "httpOnly")) == 1)
{
SetHttpOnly (true);
}
else if ((pos = HTTPTools::FindASCIICString (string, "version")) == 1)
{
SetVersion (1);
}
else if ((pos = HTTPTools::FindASCIICString (string, "max-age")) == 1)
{
HTTPTools::ExtractFieldNameValue (string, nameString, valueString);
fMaxAge = valueString.GetLong();
}
else if ((pos = HTTPTools::FindASCIICString (string, "expires")) == 1)
{
XBOX::VTime curTime;
XBOX::VTime expiresTime;
XBOX::VTime::Now (curTime);
HTTPTools::ExtractFieldNameValue (string, nameString, valueString);
expiresTime.FromRfc822String (valueString);
if (expiresTime.GetMilliseconds() > curTime.GetMilliseconds())
fMaxAge = (expiresTime.GetMilliseconds() - curTime.GetMilliseconds()) / 1000;
}
else if ((pos = HTTPTools::FindASCIICString (string, "path")) == 1)
{
HTTPTools::ExtractFieldNameValue (string, nameString, fPath);
}
else if ((pos = HTTPTools::FindASCIICString (string, "domain")) == 1)
{
HTTPTools::ExtractFieldNameValue (string, nameString, fDomain);
}
else if ((pos = HTTPTools::FindASCIICString (string, "comment")) == 1)
{
HTTPTools::ExtractFieldNameValue (string, nameString, fComment);
}
else if ((pos = HTTPTools::FindASCIICString (string, "=")))
{
HTTPTools::ExtractFieldNameValue (string, fName, fValue);
}
}
}