本文整理汇总了C++中CPLStringList::Count方法的典型用法代码示例。如果您正苦于以下问题:C++ CPLStringList::Count方法的具体用法?C++ CPLStringList::Count怎么用?C++ CPLStringList::Count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPLStringList
的用法示例。
在下文中一共展示了CPLStringList::Count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ensure
void object::test<9>()
{
// Test some name=value handling stuff *with* sorting active.
CPLStringList oNVL;
oNVL.Sort();
oNVL.AddNameValue( "KEY1", "VALUE1" );
oNVL.AddNameValue( "2KEY", "VALUE2" );
ensure_equals( "91", oNVL.Count(), 2 );
ensure( "92", EQUAL(oNVL.FetchNameValue("KEY1"),"VALUE1") );
ensure( "93", EQUAL(oNVL.FetchNameValue("2KEY"),"VALUE2") );
ensure( "94", oNVL.FetchNameValue("MISSING") == NULL );
oNVL.AddNameValue( "KEY1", "VALUE3" );
ensure_equals( "95", oNVL.Count(), 3 );
ensure( "96", EQUAL(oNVL.FetchNameValue("KEY1"),"VALUE1") );
ensure( "97", EQUAL(oNVL.FetchNameValueDef("MISSING","X"),"X") );
oNVL.SetNameValue( "2KEY", "VALUE4" );
ensure( "98", EQUAL(oNVL.FetchNameValue("2KEY"),"VALUE4") );
ensure_equals( "99", oNVL.Count(), 3 );
// make sure deletion works.
oNVL.SetNameValue( "2KEY", NULL );
ensure( "9a", oNVL.FetchNameValue("2KEY") == NULL );
ensure_equals( "9b", oNVL.Count(), 2 );
// Test insertion logic pretty carefully.
oNVL.Clear();
ensure( "9c", oNVL.IsSorted() == TRUE );
oNVL.SetNameValue( "B", "BB" );
oNVL.SetNameValue( "A", "AA" );
oNVL.SetNameValue( "D", "DD" );
oNVL.SetNameValue( "C", "CC" );
// items should be in sorted order.
ensure( "9c1", EQUAL(oNVL[0],"A=AA") );
ensure( "9c2", EQUAL(oNVL[1],"B=BB") );
ensure( "9c3", EQUAL(oNVL[2],"C=CC") );
ensure( "9c4", EQUAL(oNVL[3],"D=DD") );
ensure( "9d", EQUAL(oNVL.FetchNameValue("A"),"AA") );
ensure( "9e", EQUAL(oNVL.FetchNameValue("B"),"BB") );
ensure( "9f", EQUAL(oNVL.FetchNameValue("C"),"CC") );
ensure( "9g", EQUAL(oNVL.FetchNameValue("D"),"DD") );
}
示例2: ParseRuleString
bool GNMRule::ParseRuleString()
{
CPLStringList aTokens (CSLTokenizeString2(m_soRuleString.c_str(), " ", CSLT_STRIPLEADSPACES |
CSLT_STRIPENDSPACES));
// the minimum rule consist 3 tokens
int nTokenCount = aTokens.Count();
if(nTokenCount < 3)
{
CPLError( CE_Failure, CPLE_IllegalArg, "Need more than %d tokens. Failed to parse rule: %s",
nTokenCount, m_soRuleString.c_str() );
return false;
}
if(EQUAL(aTokens[0], GNM_RULEKW_ALLOW))
m_bAllow = true;
else if(EQUAL(aTokens[0], GNM_RULEKW_DENY))
m_bAllow = false;
else
{
CPLError( CE_Failure, CPLE_IllegalArg, "First token is invalid. Failed to parse rule: %s",
m_soRuleString.c_str() );
return false;
}
// now just test if the value == connects
// in future should set rule type
if(!EQUAL(aTokens[1], GNM_RULEKW_CONNECTS))
{
CPLError( CE_Failure, CPLE_IllegalArg, "Not a CONNECTS rule. Failed to parse rule: %s",
m_soRuleString.c_str() );
return false;
}
if(EQUAL(aTokens[2], GNM_RULEKW_ANY))
{
m_bAny = true;
return true;
}
else
{
if(nTokenCount < 5)
{
CPLError( CE_Failure, CPLE_IllegalArg, "Not an ANY rule, but have only %d tokens. Failed to parse rule: %s",
nTokenCount, m_soRuleString.c_str() );
return false;
}
m_soSrcLayerName = aTokens[2];
m_soTgtLayerName = aTokens[4];
}
if(nTokenCount < 7) // skip 5 and 6 parameters
return true;
else
m_soConnLayerName = aTokens[6];
return true;
}
示例3: oCopy
void object::test<7>()
{
CPLStringList oCSL;
ensure( "7nil", oCSL.List() == NULL );
oCSL.AddString( "def" );
oCSL.AddString( "abc" );
ensure_equals( "7", oCSL.Count(), 2 );
ensure( "70", EQUAL(oCSL[0], "def") );
ensure( "71", EQUAL(oCSL[1], "abc") );
ensure( "72", oCSL[17] == NULL );
ensure( "73", oCSL[-1] == NULL );
ensure_equals( "74", oCSL.FindString("abc"), 1 );
CSLDestroy( oCSL.StealList() );
ensure_equals( "75", oCSL.Count(), 0 );
ensure( "76", oCSL.List() == NULL );
// Test that the list will make an internal copy when needed to
// modify a read-only list.
oCSL.AddString( "def" );
oCSL.AddString( "abc" );
CPLStringList oCopy( oCSL.List(), FALSE );
ensure_equals( "77", oCSL.List(), oCopy.List() );
ensure_equals( "78", oCSL.Count(), oCopy.Count() );
oCopy.AddString( "xyz" );
ensure( "79", oCSL.List() != oCopy.List() );
ensure_equals( "7a", oCopy.Count(), 3 );
ensure_equals( "7b", oCSL.Count(), 2 );
ensure( "7c", EQUAL(oCopy[2], "xyz") );
}