本文整理汇总了C++中CPLStringList::StealList方法的典型用法代码示例。如果您正苦于以下问题:C++ CPLStringList::StealList方法的具体用法?C++ CPLStringList::StealList怎么用?C++ CPLStringList::StealList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPLStringList
的用法示例。
在下文中一共展示了CPLStringList::StealList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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") );
}
示例2: XMLInit
CPLErr VRTRasterBand::XMLInit( CPLXMLNode * psTree,
const char *pszVRTPath )
{
/* -------------------------------------------------------------------- */
/* Validate a bit. */
/* -------------------------------------------------------------------- */
if( psTree == NULL || psTree->eType != CXT_Element
|| !EQUAL(psTree->pszValue,"VRTRasterBand") )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Invalid node passed to VRTRasterBand::XMLInit()." );
return CE_Failure;
}
/* -------------------------------------------------------------------- */
/* Set the band if provided as an attribute. */
/* -------------------------------------------------------------------- */
const char* pszBand = CPLGetXMLValue( psTree, "band", NULL);
if( pszBand != NULL )
{
nBand = atoi(pszBand);
}
/* -------------------------------------------------------------------- */
/* Set the band if provided as an attribute. */
/* -------------------------------------------------------------------- */
const char *pszDataType = CPLGetXMLValue( psTree, "dataType", NULL);
if( pszDataType != NULL )
{
eDataType = GDALGetDataTypeByName(pszDataType);
}
/* -------------------------------------------------------------------- */
/* Apply any band level metadata. */
/* -------------------------------------------------------------------- */
oMDMD.XMLInit( psTree, TRUE );
/* -------------------------------------------------------------------- */
/* Collect various other items of metadata. */
/* -------------------------------------------------------------------- */
SetDescription( CPLGetXMLValue( psTree, "Description", "" ) );
if( CPLGetXMLValue( psTree, "NoDataValue", NULL ) != NULL )
SetNoDataValue( CPLAtofM(CPLGetXMLValue( psTree, "NoDataValue", "0" )) );
if( CPLGetXMLValue( psTree, "HideNoDataValue", NULL ) != NULL )
bHideNoDataValue = CSLTestBoolean( CPLGetXMLValue( psTree, "HideNoDataValue", "0" ) );
SetUnitType( CPLGetXMLValue( psTree, "UnitType", NULL ) );
SetOffset( atof(CPLGetXMLValue( psTree, "Offset", "0.0" )) );
SetScale( atof(CPLGetXMLValue( psTree, "Scale", "1.0" )) );
if( CPLGetXMLValue( psTree, "ColorInterp", NULL ) != NULL )
{
const char *pszInterp = CPLGetXMLValue( psTree, "ColorInterp", NULL );
SetColorInterpretation(GDALGetColorInterpretationByName(pszInterp));
}
/* -------------------------------------------------------------------- */
/* Category names. */
/* -------------------------------------------------------------------- */
if( CPLGetXMLNode( psTree, "CategoryNames" ) != NULL )
{
CPLXMLNode *psEntry;
CSLDestroy( papszCategoryNames );
papszCategoryNames = NULL;
CPLStringList oCategoryNames;
for( psEntry = CPLGetXMLNode( psTree, "CategoryNames" )->psChild;
psEntry != NULL; psEntry = psEntry->psNext )
{
if( psEntry->eType != CXT_Element
|| !EQUAL(psEntry->pszValue,"Category")
|| (psEntry->psChild != NULL && psEntry->psChild->eType != CXT_Text) )
continue;
oCategoryNames.AddString(
(psEntry->psChild) ? psEntry->psChild->pszValue : "");
}
papszCategoryNames = oCategoryNames.StealList();
}
/* -------------------------------------------------------------------- */
/* Collect a color table. */
/* -------------------------------------------------------------------- */
if( CPLGetXMLNode( psTree, "ColorTable" ) != NULL )
{
CPLXMLNode *psEntry;
GDALColorTable oTable;
int iEntry = 0;
for( psEntry = CPLGetXMLNode( psTree, "ColorTable" )->psChild;
psEntry != NULL; psEntry = psEntry->psNext )
{
GDALColorEntry sCEntry;
//.........这里部分代码省略.........