本文整理汇总了C++中nglString::Find方法的典型用法代码示例。如果您正苦于以下问题:C++ nglString::Find方法的具体用法?C++ nglString::Find怎么用?C++ nglString::Find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nglString
的用法示例。
在下文中一共展示了nglString::Find方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetAbsoluteURL
void nuiHTML::GetAbsoluteURL(const nglString& rBaseURL, nglString& url)
{
int32 colon = url.Find(':');
if (colon > 0)
{
// complete url link
}
else if (url[0] == '/')
{
// Site absolute
int32 col = rBaseURL.Find(_T("://"));
if (col > 0)
{
int32 end = rBaseURL.Find('/', col + 3);
if (end)
url = rBaseURL.Extract(0, end) + url;
}
}
else
{
// Site relative
int32 end = rBaseURL.FindLast(_T('/'));
if (end >= 0)
{
url = rBaseURL.Extract(0, end + 1) + url;
}
else
{
url = rBaseURL + _T("/") + url;
}
}
Canonize(url);
}
示例2: SetConstraint
void nuiLayout::SetConstraint(nuiWidget* pWidget, const nglString& rDescription)
{
nuiLayoutConstraint constraintH, constraintV;
int pos = rDescription.Find('/');
if (pos < 0)
{
nglString desc(rDescription);
desc.Trim();
constraintH.Set(desc);
}
else if (pos == 0)
{
nglString desc2 = rDescription.Extract(pos+1, rDescription.GetLength() - (pos + 1));
desc2.Trim();
constraintV.Set(desc2);
}
else
{
nglString desc1 = rDescription.Extract(0, pos);
nglString desc2 = rDescription.Extract(pos+1, rDescription.GetLength() - (pos + 1));
desc1.Trim();
desc2.Trim();
constraintH.Set(desc1);
constraintV.Set(desc2);
}
SetConstraint(pWidget, constraintH, constraintV);
}
示例3: MIN
// Stolen from nglPath!
static int32 GetRootPart(const nglString& rStr)
{
if (rStr[0] == _T('/'))
{
if (rStr[1] != _T('/'))
return 1;
// //host[/path] (network address)
// or /volume[/path] (standard unix like path)
int32 end = rStr.Find(_T('/'), 2);
return ((end > 0) ? end : rStr.GetLength());
}
// Find the protocol name:
int col = rStr.Find(_T("://"), 0, true);
return MIN(col + 3, rStr.GetLength());
}
示例4: Canonize
static bool Canonize(nglString& rStr)
{
nglString canon;
int32 len = rStr.GetLength();
int32 root_part = GetRootPart(rStr);
int32 last_slash = root_part;
int32 slash = 0;
canon = rStr.GetLeft(root_part);
while (slash < len)
{
slash = rStr.Find(_T('/'), last_slash);
if (slash == - 1)
slash = len;
if (((slash - last_slash) == 1) && (rStr.GetChar(last_slash) == _T('.')))
{
// Ignore '.'
}
else
if (((slash - last_slash) == 2) && (!rStr.Compare(_T(".."), last_slash, 2)))
{
// Interpret '..'
int32 prev_slash = canon.FindLast(_T('/'));
if (prev_slash < root_part)
prev_slash = root_part;
if (!canon.IsEmpty() && canon.Compare(_T(".."), canon.GetLength() - 2, 2))
canon.Delete(prev_slash);
else
{
if (canon.GetLength() > root_part)
canon += _T('/');
canon += _T("..");
}
}
else
{
// Simply append path node
nglString node = rStr.Extract(last_slash, (slash - last_slash));
if (canon.GetLength() > root_part)
canon += _T('/');
canon += node;
}
last_slash = slash + 1;
}
rStr = canon;
return true;
}
示例5: Find
nuiWidgetPtr nuiContainer::Find(const nglString& rName)
{
CheckValid();
int slash = rName.Find('/');
if (slash >= 0)
{
nglString path = rName.GetLeft(slash);
nglString rest = rName.Extract(slash + 1);
nuiWidgetPtr node = SearchForChild(path, false);
return node ? node->Find(rest) : NULL;
}
else
return SearchForChild(rName,false);
}