本文整理汇总了C++中CPLString::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ CPLString::empty方法的具体用法?C++ CPLString::empty怎么用?C++ CPLString::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPLString
的用法示例。
在下文中一共展示了CPLString::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
oLine.setPoint( 1,
dfArrowX2 - dfVec2X*3 - dfVec1X,
dfArrowY2 - dfVec2Y*3 - dfVec1Y );
poMLS->addGeometry( &oLine );
poFeature->SetGeometryDirectly( poMLS );
PrepareLineStyle( poFeature );
/* -------------------------------------------------------------------- */
/* Is the layer disabled/hidden/frozen/off? */
/* -------------------------------------------------------------------- */
CPLString osLayer = poFeature->GetFieldAsString("Layer");
int bHidden =
EQUAL(poDS->LookupLayerProperty( osLayer, "Hidden" ), "1");
/* -------------------------------------------------------------------- */
/* Work out the color for this feature. */
/* -------------------------------------------------------------------- */
int nColor = 256;
if( oStyleProperties.count("Color") > 0 )
nColor = atoi(oStyleProperties["Color"]);
// Use layer color?
if( nColor < 1 || nColor > 255 )
{
const char *pszValue = poDS->LookupLayerProperty( osLayer, "Color" );
if( pszValue != NULL )
nColor = atoi(pszValue);
}
if( nColor < 1 || nColor > 255 )
nColor = 8;
/* -------------------------------------------------------------------- */
/* Prepare a new feature to serve as the dimension text label */
/* feature. We will push it onto the layer as a pending */
/* feature for the next feature read. */
/* -------------------------------------------------------------------- */
// a single space suppresses labeling.
if( osText == " " )
return poFeature;
OGRFeature *poLabelFeature = poFeature->Clone();
poLabelFeature->SetGeometryDirectly( new OGRPoint( oTextPos.x, oTextPos.y ) );
// Do we need to compute the dimension value?
if( osText.empty() )
{
FormatDimension( osText, POINT_DIST( oArrow1.x, oArrow1.y,
dfArrowX2, dfArrowY2 ) );
}
CPLString osStyle;
char szBuffer[64];
char* pszComma = NULL;
osStyle.Printf("LABEL(f:\"Arial\",t:\"%s\",p:5",osText.c_str());
if( dfAngle != 0.0 )
{
CPLsnprintf(szBuffer, sizeof(szBuffer), "%.3g", dfAngle);
pszComma = strchr(szBuffer, ',');
if (pszComma)
*pszComma = '.';
osStyle += CPLString().Printf(",a:%s", szBuffer);
}
if( dfHeight != 0.0 )
{
CPLsnprintf(szBuffer, sizeof(szBuffer), "%.3g", dfHeight);
pszComma = strchr(szBuffer, ',');
if (pszComma)
*pszComma = '.';
osStyle += CPLString().Printf(",s:%sg", szBuffer);
}
const unsigned char *pabyDWGColors = ACGetColorTable();
snprintf( szBuffer, sizeof(szBuffer), ",c:#%02x%02x%02x",
pabyDWGColors[nColor*3+0],
pabyDWGColors[nColor*3+1],
pabyDWGColors[nColor*3+2] );
osStyle += szBuffer;
if( bHidden )
osStyle += "00";
osStyle += ")";
poLabelFeature->SetStyleString( osStyle );
apoPendingFeatures.push( poLabelFeature );
return poFeature;
}
示例2: GetConfiguration
bool VSIOSSHandleHelper::GetConfiguration(CSLConstList papszOptions,
CPLString& osSecretAccessKey,
CPLString& osAccessKeyId)
{
osSecretAccessKey = CSLFetchNameValueDef(papszOptions,
"OSS_SECRET_ACCESS_KEY",
CPLGetConfigOption("OSS_SECRET_ACCESS_KEY", ""));
if( !osSecretAccessKey.empty() )
{
osAccessKeyId = CSLFetchNameValueDef(papszOptions,
"OSS_ACCESS_KEY_ID",
CPLGetConfigOption("OSS_ACCESS_KEY_ID", ""));
if( osAccessKeyId.empty() )
{
VSIError(VSIE_AWSInvalidCredentials,
"OSS_ACCESS_KEY_ID configuration option not defined");
return false;
}
return true;
}
VSIError(VSIE_AWSInvalidCredentials,
"OSS_SECRET_ACCESS_KEY configuration option not defined");
return false;
}
示例3: GetFeature
OGRFeature *OGRIDBTableLayer::GetFeature( GIntBig nFeatureId )
{
if( pszFIDColumn == NULL )
return OGRIDBLayer::GetFeature( nFeatureId );
ClearQuery();
iNextShapeId = nFeatureId;
poCurr = new ITCursor( *poDS->GetConnection() );
// Create list of fields
CPLString osFields;
if ( poFeatureDefn->GetFieldIndex( pszFIDColumn ) == -1 )
osFields += pszFIDColumn;
if ( pszGeomColumn )
{
if ( ! osFields.empty() )
osFields += ",";
osFields += "st_asbinary(";
osFields += pszGeomColumn;
osFields += ") as ";
osFields += pszGeomColumn;
}
for( int i = 0; i < poFeatureDefn->GetFieldCount(); i++ )
{
if ( ! osFields.empty() )
osFields += ",";
osFields += poFeatureDefn->GetFieldDefn(i)->GetNameRef();
}
CPLString sql;
sql.Printf( "SELECT %s FROM %s WHERE %s = %d",
osFields.c_str(), poFeatureDefn->GetName(),
pszFIDColumn, nFeatureId );
CPLDebug( "OGR_IDB", "ExecuteSQL(%s)", sql.c_str() );
if( !poCurr->Prepare( sql.c_str() ) ||
!poCurr->Open(ITCursor::ReadOnly) )
{
delete poCurr;
poCurr = NULL;
return NULL;
}
return GetNextRawFeature();
}
示例4: GetProjectionRef
const char *ISIS2Dataset::GetProjectionRef()
{
if( !osProjection.empty() )
return osProjection;
return GDALPamDataset::GetProjectionRef();
}
示例5: CPLRealloc
OGRLayer* OGRPLScenesDataV1Dataset::ParseItemType(json_object* poItemType)
{
if( poItemType == nullptr || json_object_get_type(poItemType) != json_type_object )
return nullptr;
json_object* poId = CPL_json_object_object_get(poItemType, "id");
if( poId == nullptr || json_object_get_type(poId) != json_type_string )
return nullptr;
CPLString osDisplayDescription;
json_object* poDisplayDescription = CPL_json_object_object_get(poItemType, "display_description");
if( poDisplayDescription != nullptr && json_object_get_type(poDisplayDescription) == json_type_string )
osDisplayDescription = json_object_get_string(poDisplayDescription);
CPLString osDisplayName;
json_object* poDisplayName = CPL_json_object_object_get(poItemType, "display_name");
if( poDisplayName != nullptr && json_object_get_type(poDisplayName) == json_type_string )
osDisplayName = json_object_get_string(poDisplayName);
const char* pszId = json_object_get_string(poId);
// The layer might already exist if GetLayerByName() is called before
// GetLayer()/GetLayerCount() is
// Prevent GetLayerCount() from calling EstablishLayerList()
bool bLayerListInitializedBackup = m_bLayerListInitialized;
m_bLayerListInitialized = true;
OGRLayer* poExistingLayer = GDALDataset::GetLayerByName(pszId);
m_bLayerListInitialized = bLayerListInitializedBackup;
if( poExistingLayer != nullptr )
return poExistingLayer;
OGRPLScenesDataV1Layer* poPLLayer = new OGRPLScenesDataV1Layer(
this, pszId);
if( !osDisplayName.empty() )
poPLLayer->SetMetadataItem("SHORT_DESCRIPTION", osDisplayName.c_str());
if( !osDisplayDescription.empty() )
poPLLayer->SetMetadataItem("DESCRIPTION", osDisplayDescription.c_str());
m_papoLayers = (OGRPLScenesDataV1Layer**) CPLRealloc(m_papoLayers,
sizeof(OGRPLScenesDataV1Layer*) * (m_nLayers + 1));
m_papoLayers[m_nLayers ++] = poPLLayer;
return poPLLayer;
}
示例6: osCanonicalizedHeaders
// See:
// https://www.alibabacloud.com/help/doc-detail/31951.htm?spm=a3c0i.o31982en.b99.178.5HUTqV
static struct curl_slist*
CPLGetOSSHeaders( const CPLString& osSecretAccessKey,
const CPLString& osAccessKeyId,
const CPLString& osVerb,
const struct curl_slist* psExistingHeaders,
const CPLString& osCanonicalizedResource )
{
CPLString osDate = CPLGetConfigOption("CPL_OSS_TIMESTAMP", "");
if( osDate.empty() )
{
osDate = IVSIS3LikeHandleHelper::GetRFC822DateTime();
}
std::map<CPLString, CPLString> oSortedMapHeaders;
CPLString osCanonicalizedHeaders(
IVSIS3LikeHandleHelper::BuildCanonicalizedHeaders(
oSortedMapHeaders,
psExistingHeaders,
"x-oss-"));
CPLString osStringToSign;
osStringToSign += osVerb + "\n";
osStringToSign += CPLAWSGetHeaderVal(psExistingHeaders, "Content-MD5") + "\n";
osStringToSign += CPLAWSGetHeaderVal(psExistingHeaders, "Content-Type") + "\n";
osStringToSign += osDate + "\n";
osStringToSign += osCanonicalizedHeaders;
osStringToSign += osCanonicalizedResource;
#ifdef DEBUG_VERBOSE
CPLDebug("OSS", "osStringToSign = %s", osStringToSign.c_str());
#endif
/* -------------------------------------------------------------------- */
/* Build authorization header. */
/* -------------------------------------------------------------------- */
CPLString osAuthorization("OSS ");
osAuthorization += osAccessKeyId;
osAuthorization += ":";
osAuthorization += GetSignature(osStringToSign, osSecretAccessKey);
#ifdef DEBUG_VERBOSE
CPLDebug("OSS", "osAuthorization='%s'", osAuthorization.c_str());
#endif
struct curl_slist *headers=nullptr;
headers = curl_slist_append(
headers, CPLSPrintf("Date: %s", osDate.c_str()));
headers = curl_slist_append(
headers, CPLSPrintf("Authorization: %s", osAuthorization.c_str()));
return headers;
}
示例7: IsValidXPath
static bool IsValidXPath(const CPLString& osXPath )
{
// Check that the XPath syntax belongs to the subset we
// understand
bool bOK = !osXPath.empty();
for(size_t i = 0; i < osXPath.size(); ++i )
{
const char chCur = osXPath[i];
if( chCur == '/' )
{
// OK
}
else if( chCur == '@' &&
(i == 0 || osXPath[i-1] == '/') &&
i < osXPath.size()-1 &&
isalpha( static_cast<int>(osXPath[i+1]) ) )
{
// OK
}
else if( chCur == '_' ||
isalpha( static_cast<int>(chCur) ) )
{
// OK
}
else if( isdigit( static_cast<int>(chCur) ) &&
i > 0 &&
(isalnum( static_cast<int>(osXPath[i-1]) ) ||
osXPath[i-1] == '_') )
{
// OK
}
else if( chCur == ':' &&
i > 0 &&
(isalnum( static_cast<int>(osXPath[i-1]) ) ||
osXPath[i-1] == '_') &&
i < osXPath.size()-1 &&
isalpha( static_cast<int>(osXPath[i+1]) ) )
{
// OK
}
else
{
bOK = false;
break;
}
}
return bOK;
}
示例8: DeleteLayer
OGRErr OGRAmigoCloudDataSource::DeleteLayer(int iLayer)
{
if( !bReadWrite )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Operation not available in read-only mode");
return OGRERR_FAILURE;
}
if( iLayer < 0 || iLayer >= nLayers )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Layer %d not in legal range of 0 to %d.",
iLayer, nLayers-1 );
return OGRERR_FAILURE;
}
/* -------------------------------------------------------------------- */
/* Blow away our OGR structures related to the layer. This is */
/* pretty dangerous if anything has a reference to this layer! */
/* -------------------------------------------------------------------- */
CPLString osDatasetId = papoLayers[iLayer]->GetDatasetId();
CPLDebug( "AMIGOCLOUD", "DeleteLayer(%s)", osDatasetId.c_str() );
int bDeferredCreation = papoLayers[iLayer]->GetDeferredCreation();
papoLayers[iLayer]->CancelDeferredCreation();
delete papoLayers[iLayer];
memmove( papoLayers + iLayer, papoLayers + iLayer + 1,
sizeof(void *) * (nLayers - iLayer - 1) );
nLayers--;
if (osDatasetId.empty())
return OGRERR_NONE;
if( !bDeferredCreation )
{
std::stringstream url;
url << std::string(GetAPIURL()) << "/users/0/projects/" + std::string(GetProjectId()) + "/datasets/"+ osDatasetId.c_str();
if( !RunDELETE(url.str().c_str()) ) {
return OGRERR_FAILURE;
}
}
return OGRERR_NONE;
}
示例9: GetOutputDriversFor
std::vector<CPLString> GetOutputDriversFor(const char* pszDestFilename,
int nFlagRasterVector)
{
std::vector<CPLString> aoDriverList;
CPLString osExt = CPLGetExtension(pszDestFilename);
const int nDriverCount = GDALGetDriverCount();
for( int i = 0; i < nDriverCount; i++ )
{
GDALDriverH hDriver = GDALGetDriver(i);
if( (GDALGetMetadataItem( hDriver, GDAL_DCAP_CREATE, nullptr ) != nullptr ||
GDALGetMetadataItem( hDriver, GDAL_DCAP_CREATECOPY, nullptr ) != nullptr ) &&
(((nFlagRasterVector & GDAL_OF_RASTER) &&
GDALGetMetadataItem( hDriver, GDAL_DCAP_RASTER, nullptr ) != nullptr) ||
((nFlagRasterVector & GDAL_OF_VECTOR) &&
GDALGetMetadataItem( hDriver, GDAL_DCAP_VECTOR, nullptr ) != nullptr)) )
{
if( !osExt.empty() && DoesDriverHandleExtension(hDriver, osExt) )
{
aoDriverList.push_back( GDALGetDriverShortName(hDriver) );
}
else
{
const char* pszPrefix = GDALGetMetadataItem(hDriver,
GDAL_DMD_CONNECTION_PREFIX, nullptr);
if( pszPrefix && STARTS_WITH_CI(pszDestFilename, pszPrefix) )
{
aoDriverList.push_back( GDALGetDriverShortName(hDriver) );
}
}
}
}
// GMT is registered before netCDF for opening reasons, but we want
// netCDF to be used by default for output.
if( EQUAL(osExt, "nc") && aoDriverList.size() == 2 &&
EQUAL(aoDriverList[0], "GMT") && EQUAL(aoDriverList[1], "NETCDF") )
{
aoDriverList.clear();
aoDriverList.push_back("NETCDF");
aoDriverList.push_back("GMT");
}
return aoDriverList;
}
示例10: CanConnect
bool GNMRule::CanConnect(const CPLString &soSrcLayerName,
const CPLString &soTgtLayerName,
const CPLString &soConnLayerName)
{
if(IsAcceptAny())
return m_bAllow;
if(m_soSrcLayerName == soSrcLayerName &&
m_soTgtLayerName == soTgtLayerName)
{
if(soConnLayerName.empty())
return m_bAllow;
else
return m_bAllow && m_soConnLayerName == soConnLayerName;
}
return false;
}
示例11: GetLayer
OGRErr OGRDataSourceWithTransaction::DeleteLayer(int iIndex)
{
if( !m_poBaseDataSource ) return OGRERR_FAILURE;
OGRLayer* poLayer = GetLayer(iIndex);
CPLString osName;
if( poLayer )
osName = poLayer->GetName();
OGRErr eErr = m_poBaseDataSource->DeleteLayer(iIndex);
if( eErr == OGRERR_NONE && !osName.empty() )
{
std::map<CPLString, OGRLayerWithTransaction*>::iterator oIter = m_oMapLayers.find(osName);
if(oIter != m_oMapLayers.end())
{
delete oIter->second;
m_oSetLayers.erase(oIter->second);
m_oMapLayers.erase(oIter);
}
}
return eErr;
}
示例12: oHolder
VSILFILE *VSIFileFromMemBuffer( const char *pszFilename,
GByte *pabyData,
vsi_l_offset nDataLength,
int bTakeOwnership )
{
if( VSIFileManager::GetHandler("")
== VSIFileManager::GetHandler("/vsimem/") )
VSIInstallMemFileHandler();
VSIMemFilesystemHandler *poHandler =
static_cast<VSIMemFilesystemHandler *>(
VSIFileManager::GetHandler("/vsimem/"));
if( pszFilename == nullptr )
return nullptr;
CPLString osFilename = pszFilename;
VSIMemFilesystemHandler::NormalizePath( osFilename );
if( osFilename.empty() )
return nullptr;
VSIMemFile *poFile = new VSIMemFile;
poFile->osFilename = osFilename;
poFile->bOwnData = CPL_TO_BOOL(bTakeOwnership);
poFile->pabyData = pabyData;
poFile->nLength = nDataLength;
poFile->nAllocLength = nDataLength;
{
CPLMutexHolder oHolder( &poHandler->hMutex );
poHandler->Unlink_unlocked(osFilename);
poHandler->oFileList[poFile->osFilename] = poFile;
CPLAtomicInc(&(poFile->nRefCount));
}
// TODO(schwehr): Fix this so that the using statement is not needed.
// Will just adding the bool for bSetError be okay?
return reinterpret_cast<VSILFILE *>( poHandler->Open( osFilename, "r+" ) );
}
示例13: CPLStrip
/**
* CPLStrip()
*/
CPLString CPLStrip(const CPLString& sString, const char cChar)
{
if(sString.empty())
return sString;
size_t dCopyFrom = 0;
size_t dCopyCount = sString.size();
if (sString[0] == cChar)
{
dCopyFrom++;
dCopyCount--;
}
if (sString[sString.size() - 1] == cChar)
dCopyCount--;
if(dCopyCount == 0)
return CPLString();
return sString.substr(dCopyFrom, dCopyCount);
}
示例14: Identify
int ROIPACDataset::Identify( GDALOpenInfo *poOpenInfo )
{
/* -------------------------------------------------------------------- */
/* Check if: */
/* * 1. The data file extension is known */
/* -------------------------------------------------------------------- */
const char *pszExtension = CPLGetExtension(poOpenInfo->pszFilename);
if ( strcmp( pszExtension, "raw" ) == 0 )
{
/* Since gdal do not read natively CInt8, more work is needed
* to read raw files */
return false;
}
bool bExtensionIsValid = strcmp( pszExtension, "int" ) == 0
|| strcmp( pszExtension, "slc" ) == 0
|| strcmp( pszExtension, "amp" ) == 0
|| strcmp( pszExtension, "cor" ) == 0
|| strcmp( pszExtension, "hgt" ) == 0
|| strcmp( pszExtension, "unw" ) == 0
|| strcmp( pszExtension, "msk" ) == 0
|| strcmp( pszExtension, "trans" ) == 0
|| strcmp( pszExtension, "dem" ) == 0
|| strcmp( pszExtension, "flg" ) == 0;
if ( !bExtensionIsValid )
{
return false;
}
/* -------------------------------------------------------------------- */
/* * 2. there is a .rsc file */
/* -------------------------------------------------------------------- */
CPLString osRscFilename = getRscFilename( poOpenInfo );
if ( osRscFilename.empty() )
{
return false;
}
return true;
}
示例15: BuildURL
CPLString VSIOSSHandleHelper::BuildURL(const CPLString& osEndpoint,
const CPLString& osBucket,
const CPLString& osObjectKey,
bool bUseHTTPS, bool bUseVirtualHosting)
{
const char* pszProtocol = (bUseHTTPS) ? "https" : "http";
if( osBucket.empty() )
{
return CPLSPrintf("%s://%s", pszProtocol,
osEndpoint.c_str());
}
else if( bUseVirtualHosting )
return CPLSPrintf("%s://%s.%s/%s", pszProtocol,
osBucket.c_str(),
osEndpoint.c_str(),
CPLAWSURLEncode(osObjectKey, false).c_str());
else
return CPLSPrintf("%s://%s/%s/%s", pszProtocol,
osEndpoint.c_str(),
osBucket.c_str(),
CPLAWSURLEncode(osObjectKey, false).c_str());
}