本文整理汇总了C++中CSLTokenizeString函数的典型用法代码示例。如果您正苦于以下问题:C++ CSLTokenizeString函数的具体用法?C++ CSLTokenizeString怎么用?C++ CSLTokenizeString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CSLTokenizeString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
const char * E00GRIDRasterBand::GetUnitType()
{
E00GRIDDataset *poGDS = (E00GRIDDataset *) poDS;
poGDS->ReadMetadata();
if (poGDS->papszPrj == NULL)
return GDALPamRasterBand::GetUnitType();
char** papszIter = poGDS->papszPrj;
const char* pszRet = "";
while(*papszIter)
{
if (STARTS_WITH_CI(*papszIter, "Zunits"))
{
char** papszTokens = CSLTokenizeString(*papszIter);
if (CSLCount(papszTokens) == 2)
{
if (EQUAL(papszTokens[1], "FEET"))
pszRet = "ft";
else if (EQUAL(papszTokens[1], "METERS"))
pszRet = "m";
}
CSLDestroy(papszTokens);
break;
}
papszIter ++;
}
return pszRet;
}
示例2: CSLTokenizeString
GBool MIDDATAFile::IsValidFeature(const char *pszString)
{
char **papszToken ;
papszToken = CSLTokenizeString(pszString);
// printf("%s\n",pszString);
if (CSLCount(papszToken) == 0)
{
CSLDestroy(papszToken);
return FALSE;
}
if (EQUAL(papszToken[0],"NONE") || EQUAL(papszToken[0],"POINT") ||
EQUAL(papszToken[0],"LINE") || EQUAL(papszToken[0],"PLINE") ||
EQUAL(papszToken[0],"REGION") || EQUAL(papszToken[0],"ARC") ||
EQUAL(papszToken[0],"TEXT") || EQUAL(papszToken[0],"RECT") ||
EQUAL(papszToken[0],"ROUNDRECT") || EQUAL(papszToken[0],"ELLIPSE") ||
EQUAL(papszToken[0],"MULTIPOINT")|| EQUAL(papszToken[0],"COLLECTION") )
{
CSLDestroy(papszToken);
return TRUE;
}
CSLDestroy(papszToken);
return FALSE;
}
示例3: OSR_GDS
static CPLString OSR_GDS( char **papszNV, const char *pszField,
const char *pszDefaultValue )
{
if( papszNV == nullptr || papszNV[0] == nullptr )
return pszDefaultValue;
int iLine = 0; // Used after for.
for( ;
papszNV[iLine] != nullptr &&
!EQUALN(papszNV[iLine],pszField,strlen(pszField));
iLine++ ) {}
if( papszNV[iLine] == nullptr )
return pszDefaultValue;
else
{
char **papszTokens = CSLTokenizeString(papszNV[iLine]);
CPLString osResult;
if( CSLCount(papszTokens) > 1 )
osResult = papszTokens[1];
else
osResult = pszDefaultValue;
CSLDestroy(papszTokens);
return osResult;
}
}
示例4: CheckExtensionConsistency
void CheckExtensionConsistency(const char* pszDestFilename,
const char* pszDriverName)
{
char* pszDestExtension = CPLStrdup(CPLGetExtension(pszDestFilename));
if (pszDestExtension[0] != '\0')
{
int nDriverCount = GDALGetDriverCount();
CPLString osConflictingDriverList;
for(int i=0;i<nDriverCount;i++)
{
GDALDriverH hDriver = GDALGetDriver(i);
const char* pszDriverExtensions =
GDALGetMetadataItem( hDriver, GDAL_DMD_EXTENSIONS, NULL );
if( pszDriverExtensions )
{
char** papszTokens = CSLTokenizeString( pszDriverExtensions );
for(int j=0; papszTokens[j]; j++)
{
const char* pszDriverExtension = papszTokens[j];
if (EQUAL(pszDestExtension, pszDriverExtension))
{
if (GDALGetDriverByName(pszDriverName) != hDriver)
{
if (osConflictingDriverList.size())
osConflictingDriverList += ", ";
osConflictingDriverList += GDALGetDriverShortName(hDriver);
}
else
{
/* If the request driver allows the used extension, then */
/* just stop iterating now */
osConflictingDriverList = "";
break;
}
}
}
CSLDestroy(papszTokens);
}
}
if (osConflictingDriverList.size())
{
fprintf(stderr,
"Warning: The target file has a '%s' extension, which is normally used by the %s driver%s,\n"
"but the requested output driver is %s. Is it really what you want ?\n",
pszDestExtension,
osConflictingDriverList.c_str(),
strchr(osConflictingDriverList.c_str(), ',') ? "s" : "",
pszDriverName);
}
}
CPLFree(pszDestExtension);
}
示例5: atoi
CPLErr VRTKernelFilteredSource::XMLInit( CPLXMLNode *psTree,
const char *pszVRTPath,
void* pUniqueHandle,
std::map<CPLString, GDALDataset*>& oMapSharedSources )
{
{
const CPLErr eErr = VRTFilteredSource::XMLInit( psTree, pszVRTPath,
pUniqueHandle,
oMapSharedSources );
if( eErr != CE_None )
return eErr;
}
const int nNewKernelSize = atoi(CPLGetXMLValue(psTree,"Kernel.Size","0"));
if( nNewKernelSize == 0 )
return CE_None;
char **papszCoefItems =
CSLTokenizeString( CPLGetXMLValue(psTree,"Kernel.Coefs","") );
const int nCoefs = CSLCount(papszCoefItems);
const bool bSquare = nCoefs == nNewKernelSize * nNewKernelSize;
const bool bSeparable = nCoefs == nNewKernelSize && nCoefs != 1;
if( !bSquare && !bSeparable )
{
CSLDestroy( papszCoefItems );
CPLError( CE_Failure, CPLE_AppDefined,
"Got wrong number of filter kernel coefficients (%s). "
"Expected %d or %d, got %d.",
CPLGetXMLValue(psTree,"Kernel.Coefs",""),
nNewKernelSize * nNewKernelSize, nNewKernelSize, nCoefs );
return CE_Failure;
}
double *padfNewCoefs = static_cast<double *>(
CPLMalloc( sizeof(double) * nCoefs ) );
for( int i = 0; i < nCoefs; i++ )
padfNewCoefs[i] = CPLAtof(papszCoefItems[i]);
const CPLErr eErr = SetKernel( nNewKernelSize, bSeparable, padfNewCoefs );
CPLFree( padfNewCoefs );
CSLDestroy( papszCoefItems );
SetNormalized( atoi(CPLGetXMLValue(psTree,"Kernel.normalized","0")) );
return eErr;
}
示例6: CSLTokenizeString
std::vector<double>
OGRDXFWriterLayer::PrepareLineTypeDefinition( OGRStylePen *poPen )
{
/* -------------------------------------------------------------------- */
/* Fetch pattern. */
/* -------------------------------------------------------------------- */
GBool bDefault;
const char *pszPattern = poPen->Pattern( bDefault );
if( bDefault || strlen(pszPattern) == 0 )
return std::vector<double>();
/* -------------------------------------------------------------------- */
/* Split into pen up / pen down bits. */
/* -------------------------------------------------------------------- */
char **papszTokens = CSLTokenizeString(pszPattern);
std::vector<double> adfWeightTokens;
for( int i = 0; papszTokens != nullptr && papszTokens[i] != nullptr; i++ )
{
const char *pszToken = papszTokens[i];
CPLString osAmount;
CPLString osDXFEntry;
// Split amount and unit.
const char *pszUnit = pszToken; // Used after for.
for( ;
strchr( "0123456789.", *pszUnit) != nullptr;
pszUnit++ ) {}
osAmount.assign(pszToken,(int) (pszUnit-pszToken));
// If the unit is other than 'g' we really should be trying to
// do some type of transformation - but what to do? Pretty hard.
// Even entries are "pen down" represented as positive in DXF.
// "Pen up" entries (gaps) are represented as negative.
if( i%2 == 0 )
adfWeightTokens.push_back( CPLAtof( osAmount ) );
else
adfWeightTokens.push_back( -CPLAtof( osAmount ) );
}
CSLDestroy( papszTokens );
return adfWeightTokens;
}
示例7: while
void OGRXPlaneNavReader::Read()
{
const char* pszLine = NULL;
while( (pszLine = CPLReadLineL(fp)) != NULL )
{
papszTokens = CSLTokenizeString(pszLine);
nTokens = CSLCount(papszTokens);
nLineNumber++;
if (nTokens == 1 && strcmp(papszTokens[0], "99") == 0)
{
CSLDestroy(papszTokens);
papszTokens = NULL;
bEOF = true;
return;
}
else if( nTokens == 0 || !assertMinCol(9) )
{
CSLDestroy(papszTokens);
papszTokens = NULL;
continue;
}
const int nType = atoi(papszTokens[0]);
if (!((nType >= NAVAID_NDB && nType <= NAVAID_IM) ||
nType == NAVAID_DME_COLOC || nType == NAVAID_DME_STANDALONE))
{
CPLDebug("XPlane", "Line %d : bad feature code '%s'",
nLineNumber, papszTokens[0]);
CSLDestroy(papszTokens);
papszTokens = NULL;
continue;
}
ParseRecord(nType);
CSLDestroy(papszTokens);
papszTokens = NULL;
if( poInterestLayer && !poInterestLayer->IsEmpty() )
return;
}
papszTokens = NULL;
bEOF = true;
}
示例8: atoi
CPLErr VRTKernelFilteredSource::XMLInit( CPLXMLNode *psTree,
const char *pszVRTPath )
{
CPLErr eErr = VRTFilteredSource::XMLInit( psTree, pszVRTPath );
int nNewKernelSize, i, nCoefs;
double *padfNewCoefs;
if( eErr != CE_None )
return eErr;
nNewKernelSize = atoi(CPLGetXMLValue(psTree,"Kernel.Size","0"));
if( nNewKernelSize == 0 )
return CE_None;
char **papszCoefItems =
CSLTokenizeString( CPLGetXMLValue(psTree,"Kernel.Coefs","") );
nCoefs = CSLCount(papszCoefItems);
if( nCoefs != nNewKernelSize * nNewKernelSize )
{
CSLDestroy( papszCoefItems );
CPLError( CE_Failure, CPLE_AppDefined,
"Got wrong number of filter kernel coefficients (%s).\n"
"Expected %d, got %d.",
CPLGetXMLValue(psTree,"Kernel.Coefs",""),
nNewKernelSize * nNewKernelSize, nCoefs );
return CE_Failure;
}
padfNewCoefs = (double *) CPLMalloc(sizeof(double) * nCoefs);
for( i = 0; i < nCoefs; i++ )
padfNewCoefs[i] = CPLAtof(papszCoefItems[i]);
eErr = SetKernel( nNewKernelSize, padfNewCoefs );
CPLFree( padfNewCoefs );
CSLDestroy( papszCoefItems );
SetNormalized( atoi(CPLGetXMLValue(psTree,"Kernel.normalized","0")) );
return eErr;
}
示例9: while
char *PAuxDataset::PCI2WKT( const char *pszGeosys,
const char *pszProjParms )
{
OGRSpatialReference oSRS;
while( *pszGeosys == ' ' )
pszGeosys++;
/* -------------------------------------------------------------------- */
/* Parse projection parameters array. */
/* -------------------------------------------------------------------- */
double adfProjParms[16];
memset( adfProjParms, 0, sizeof(adfProjParms) );
if( pszProjParms != NULL )
{
char **papszTokens;
int i;
papszTokens = CSLTokenizeString( pszProjParms );
for( i=0; papszTokens != NULL && papszTokens[i] != NULL && i < 16; i++)
adfProjParms[i] = atof(papszTokens[i]);
CSLDestroy( papszTokens );
}
/* -------------------------------------------------------------------- */
/* Convert to SRS. */
/* -------------------------------------------------------------------- */
if( oSRS.importFromPCI( pszGeosys, NULL, adfProjParms ) == OGRERR_NONE )
{
char *pszResult = NULL;
oSRS.exportToWkt( &pszResult );
return pszResult;
}
else
return NULL;
}
示例10: DoesDriverHandleExtension
static bool DoesDriverHandleExtension( GDALDriverH hDriver, const char* pszExt )
{
bool bRet = false;
const char* pszDriverExtensions =
GDALGetMetadataItem( hDriver, GDAL_DMD_EXTENSIONS, NULL );
if( pszDriverExtensions )
{
char** papszTokens = CSLTokenizeString( pszDriverExtensions );
for(int j=0; papszTokens[j]; j++)
{
if( EQUAL(pszExt, papszTokens[j]) )
{
bRet = true;
break;
}
}
CSLDestroy(papszTokens);
}
return bRet;
}
示例11: while
char *PAuxDataset::PCI2WKT( const char *pszGeosys,
const char *pszProjParms )
{
while( *pszGeosys == ' ' )
pszGeosys++;
/* -------------------------------------------------------------------- */
/* Parse projection parameters array. */
/* -------------------------------------------------------------------- */
double adfProjParms[16] = { 0.0 };
if( pszProjParms != nullptr )
{
char **papszTokens = CSLTokenizeString( pszProjParms );
for( int i = 0;
i < 16 && papszTokens != nullptr && papszTokens[i] != nullptr;
i++ )
adfProjParms[i] = CPLAtof(papszTokens[i]);
CSLDestroy( papszTokens );
}
/* -------------------------------------------------------------------- */
/* Convert to SRS. */
/* -------------------------------------------------------------------- */
OGRSpatialReference oSRS;
if( oSRS.importFromPCI( pszGeosys, nullptr, adfProjParms ) == OGRERR_NONE )
{
char *pszResult = nullptr;
oSRS.exportToWkt( &pszResult );
return pszResult;
}
return nullptr;
}
示例12: CSLTokenizeString
OGRLayer* OGRTABDataSource::ExecuteSQL( const char *pszStatement,
OGRGeometry *poSpatialFilter,
const char *pszDialect )
{
char **papszTokens = CSLTokenizeString(pszStatement);
if( CSLCount(papszTokens) == 6 &&
EQUAL(papszTokens[0], "CREATE") &&
EQUAL(papszTokens[1], "INDEX") &&
EQUAL(papszTokens[2], "ON") &&
EQUAL(papszTokens[4], "USING") )
{
IMapInfoFile* poLayer = dynamic_cast<IMapInfoFile*>(
GetLayerByName(papszTokens[3]));
if( poLayer == nullptr )
{
CPLError(CE_Failure, CPLE_AppDefined,
"`%s' failed failed, no such layer as `%s'.",
pszStatement, papszTokens[3]);
CSLDestroy(papszTokens);
return nullptr;
}
int nFieldIdx = poLayer->GetLayerDefn()->GetFieldIndex(papszTokens[5]);
CSLDestroy(papszTokens);
if( nFieldIdx < 0 )
{
CPLError(CE_Failure, CPLE_AppDefined,
"`%s' failed, field not found.",
pszStatement);
return nullptr;
}
poLayer->SetFieldIndexed(nFieldIdx);
return nullptr;
}
CSLDestroy(papszTokens);
return GDALDataset::ExecuteSQL(pszStatement, poSpatialFilter, pszDialect);
}
示例13: while
void OGRXPlaneFixReader::Read()
{
const char* pszLine;
while((pszLine = CPLReadLine(fp)) != NULL)
{
papszTokens = CSLTokenizeString(pszLine);
nTokens = CSLCount(papszTokens);
nLineNumber ++;
if (nTokens == 1 && strcmp(papszTokens[0], "99") == 0)
{
CSLDestroy(papszTokens);
papszTokens = NULL;
bEOF = TRUE;
return;
}
else if (nTokens == 0 || assertMinCol(3) == FALSE)
{
CSLDestroy(papszTokens);
papszTokens = NULL;
continue;
}
ParseRecord();
CSLDestroy(papszTokens);
papszTokens = NULL;
if (poInterestLayer && poInterestLayer->IsEmpty() == FALSE)
return;
}
papszTokens = NULL;
bEOF = TRUE;
}
示例14: CPLAssert
int OGRGPSBabelDataSource::Open( const char * pszDatasourceName,
const char* pszGPSBabelDriverNameIn,
char** papszOpenOptionsIn )
{
if (!STARTS_WITH_CI(pszDatasourceName, "GPSBABEL:"))
{
CPLAssert(pszGPSBabelDriverNameIn);
pszGPSBabelDriverName = CPLStrdup(pszGPSBabelDriverNameIn);
pszFilename = CPLStrdup(pszDatasourceName);
}
else
{
if( CSLFetchNameValue(papszOpenOptionsIn, "FILENAME") )
pszFilename = CPLStrdup(CSLFetchNameValue(papszOpenOptionsIn,
"FILENAME"));
if( CSLFetchNameValue(papszOpenOptionsIn, "GPSBABEL_DRIVER") )
{
if( pszFilename == NULL )
{
CPLError(CE_Failure, CPLE_AppDefined, "Missing FILENAME");
return FALSE;
}
pszGPSBabelDriverName
= CPLStrdup(CSLFetchNameValue(papszOpenOptionsIn, "DRIVER"));
/* A bit of validation to avoid command line injection */
if (!IsValidDriverName(pszGPSBabelDriverName))
return FALSE;
}
}
pszName = CPLStrdup( pszDatasourceName );
bool bExplicitFeatures = false;
bool bWaypoints = true;
bool bTracks = true;
bool bRoutes = true;
if (pszGPSBabelDriverName == NULL)
{
const char* pszSep = strchr(pszDatasourceName + 9, ':');
if (pszSep == NULL)
{
CPLError( CE_Failure, CPLE_AppDefined,
"Wrong syntax. Expected GPSBabel:driver_name:file_name");
return FALSE;
}
pszGPSBabelDriverName = CPLStrdup(pszDatasourceName + 9);
*(strchr(pszGPSBabelDriverName, ':')) = '\0';
/* A bit of validation to avoid command line injection */
if (!IsValidDriverName(pszGPSBabelDriverName))
return FALSE;
/* Parse optional features= option */
if (STARTS_WITH_CI(pszSep+1, "features="))
{
const char* pszNextSep = strchr(pszSep+1, ':');
if (pszNextSep == NULL)
{
CPLError(CE_Failure, CPLE_AppDefined,
"Wrong syntax. Expected "
"GPSBabel:driver_name[,options]*:["
"features=waypoints,tracks,routes:]file_name");
return FALSE;
}
char* pszFeatures = CPLStrdup(pszSep+1+9);
*strchr(pszFeatures, ':') = 0;
char** papszTokens = CSLTokenizeString(pszFeatures);
char** papszIter = papszTokens;
bool bErr = false;
bExplicitFeatures = true;
bWaypoints = false;
bTracks = false;
bRoutes = false;
while(papszIter && *papszIter)
{
if (EQUAL(*papszIter, "waypoints"))
bWaypoints = true;
else if (EQUAL(*papszIter, "tracks"))
bTracks = true;
else if (EQUAL(*papszIter, "routes"))
bRoutes = true;
else
{
CPLError( CE_Failure, CPLE_AppDefined,
"Wrong value for 'features' options");
bErr = true;
}
papszIter++;
}
CSLDestroy(papszTokens);
CPLFree(pszFeatures);
if (bErr)
//.........这里部分代码省略.........
示例15: GetLayerByName
OGRLayer * OGRShapeDataSource::ExecuteSQL( const char *pszStatement,
OGRGeometry *poSpatialFilter,
const char *pszDialect )
{
/* ==================================================================== */
/* Handle command to drop a spatial index. */
/* ==================================================================== */
if( EQUALN(pszStatement, "REPACK ", 7) )
{
OGRShapeLayer *poLayer = (OGRShapeLayer *)
GetLayerByName( pszStatement + 7 );
if( poLayer != NULL )
poLayer->Repack();
else
{
CPLError( CE_Failure, CPLE_AppDefined,
"No such layer as '%s' in REPACK.",
pszStatement + 7 );
}
return NULL;
}
/* ==================================================================== */
/* Handle command to drop a spatial index. */
/* ==================================================================== */
if( EQUALN(pszStatement, "DROP SPATIAL INDEX ON ", 22) )
{
OGRShapeLayer *poLayer = (OGRShapeLayer *)
GetLayerByName( pszStatement + 22 );
if( poLayer != NULL )
poLayer->DropSpatialIndex();
else
{
CPLError( CE_Failure, CPLE_AppDefined,
"No such layer as '%s' in DROP SPATIAL INDEX.",
pszStatement + 19 );
}
return NULL;
}
/* ==================================================================== */
/* Handle all comands except spatial index creation generically. */
/* ==================================================================== */
if( !EQUALN(pszStatement,"CREATE SPATIAL INDEX ON ",24) )
return OGRDataSource::ExecuteSQL( pszStatement, poSpatialFilter,
pszDialect );
/* -------------------------------------------------------------------- */
/* Parse into keywords. */
/* -------------------------------------------------------------------- */
char **papszTokens = CSLTokenizeString( pszStatement );
if( CSLCount(papszTokens) < 5
|| !EQUAL(papszTokens[0],"CREATE")
|| !EQUAL(papszTokens[1],"SPATIAL")
|| !EQUAL(papszTokens[2],"INDEX")
|| !EQUAL(papszTokens[3],"ON")
|| CSLCount(papszTokens) > 7
|| (CSLCount(papszTokens) == 7 && !EQUAL(papszTokens[5],"DEPTH")) )
{
CSLDestroy( papszTokens );
CPLError( CE_Failure, CPLE_AppDefined,
"Syntax error in CREATE SPATIAL INDEX command.\n"
"Was '%s'\n"
"Should be of form 'CREATE SPATIAL INDEX ON <table> [DEPTH <n>]'",
pszStatement );
return NULL;
}
/* -------------------------------------------------------------------- */
/* Get depth if provided. */
/* -------------------------------------------------------------------- */
int nDepth = 0;
if( CSLCount(papszTokens) == 7 )
nDepth = atoi(papszTokens[6]);
/* -------------------------------------------------------------------- */
/* What layer are we operating on. */
/* -------------------------------------------------------------------- */
OGRShapeLayer *poLayer = (OGRShapeLayer *) GetLayerByName(papszTokens[4]);
CSLDestroy( papszTokens );
if( poLayer == NULL )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Layer %s not recognised.",
papszTokens[4] );
return NULL;
}
poLayer->CreateSpatialIndex( nDepth );
return NULL;
}