本文整理汇总了C++中NPT_String::ReverseFind方法的典型用法代码示例。如果您正苦于以下问题:C++ NPT_String::ReverseFind方法的具体用法?C++ NPT_String::ReverseFind怎么用?C++ NPT_String::ReverseFind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NPT_String
的用法示例。
在下文中一共展示了NPT_String::ReverseFind方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*----------------------------------------------------------------------
| PLT_DeviceData::SetURLBase
+---------------------------------------------------------------------*/
NPT_Result
PLT_DeviceData::SetURLBase(NPT_HttpUrl& url)
{
// only http scheme supported
m_URLBase.SetScheme(url.GetScheme());
// update port if any
if (url.GetPort() != NPT_URL_INVALID_PORT) m_URLBase.SetPort(url.GetPort());
// update host if any
if (!url.GetHost().IsEmpty()) m_URLBase.SetHost(url.GetHost());
// update path
NPT_String path = url.GetPath();
// remove trailing file according to RFC 2396
if (!path.EndsWith("/")) {
int index = path.ReverseFind('/');
if (index < 0) return NPT_FAILURE;
path.SetLength(index+1);
}
m_URLBase.SetPath(path, true);
return NPT_SUCCESS;
}
示例2:
/*----------------------------------------------------------------------
| NPT_FilePath::BaseName
+---------------------------------------------------------------------*/
NPT_String
NPT_FilePath::BaseName(const char* path, bool with_extension /* = true */)
{
NPT_String result = path;
int separator = result.ReverseFind(Separator);
if (separator >= 0) {
result = path+separator+NPT_StringLength(Separator);
}
if (!with_extension) {
int dot = result.ReverseFind('.');
if (dot >= 0) {
result.SetLength(dot);
}
}
return result;
}
示例3:
/*----------------------------------------------------------------------
| NPT_FilePath::BaseName
+---------------------------------------------------------------------*/
NPT_String
NPT_FilePath::BaseName(const char* path)
{
NPT_String result = path;
int separator = result.ReverseFind(Separator);
if (separator >= 0) {
result = path+separator+NPT_StringLength(Separator);
}
return result;
}
示例4:
/*----------------------------------------------------------------------
| PLT_Didl::ParseTimeStamp
+---------------------------------------------------------------------*/
NPT_Result
PLT_Didl::ParseTimeStamp(const NPT_String& timestamp, NPT_UInt32& seconds)
{
// assume a timestamp in the format HH:MM:SS.FFF
int separator;
NPT_String str = timestamp;
NPT_UInt32 value;
// reset output params first
seconds = 0;
// remove milliseconds first if any
if ((separator = str.ReverseFind('.')) != -1) {
str = str.Left(separator);
}
// look for next separator
if ((separator = str.ReverseFind(':')) == -1) return NPT_FAILURE;
// extract seconds
NPT_CHECK_WARNING(str.SubString(separator+1).ToInteger(value));
seconds = value;
str = str.Left(separator);
// look for next separator
if ((separator = str.ReverseFind(':')) == -1) return NPT_FAILURE;
// extract minutes
NPT_CHECK_WARNING(str.SubString(separator+1).ToInteger(value));
seconds += 60*value;
str = str.Left(separator);
// extract hours
NPT_CHECK_WARNING(str.ToInteger(value));
seconds += 3600*value;
return NPT_SUCCESS;
}