本文整理汇总了C++中CPLString函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLString函数的具体用法?C++ CPLString怎么用?C++ CPLString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CPLString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FlushCache
EIRDataset::~EIRDataset()
{
FlushCache();
if( nBands > 0 && GetAccess() == GA_Update )
{
int bNoDataSet;
double dfNoData;
RawRasterBand *poBand = (RawRasterBand *) GetRasterBand( 1 );
dfNoData = poBand->GetNoDataValue(&bNoDataSet);
if( bNoDataSet )
{
ResetKeyValue( "NODATA",
CPLString().Printf( "%.8g", dfNoData ) );
}
}
if( fpImage != NULL )
VSIFCloseL( fpImage );
CSLDestroy( papszHDR );
CSLDestroy( papszExtraFiles );
}
示例2: CPLGetConfigOption
CPLString GMLASConfiguration::GetBaseCacheDirectory()
{
#ifdef WIN32
const char* pszHome = CPLGetConfigOption("USERPROFILE", NULL);
#else
const char* pszHome = CPLGetConfigOption("HOME", NULL);
#endif
if( pszHome != NULL )
{
return CPLFormFilename( pszHome, ".gdal", NULL) ;
}
else
{
const char *pszDir = CPLGetConfigOption( "CPL_TMPDIR", NULL );
if( pszDir == NULL )
pszDir = CPLGetConfigOption( "TMPDIR", NULL );
if( pszDir == NULL )
pszDir = CPLGetConfigOption( "TEMP", NULL );
const char* pszUsername = CPLGetConfigOption("USERNAME", NULL);
if( pszUsername == NULL )
pszUsername = CPLGetConfigOption("USER", NULL);
if( pszDir != NULL && pszUsername != NULL )
{
return CPLFormFilename( pszDir,
CPLSPrintf(".gdal_%s", pszUsername), NULL) ;
}
}
return CPLString();
}
示例3: ReadGroup
int CPLKeywordParser::ReadGroup( const char *pszPathPrefix )
{
CPLString osName, osValue;
for( ; TRUE; )
{
if( !ReadPair( osName, osValue ) )
return FALSE;
if( EQUAL(osName,"BEGIN_GROUP") || EQUAL(osName,"GROUP") )
{
if( !ReadGroup( (CPLString(pszPathPrefix) + osValue + ".").c_str() ) )
return FALSE;
}
else if( EQUALN(osName,"END",3) )
{
return TRUE;
}
else
{
osName = pszPathPrefix + osName;
papszKeywordList = CSLSetNameValue( papszKeywordList,
osName, osValue );
}
}
}
示例4: CPLWriteFct
static size_t
CPLWriteFct(void *buffer, size_t size, size_t nmemb, void *reqInfo)
{
CPLHTTPResult *psResult = (CPLHTTPResult *) reqInfo;
int nNewSize;
nNewSize = psResult->nDataLen + nmemb*size + 1;
if( nNewSize > psResult->nDataAlloc )
{
psResult->nDataAlloc = (int) (nNewSize * 1.25 + 100);
GByte* pabyNewData = (GByte *) VSIRealloc(psResult->pabyData,
psResult->nDataAlloc);
if( pabyNewData == NULL )
{
VSIFree(psResult->pabyData);
psResult->pabyData = NULL;
psResult->pszErrBuf = CPLStrdup(CPLString().Printf("Out of memory allocating %d bytes for HTTP data buffer.", psResult->nDataAlloc));
psResult->nDataAlloc = psResult->nDataLen = 0;
return 0;
}
psResult->pabyData = pabyNewData;
}
memcpy( psResult->pabyData + psResult->nDataLen, buffer,
nmemb * size );
psResult->nDataLen += nmemb * size;
psResult->pabyData[psResult->nDataLen] = 0;
return nmemb;
}
示例5: osErrMsg
void GDALGMLJP2Expr::ReportError( const char* pszOriStr,
const char* pszStr,
const char* pszIntroMessage )
{
size_t nDist = static_cast<size_t>(pszStr - pszOriStr);
if( nDist > 40 )
nDist = 40;
CPLString osErrMsg(pszIntroMessage);
CPLString osInvalidExpr = CPLString(pszStr - nDist).substr(0, nDist + 20);
for( int i = static_cast<int>(nDist) - 1; i >= 0; --i )
{
if( osInvalidExpr[i] == '\n' )
{
osInvalidExpr = osInvalidExpr.substr(i+1);
nDist -= i + 1;
break;
}
}
for( size_t i = nDist; i < osInvalidExpr.size(); ++i )
{
if( osInvalidExpr[i] == '\n' )
{
osInvalidExpr.resize(i);
break;
}
}
osErrMsg += osInvalidExpr;
osErrMsg += "\n";
for( size_t i = 0; i < nDist; ++i )
osErrMsg += " ";
osErrMsg += "^";
CPLError(CE_Failure, CPLE_AppDefined, "%s", osErrMsg.c_str());
}
示例6: OGRFeatureDefn
OGRPGDumpLayer::OGRPGDumpLayer(OGRPGDumpDataSource* poDS,
const char* pszSchemaName,
const char* pszTableName,
const char* pszGeomColumn,
const char *pszFIDColumn,
int nCoordDimension,
int nSRSId,
int bWriteAsHexIn,
int bCreateTable)
{
this->poDS = poDS;
poFeatureDefn = new OGRFeatureDefn( pszTableName );
poFeatureDefn->Reference();
nFeatures = 0;
pszSqlTableName = CPLStrdup(CPLString().Printf("%s.%s",
OGRPGDumpEscapeColumnName(pszSchemaName).c_str(),
OGRPGDumpEscapeColumnName(pszTableName).c_str() ));
this->pszGeomColumn = (pszGeomColumn) ? CPLStrdup(pszGeomColumn) : NULL;
this->pszFIDColumn = CPLStrdup(pszFIDColumn);
this->nCoordDimension = nCoordDimension;
this->nSRSId = nSRSId;
this->bCreateTable = bCreateTable;
bLaunderColumnNames = TRUE;
bPreservePrecision = TRUE;
bUseCopy = USE_COPY_UNSET;
bWriteAsHex = bWriteAsHexIn;
bCopyActive = FALSE;
}
示例7: GDALMRFRasterBand
TIF_Band::TIF_Band(GDALMRFDataset *pDS, const ILImage &image, int b, int level):
GDALMRFRasterBand(pDS,image,b,int(level))
{
// Increase the page buffer by 1K in case Tiff expands data
pDS->SetPBuffer(image.pageSizeBytes + 1024);
// Static create options for TIFF tiles
papszOptions = CSLAddNameValue(NULL, "COMPRESS", "DEFLATE");
papszOptions = CSLAddNameValue(papszOptions, "TILED", "Yes");
papszOptions = CSLAddNameValue(papszOptions, "BLOCKXSIZE", CPLString().Printf("%d",img.pagesize.x));
papszOptions = CSLAddNameValue(papszOptions, "BLOCKYSIZE", CPLString().Printf("%d",img.pagesize.y));
int q = img.quality / 10;
// Move down so the default 85 maps to 6. This makes the maz ZLEVEL 8, which is OK
if (q >2) q-=2;
papszOptions = CSLAddNameValue(papszOptions, "ZLEVEL", CPLString().Printf("%d",q));
};
示例8: OGRVRTGetSerializedGeometryType
CPLString OGRVRTGetSerializedGeometryType(OGRwkbGeometryType eGeomType)
{
for( const auto& entry: asGeomTypeNames )
{
if( entry.eType == wkbFlatten(eGeomType) )
{
CPLString osRet(entry.pszName);
if( entry.bIsoFlags || OGR_GT_HasM(eGeomType) )
{
if( OGR_GT_HasZ(eGeomType) )
{
osRet += "Z";
}
if( OGR_GT_HasM(eGeomType) )
{
osRet += "M";
}
}
else if(OGR_GT_HasZ(eGeomType) )
{
osRet += "25D";
}
return osRet;
}
}
return CPLString();
}
示例9: VALIDATE_POINTER1
CPLXMLNode *GDALSerializeTPSTransformer( void *pTransformArg )
{
VALIDATE_POINTER1( pTransformArg, "GDALSerializeTPSTransformer", NULL );
CPLXMLNode *psTree;
TPSTransformInfo *psInfo = static_cast<TPSTransformInfo *>(pTransformArg);
psTree = CPLCreateXMLNode( NULL, CXT_Element, "TPSTransformer" );
/* -------------------------------------------------------------------- */
/* Serialize bReversed. */
/* -------------------------------------------------------------------- */
CPLCreateXMLElementAndValue(
psTree, "Reversed",
CPLString().Printf( "%d", psInfo->bReversed ) );
/* -------------------------------------------------------------------- */
/* Attach GCP List. */
/* -------------------------------------------------------------------- */
if( psInfo->nGCPCount > 0 )
{
GDALSerializeGCPListToXML( psTree,
psInfo->pasGCPList,
psInfo->nGCPCount,
NULL );
}
return psTree;
}
示例10: CPLString
std::map<CPLString, CPLString>
OGRDXFWriterLayer::PrepareTextStyleDefinition( OGRStyleLabel *poLabelTool )
{
GBool bDefault;
std::map<CPLString, CPLString> oTextStyleDef;
/* -------------------------------------------------------------------- */
/* Fetch the data for this text style. */
/* -------------------------------------------------------------------- */
const char *pszFontName = poLabelTool->FontName(bDefault);
if( !bDefault )
oTextStyleDef["Font"] = pszFontName;
const GBool bBold = poLabelTool->Bold(bDefault);
if( !bDefault )
oTextStyleDef["Bold"] = bBold ? "1" : "0";
const GBool bItalic = poLabelTool->Italic(bDefault);
if( !bDefault )
oTextStyleDef["Italic"] = bItalic ? "1" : "0";
const double dfStretch = poLabelTool->Stretch(bDefault);
if( !bDefault )
{
oTextStyleDef["Width"] = CPLString().Printf( "%f",
dfStretch / 100.0 );
}
return oTextStyleDef;
}
示例11: CPLHTTPWriteFunc
static size_t CPLHTTPWriteFunc(void *buffer, size_t count, size_t nmemb, void *req) {
CPLHTTPRequest *psRequest = reinterpret_cast<CPLHTTPRequest *>(req);
size_t size = count * nmemb;
if (size == 0) return 0;
const size_t required_size = psRequest->nDataLen + size + 1;
if (required_size > psRequest->nDataAlloc) {
size_t new_size = required_size * 2;
if (new_size < 512) new_size = 512;
psRequest->nDataAlloc = new_size;
GByte * pabyNewData = reinterpret_cast<GByte *>(VSIRealloc(psRequest->pabyData, new_size));
if (pabyNewData == NULL) {
VSIFree(psRequest->pabyData);
psRequest->pabyData = NULL;
psRequest->pszError = CPLStrdup(CPLString().Printf("Out of memory allocating %u bytes for HTTP data buffer.", static_cast<int>(new_size)));
psRequest->nDataAlloc = 0;
psRequest->nDataLen = 0;
return 0;
}
psRequest->pabyData = pabyNewData;
}
memcpy(psRequest->pabyData + psRequest->nDataLen, buffer, size);
psRequest->nDataLen += size;
psRequest->pabyData[psRequest->nDataLen] = 0;
return nmemb;
}
示例12: ReadGroup
int NASAKeywordHandler::ReadGroup( const char *pszPathPrefix )
{
for( ; true; )
{
CPLString osName, osValue;
if( !ReadPair( osName, osValue ) )
return FALSE;
if( EQUAL(osName,"OBJECT") || EQUAL(osName,"GROUP") )
{
if( !ReadGroup( (CPLString(pszPathPrefix) + osValue + ".").c_str() ) )
return FALSE;
}
else if( EQUAL(osName,"END")
|| EQUAL(osName,"END_GROUP" )
|| EQUAL(osName,"END_OBJECT" ) )
{
return TRUE;
}
else
{
osName = pszPathPrefix + osName;
papszKeywordList = CSLSetNameValue( papszKeywordList,
osName, osValue );
}
}
}
示例13: CPLDebug
int ISIS2Dataset::WriteQUBE_Information(
VSILFILE *fpLabel, unsigned int iLevel, unsigned int & nWritingBytes,
unsigned int nXSize, unsigned int nYSize, unsigned int nBands,
GDALDataType eType, const char * pszInterleaving)
{
nWritingBytes += ISIS2Dataset::WriteFormatting( fpLabel, "");
nWritingBytes += ISIS2Dataset::WriteFormatting( fpLabel, "/* Qube structure */");
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "OBJECT", "QUBE");
iLevel++;
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "AXES", "3");
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "AXIS_NAME", pszInterleaving);
nWritingBytes += ISIS2Dataset::WriteFormatting( fpLabel, "/* Core description */");
CPLDebug("ISIS2","%d,%d,%d",nXSize,nYSize,nBands);
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "CORE_ITEMS",CPLString().Printf("(%d,%d,%d)",nXSize,nYSize,nBands));
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "CORE_NAME", "\"RAW DATA NUMBER\"");
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "CORE_UNIT", "\"N/A\"");
// TODO change for eType
if( eType == GDT_Byte )
{
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "CORE_ITEM_TYPE", "PC_UNSIGNED_INTEGER");
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "CORE_ITEM_BYTES", "1");
}
else if( eType == GDT_UInt16 )
{
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "CORE_ITEM_TYPE", "PC_UNSIGNED_INTEGER");
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "CORE_ITEM_BYTES", "2");
}
else if( eType == GDT_Int16 )
{
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "CORE_ITEM_TYPE", "PC_INTEGER");
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "CORE_ITEM_BYTES", "2");
}
else if( eType == GDT_Float32 )
{
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "CORE_ITEM_TYPE", "PC_REAL");
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "CORE_ITEM_BYTES", "4");
}
else if( eType == GDT_Float64 )
{
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "CORE_ITEM_TYPE", "PC_REAL");
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "CORE_ITEM_BYTES", "8");
}
// TODO add core null value
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "CORE_BASE", "0.0");
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "CORE_MULTIPLIER", "1.0");
nWritingBytes += ISIS2Dataset::WriteFormatting( fpLabel, "/* Suffix description */");
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "SUFFIX_BYTES", "4");
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "SUFFIX_ITEMS", "( 0, 0, 0)");
iLevel--;
nWritingBytes += ISIS2Dataset::WriteKeyword( fpLabel, iLevel, "END_OBJECT", "QUBE");
return TRUE;
}
示例14: GetLocation
CPLString wxGxObjectDialog::GetPath(void) const
{
wxGxObject* pObj = GetLocation();
if (NULL == pObj)
return CPLString();
return pObj->GetPath();
}
示例15: BufferToVSIFile
CPLString BufferToVSIFile(GByte *buffer, size_t size) {
CPLString file_name;
file_name.Printf("/vsimem/wms/%p/wmsresult.dat", buffer);
VSILFILE *f = VSIFileFromMemBuffer(file_name.c_str(), buffer, size, false);
if (f == nullptr) return CPLString();
VSIFCloseL(f);
return file_name;
}