本文整理汇总了C++中xbox::VString::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ VString::Clear方法的具体用法?C++ VString::Clear怎么用?C++ VString::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xbox::VString
的用法示例。
在下文中一共展示了VString::Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TrimUniChar
void TrimUniChar (XBOX::VString& ioString, const UniChar inCharToTrim)
{
if (ioString.GetLength() > 0)
{
sLONG length = ioString.GetLength();
UniChar * data = (UniChar *)ioString.GetCPointer();
XBOX::VIndex leadingChars = 0;
XBOX::VIndex endingChars = 0;
for (UniChar *p = data, *end = (data + length); (p != end) && (*p == inCharToTrim); p++, leadingChars++);
for (UniChar *p = (data + length - 1), *start = (data - 1); (p != start) && (*p == inCharToTrim); p--, endingChars++);
if ((0 != leadingChars) || (0 != endingChars))
{
if ((leadingChars + endingChars) >= length)
{
ioString.Clear();
}
else
{
ioString.SubString (leadingChars + 1, length - leadingChars - endingChars);
}
}
}
}
示例2: GetSubString
void GetSubString (const XBOX::VString& inString, sLONG inFirst, sLONG inLast, XBOX::VString& outString)
{
if (testAssert ((inFirst >= 0) && (inLast < inString.GetLength())))
outString.FromBlock (inString.GetCPointer() + inFirst, (inLast - inFirst + 1) * sizeof(UniChar), XBOX::VTC_UTF_16);
else
outString.Clear();
}
示例3: GetFormatedDateTimeString
static
void GetFormatedDateTimeString (const XBOX::VTime& inTime, XBOX::VString &outDateTimeString)
{
sLONG8 ms = inTime.GetMilliseconds() - (inTime.GetJulianDay() * 24 * 60 * 60 * 1000);
outDateTimeString.Clear();
outDateTimeString.Printf ("D%04d%02d%02dT%08d",
inTime.GetLocalYear(),
inTime.GetLocalMonth(),
inTime.GetLocalDay(),
ms);
}
示例4: MakeHostString
void MakeHostString (const XBOX::VString& inHost, PortNumber inPort, XBOX::VString& outHostString)
{
outHostString.Clear();
if (!inHost.IsEmpty())
outHostString.AppendString (inHost);
if (inPort != DEFAULT_LISTENING_PORT)
{
outHostString.AppendUniChar (CHAR_COLON);
outHostString.AppendLong (inPort);
}
}
示例5: MakeIPv4AddressString
void MakeIPv4AddressString (IP4 inIPv4, XBOX::VString& outIPv4String)
{
struct in_addr addr = {0};
char * buffer = NULL;
addr.s_addr = htonl (inIPv4);
buffer = inet_ntoa (addr);
if (NULL != buffer)
outIPv4String.AppendCString (buffer);
else
outIPv4String.Clear();
}
示例6: _GetCurrentFormatedTime
void VHTTPServerLog::_GetCurrentFormatedTime (XBOX::VString& outTimeString, bool inLocalTime)
{
sWORD year, month, day, hour, minute, seconds, milliseconds;
XBOX::VTime time;
time.FromSystemTime(); // GMT time
if (inLocalTime)
time.GetLocalTime (year, month, day, hour, minute, seconds, milliseconds);
else
time.GetUTCTime (year, month, day, hour, minute, seconds, milliseconds);
outTimeString.Clear();
outTimeString.Printf ("%02d:%02d:%02d", hour, minute, seconds);
}
示例7: _GetCurrentFormatedDate
void VHTTPServerLog::_GetCurrentFormatedDate (XBOX::VString& outDateString, bool inLocalTime, const char inDateSeparator)
{
sWORD year, month, day, hour, minute, seconds, milliseconds;
XBOX::VTime time;
time.FromSystemTime(); // GMT time
if (inLocalTime)
time.GetLocalTime (year, month, day, hour, minute, seconds, milliseconds);
else
time.GetUTCTime (year, month, day, hour, minute, seconds, milliseconds);
outDateString.Clear();
outDateString.Printf ("%04d%c%02d%c%02d %02d:%02d:%02d", year, inDateSeparator,
month, inDateSeparator, day,
hour, minute, seconds);
}
示例8: GetLogTokenNamesList
void GetLogTokenNamesList (const VectorOfLogToken& inLogTokens, XBOX::VString& outTokenNames, const UniChar inSeparator)
{
XBOX::VString string;
VectorOfLogToken::const_iterator nextToken = inLogTokens.begin();
outTokenNames.Clear();
for (VectorOfLogToken::const_iterator it = inLogTokens.begin(); it != inLogTokens.end(); ++it)
{
GetLogTokenName (*it, string);
outTokenNames.AppendString (string);
nextToken = it;
if (++nextToken != inLogTokens.end())
outTokenNames.AppendUniChar (CHAR_SPACE);
}
}
示例9: GetDescription
void VProjectItemFile::GetDescription( XBOX::VString& outDescription) const
{
outDescription.Clear();
if (fOwner != NULL)
{
VString extension;
fOwner->GetExtension( extension);
VFileKind *itemKind = VFileKindManager::Get()->RetainFirstFileKindMatchingWithExtension( extension);
if (itemKind != NULL)
{
outDescription = itemKind->GetDescription();
ReleaseRefCountable( &itemKind);
}
}
}
示例10: _GetRFC1123DateString
BEGIN_TOOLBOX_NAMESPACE
USING_TOOLBOX_NAMESPACE
//--------------------------------------------------------------------------------------------------
static
void _GetRFC1123DateString (const XBOX::VTime& inDate, XBOX::VString& outString)
{
sWORD year, month, day, hour, minute, second, millisecond;
inDate.GetUTCTime (year, month, day, hour, minute, second, millisecond);
outString.Clear();
switch (inDate.GetWeekDay())
{
case 0: outString.AppendCString ("Sun"); break;
case 1: outString.AppendCString ("Mon"); break;
case 2: outString.AppendCString ("Tue"); break;
case 3: outString.AppendCString ("Wed"); break;
case 4: outString.AppendCString ("Thu"); break;
case 5: outString.AppendCString ("Fri"); break;
case 6: outString.AppendCString ("Sat"); break;
}
outString.AppendPrintf (", %02d-", day);
switch (month)
{
case 1: outString.AppendCString ("Jan"); break;
case 2: outString.AppendCString ("Feb"); break;
case 3: outString.AppendCString ("Mar"); break;
case 4: outString.AppendCString ("Apr"); break;
case 5: outString.AppendCString ("May"); break;
case 6: outString.AppendCString ("Jun"); break;
case 7: outString.AppendCString ("Jul"); break;
case 8: outString.AppendCString ("Aug"); break;
case 9: outString.AppendCString ("Sep"); break;
case 10: outString.AppendCString ("Oct"); break;
case 11: outString.AppendCString ("Nov"); break;
case 12: outString.AppendCString ("Dec"); break;
}
outString.AppendPrintf ("-%04d %02d:%02d:%02d GMT", year, hour, minute, second);
}
示例11: _MakeDateString
void VHTTPServerLog::_MakeDateString (const XBOX::VTime& inTime, XBOX::VString& outDateString)
{
/* See description: http://httpd.apache.org/docs/2.2/logs.html#common
[day/month/year:hour:minute:second zone]
day = 2*digit
month = 3*letter
year = 4*digit
hour = 2*digit
minute = 2*digit
second = 2*digit
zone = (`+' | `-') 4*digit
*/
sWORD year = 0, month = 0, day = 0, hour = 0, minute = 0, seconds = 0, milliseconds = 0;
static sLONG sGMTOffSet = 0;
static bool sGMTOffSetUndefined = true;
inTime.GetUTCTime (year, month, day, hour, minute, seconds, milliseconds);
if (sGMTOffSetUndefined)
{
sGMTOffSet = (XBOX::VSystem::GetGMTOffset (true) / (3600));
sGMTOffSetUndefined = false;
}
outDateString.Clear();
outDateString.Printf ( "%02d/%s/%04d:%02d:%02d:%02d %c%02ld00",
day,
CONST_ABBREVIATED_ENGLISH_MONTH_NAMES[month],
year,
hour,
minute,
seconds,
(sGMTOffSet >= 0) ? '+' : '-',
sGMTOffSet);
}
示例12: _WriteWLF_ELF
XBOX::VError VHTTPServerLog::_WriteWLF_ELF (const IHTTPResponse& inHTTPResponse)
{
XBOX::VString string;
XBOX::VString ipAddress;
const VectorOfLogToken tokens = fSettings.GetLogTokens();
const EHTTPServerLogFormat format = fSettings.GetLogFormat();
for (VectorOfLogToken::const_iterator it = tokens.begin(); it != tokens.end(); ++it)
{
switch (*it)
{
case LOG_TOKEN_DATE:
string.Clear();
if (format == LOG_FORMAT_ELF)
{
_GetCurrentFormatedDate (string, false);
}
else
{
_GetCurrentFormatedDate (string, true, HTTP_SOLIDUS);
}
if (!string.IsEmpty())
{
fRequestsBuffer.AppendString (string);
}
else
{
fRequestsBuffer.AppendUniChar (CHAR_HYPHEN_MINUS);
}
break;
case LOG_TOKEN_TIME:
string.Clear();
if (format == LOG_FORMAT_WLF)
_GetCurrentFormatedTime (string, true);
else
_GetCurrentFormatedTime (string, false);
fRequestsBuffer.AppendString (string);
break;
case LOG_TOKEN_STATUS:
string.FromLong ((sLONG)inHTTPResponse.GetResponseStatusCode());
fRequestsBuffer.AppendString (string);
break;
case LOG_TOKEN_ELF_S_IP:
string.Clear();
HTTPServerTools::MakeIPv4String (inHTTPResponse.GetIPv4(), string);
fRequestsBuffer.AppendString (string);
break;
case LOG_TOKEN_HOST_NAME: // = C_DNS .....
case LOG_TOKEN_ELF_C_DNS: // DNS lookup : tres couteux en perf : remplacé par l'IP du client (les analyseurs de log font le DNS lookup)...
case LOG_TOKEN_ELF_C_IP: // Client IP Address 192.0.1.3
string.Clear();
HTTPServerTools::MakeIPv4String (inHTTPResponse.GetIPv4(), string);
fRequestsBuffer.AppendString (string);
break;
case LOG_TOKEN_METHOD: // The HTTP method : GET HEAD POST. If Unknown, we just copy it
string.Clear();
HTTPProtocol::MakeHTTPMethodString (inHTTPResponse.GetRequest().GetRequestMethod(), string);
fRequestsBuffer.AppendString (string);
break;
case LOG_TOKEN_BYTES_SENT: //WLF : Bytes sent to the client : = HTTP Content Length
string.Clear();
if (inHTTPResponse.GetResponseHeader (STRING_HEADER_CONTENT_LENGTH, string) && !string.IsEmpty())
fRequestsBuffer.AppendString (string);
else
fRequestsBuffer.AppendUniChar (CHAR_DIGIT_ZERO);
break;
case LOG_TOKEN_AGENT: // The identity of the browser software or other client. Mozilla/4.04_(Macintosh;_U;_PPC)
string.Clear();
if (inHTTPResponse.GetRequest().GetHTTPHeaders().GetHeaderValue (STRING_HEADER_USER_AGENT, string) && !string.IsEmpty())
{
string.Exchange (CHAR_SPACE, CHAR_LOW_LINE);
fRequestsBuffer.AppendString (string);
}
else
{
fRequestsBuffer.AppendUniChar (CHAR_HYPHEN_MINUS);
}
break;
case LOG_TOKEN_CS_USER_AGENT: // HTTP request's "User-Agent" header field. "Mozilla/4.04 (Macintosh; U; PPC)"
string.Clear();
inHTTPResponse.GetRequest().GetHTTPHeaders().GetHeaderValue (STRING_HEADER_USER_AGENT, string);
fRequestsBuffer.AppendUniChar (CHAR_QUOTATION_MARK);
fRequestsBuffer.AppendString (string);
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;
//.........这里部分代码省略.........
示例13: _WriteCLF_DLF
XBOX::VError VHTTPServerLog::_WriteCLF_DLF (const IHTTPResponse& inHTTPResponse)
{
XBOX::VString string;
XBOX::VTime time;
// GMT time
time.FromSystemTime();
// Client IP address
HTTPServerTools::MakeIPv4String (inHTTPResponse.GetIPv4(), string);
fRequestsBuffer.AppendString (string);
fRequestsBuffer.AppendUniChar (CHAR_SPACE);
// RFC931
fRequestsBuffer.AppendUniChar (CHAR_HYPHEN_MINUS);
fRequestsBuffer.AppendUniChar (CHAR_SPACE);
// AuthUser
XBOX::VString userName;
inHTTPResponse.GetRequest().GetAuthenticationInfos()->GetUserName (userName);
if (userName.IsEmpty())
fRequestsBuffer.AppendUniChar (CHAR_HYPHEN_MINUS);
else
fRequestsBuffer.AppendString (userName);
fRequestsBuffer.AppendUniChar (CHAR_SPACE);
// Date & Time
string.Clear();
_MakeDateString (time, string);
fRequestsBuffer.AppendUniChar (CHAR_LEFT_SQUARE_BRACKET);
fRequestsBuffer.AppendString (string);
fRequestsBuffer.AppendUniChar (CHAR_RIGHT_SQUARE_BRACKET);
fRequestsBuffer.AppendUniChar (CHAR_SPACE);
// HTTP Request
fRequestsBuffer.AppendUniChar (CHAR_QUOTATION_MARK);
fRequestsBuffer.AppendString (inHTTPResponse.GetRequest().GetRequestLine());
fRequestsBuffer.AppendUniChar (CHAR_QUOTATION_MARK);
fRequestsBuffer.AppendUniChar (CHAR_SPACE);
// HTTP Status
string.Clear();
string.FromLong ((sLONG)inHTTPResponse.GetResponseStatusCode());
fRequestsBuffer.AppendString (string);
fRequestsBuffer.AppendUniChar (CHAR_SPACE);
// HTTP Content Length
string.Clear();
if (!inHTTPResponse.GetResponseHeader (STRING_HEADER_CONTENT_LENGTH, string) || string.IsEmpty())
string.FromLong(0);
fRequestsBuffer.AppendString (string);
// We add the last fields for the DLF log format
if (fSettings.GetLogFormat() == LOG_FORMAT_DLF)
{
// HTTP Referrer
string.Clear();
fRequestsBuffer.AppendUniChar (CHAR_SPACE);
inHTTPResponse.GetRequest().GetHTTPHeaders().GetHeaderValue (STRING_HEADER_REFERER, string);
fRequestsBuffer.AppendUniChar (CHAR_QUOTATION_MARK);
fRequestsBuffer.AppendString (string);
fRequestsBuffer.AppendUniChar (CHAR_QUOTATION_MARK);
fRequestsBuffer.AppendUniChar (CHAR_SPACE);
// HTTP User-Agent
string.Clear();
inHTTPResponse.GetRequest().GetHTTPHeaders().GetHeaderValue (STRING_HEADER_USER_AGENT, string);
fRequestsBuffer.AppendUniChar (CHAR_QUOTATION_MARK);
fRequestsBuffer.AppendString (string);
fRequestsBuffer.AppendUniChar (CHAR_QUOTATION_MARK);
}
fRequestsBuffer.AppendUniChar (HTTP_LF);
return XBOX::VE_OK;
}
示例14: _WriteCatalog
//ACI0078887 23rd Nov 2012, O.R., always specify folder used for computing relative path of entry in TOC
VError VArchiveStream::_WriteCatalog( const VFile* inFile, const XBOX::VFilePath& inSourceFolder,const VString &inExtraInfo, uLONG8 &ioTotalByteCount )
{
VString fileInfo;
VStr8 slash("/");
VStr8 extra("::");
VStr8 folderSep(XBOX::FOLDER_SEPARATOR);
VError result = VE_INVALID_PARAMETER;
XBOX::VString savedExtraInfo = inExtraInfo;
//ACI0078887 23rd Nov 2012, O.R., compute relative path using the specified source folder
//don't assume that extra info carries relative folder info
//ACI0078887 23rd Nov 2012, O.R., compute relative path using the specified source folder
//don't assume that extra info carries relative folder info
if (savedExtraInfo == PRESERVE_PARENT_OPTION)
{
//this is a bogus extra info that we use internally so we need to clear it so that it is not saved into
//the archive.
//This options means that the file will have to be restored in with its parent directory preserved.
savedExtraInfo.Clear();
VFolder *folder = inFile->RetainParentFolder();
VString fileName;
folder->GetName(fileInfo);
// folder name can be a drive letter like Z:
fileInfo.Exchange( (UniChar) ':', (UniChar) '_');
inFile->GetName(fileName);
fileInfo += slash;
fileInfo += fileName;
fileInfo.Insert( slash, 1 );
folder->Release();
result = VE_OK;
}
else
{
if(testAssert(inFile->GetPath().GetRelativePath(inSourceFolder,fileInfo)))
{
result = VE_OK;
fileInfo.Insert( FOLDER_SEPARATOR, 1);
}
}
if(result == VE_OK)
{
fileInfo.Exchange(folderSep ,slash, 1, 255);
if ( fileInfo.GetUniChar(1) == '/' )
fileInfo.Insert( '.', 1 );
fileInfo += extra;
fileInfo += savedExtraInfo;
result = fStream->PutLong('file');
if ( result == VE_OK )
{
result = fileInfo.WriteToStream(fStream);
}
if ( result == VE_OK )
{
sLONG8 fileSize = 0;
inFile->GetSize(&fileSize);
fStream->PutLong8(fileSize);
ioTotalByteCount += fileSize;
#if VERSIONWIN || VERSION_LINUX
/* rez file size */
fStream->PutLong8(0);
/* no file kind or creator under Windows */
fStream->PutLong(0); /* kind */
fStream->PutLong(0); /* creator */
#elif VERSIONMAC
inFile->GetResourceForkSize(&fileSize);
fStream->PutLong8(fileSize);
ioTotalByteCount += fileSize;
OsType osType;
inFile->MAC_GetKind( &osType );
result = fStream->PutLong( osType );
inFile->MAC_GetCreator( &osType );
result = fStream->PutLong( osType );
#endif
}
}
return result;
}
示例15: 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);
}
//.........这里部分代码省略.........