本文整理汇总了C++中CPLString::append方法的典型用法代码示例。如果您正苦于以下问题:C++ CPLString::append方法的具体用法?C++ CPLString::append怎么用?C++ CPLString::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPLString
的用法示例。
在下文中一共展示了CPLString::append方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: URLPrepare
// Terminates an URL base with either ? or &, so extra args can be appended
void URLPrepare(CPLString &url) {
if (url.find("?") == std::string::npos) {
url.append("?");
} else {
if (*url.rbegin() != '?' && *url.rbegin() != '&')
url.append("&");
}
}
示例2: OGRCARTODBEscapeLiteral
CPLString OGRCARTODBEscapeLiteral(const char* pszStr)
{
CPLString osStr;
char ch;
for(int i=0; (ch = pszStr[i]) != '\0'; i++)
{
if (ch == '\'')
osStr.append(1, ch);
osStr.append(1, ch);
}
return osStr;
}
示例3: OGRPGDumpEscapeColumnName
CPLString OGRPGDumpEscapeColumnName(const char* pszColumnName)
{
CPLString osStr;
osStr += "\"";
char ch;
for(int i=0; (ch = pszColumnName[i]) != '\0'; i++)
{
if (ch == '"')
osStr.append(1, ch);
osStr.append(1, ch);
}
osStr += "\"";
return osStr;
}
示例4: OGRCARTODBEscapeIdentifier
CPLString OGRCARTODBEscapeIdentifier(const char* pszStr)
{
CPLString osStr;
osStr += "\"";
char ch;
for(int i=0; (ch = pszStr[i]) != '\0'; i++)
{
if (ch == '"')
osStr.append(1, ch);
osStr.append(1, ch);
}
osStr += "\"";
return osStr;
}
示例5: WriteValue
int OGRDXFWriterLayer::WriteValue( int nCode, const char *pszValue )
{
CPLString osLinePair;
osLinePair.Printf( "%3d\n", nCode );
if( strlen(pszValue) < 255 )
osLinePair += pszValue;
else
osLinePair.append( pszValue, 255 );
osLinePair += "\n";
return VSIFWriteL( osLinePair.c_str(),
1, osLinePair.size(), fp ) == osLinePair.size();
}
示例6: ImagineCitationTranslation
char* ImagineCitationTranslation(const char* psCitation, geokey_t keyID)
{
char* ret = NULL;
if(!psCitation)
return ret;
if(EQUALN(psCitation, "IMAGINE GeoTIFF Support", strlen("IMAGINE GeoTIFF Support")))
{
CPLString osName;
// this is a handle IMAGING style citation
const char* p = NULL;
p = strchr(psCitation, '$');
if(p)
p = strchr(p, '\n');
if(p)
p++;
const char* p1 = NULL;
if(p)
p1 = strchr(p, '\n');
if(p && p1)
{
switch (keyID)
{
case PCSCitationGeoKey:
osName = "PCS Name = ";
break;
case GTCitationGeoKey:
osName = "CS Name = ";
break;
case GeogCitationGeoKey:
if(!strstr(p, "Unable to"))
osName = "GCS Name = ";
break;
default:
break;
}
if(strlen(osName)>0)
{
osName.append(p, p1-p);
osName += "|";
}
}
p = strstr(psCitation, "Projection Name = ");
if(p)
{
p += strlen("Projection Name = ");
p1 = strchr(p, '\n');
if(!p1)
p1 = strchr(p, '\0');
}
if(p && p1)
{
osName.append(p, p1-p);
osName += "|";
}
p = strstr(psCitation, "Datum = ");
if(p)
{
p += strlen("Datum = ");
p1 = strchr(p, '\n');
if(!p1)
p1 = strchr(p, '\0');
}
if(p && p1)
{
osName += "Datum = ";
osName.append(p, p1-p);
osName += "|";
}
p = strstr(psCitation, "Ellipsoid = ");
if(p)
{
p += strlen("Ellipsoid = ");
p1 = strchr(p, '\n');
if(!p1)
p1 = strchr(p, '\0');
}
if(p && p1)
{
osName += "Ellipsoid = ";
osName.append(p, p1-p);
osName += "|";
}
p = strstr(psCitation, "Units = ");
if(p)
{
p += strlen("Units = ");
p1 = strchr(p, '\n');
if(!p1)
p1 = strchr(p, '\0');
}
if(p && p1)
{
osName += "LUnits = ";
osName.append(p, p1-p);
osName += "|";
}
if(strlen(osName) > 0)
{
ret = CPLStrdup(osName);
//.........这里部分代码省略.........
示例7: SetDefaultRAT
//.........这里部分代码省略.........
}
// ---------------------------
// Load data to buffers
// ---------------------------
for( iEntry = 0; iEntry < nEntryCount; iEntry++ )
{
((int *)(papWriteFields[0]))[iEntry] = iEntry; // ID field
for(iCol = 0; iCol < nColunsCount; iCol++)
{
if( poRAT->GetTypeOfCol( iCol ) == GFT_String )
{
int nOffset = iEntry * nVATStrSize;
char* pszTarget = ((char*)papWriteFields[iCol + 1]) + nOffset;
const char *pszStrValue = poRAT->GetValueAsString(iEntry, iCol);
int nLen = strlen( pszStrValue );
nLen = nLen > ( nVATStrSize - 1 ) ? nVATStrSize : ( nVATStrSize - 1 );
strncpy( pszTarget, pszStrValue, nLen );
pszTarget[nLen] = '\0';
}
if( poRAT->GetTypeOfCol( iCol ) == GFT_Integer )
{
((int *)(papWriteFields[iCol + 1]))[iEntry] =
poRAT->GetValueAsInt(iEntry, iCol);
}
if( poRAT->GetTypeOfCol( iCol ) == GFT_Real )
{
((double *)(papWriteFields[iCol]))[iEntry + 1] =
poRAT->GetValueAsDouble(iEntry, iCol);
}
}
}
// ---------------------------
// Prepare insert statement
// ---------------------------
CPLString osInsert = CPLSPrintf( "INSERT INTO %s VALUES (", pszVATName );
for( iCol = 0; iCol < ( nColunsCount + 1); iCol++ )
{
if( iCol > 0 )
{
osInsert.append(", ");
}
osInsert.append( CPLSPrintf(":%d", iCol + 1) );
}
osInsert.append(")");
poStmt = poGeoRaster->poConnection->CreateStatement( osInsert.c_str() );
// ---------------------------
// Bind buffers to columns
// ---------------------------
poStmt->Bind((int*) papWriteFields[0]); // ID field
for(iCol = 0; iCol < nColunsCount; iCol++)
{
if( poRAT->GetTypeOfCol( iCol ) == GFT_String )
{
poStmt->Bind( (char*) papWriteFields[iCol + 1], nVATStrSize );
}
if( poRAT->GetTypeOfCol( iCol ) == GFT_Integer )
{
poStmt->Bind( (int*) papWriteFields[iCol + 1]);
}
if( poRAT->GetTypeOfCol( iCol ) == GFT_Real )
{
poStmt->Bind( (double*) papWriteFields[iCol + 1]);
}
}
if( poStmt->Execute( iEntry ) )
{
poGDS->poGeoRaster->SetVAT( nBand, pszVATName );
}
else
{
CPLError( CE_Failure, CPLE_AppDefined, "Insert VAT Error!" );
}
// ---------------------------
// Clean up
// ---------------------------
for(iCol = 0; iCol < ( nColunsCount + 1); iCol++)
{
CPLFree( papWriteFields[iCol] );
}
CPLFree( papWriteFields );
delete poStmt;
return CE_None;
}
示例8: if
void GMLASXPathMatcher::SetDocumentMapURIToPrefix(
const std::map<CPLString,CPLString>& oMapURIToPrefix )
{
m_aosReferenceXPaths.clear();
// Split each reference XPath into its components
for(size_t i = 0; i < m_aosReferenceXPathsUncompiled.size(); ++i )
{
const CPLString& osXPath( m_aosReferenceXPathsUncompiled[i] );
std::vector<XPathComponent> oVector;
size_t iPos = 0;
bool bDirectChild = false;
if( osXPath.size() >= 2 &&
osXPath[0] == '/' && osXPath[1] == '/' )
{
iPos += 2;
}
else if( osXPath.size() >= 1 && osXPath[0] == '/' )
{
iPos += 1;
bDirectChild = true;
}
while( iPos < osXPath.size() )
{
size_t iPosNextSlash = osXPath.find('/', iPos);
if( iPos == iPosNextSlash )
{
bDirectChild = false;
iPos ++;
continue;
}
CPLString osCurNode;
if( iPosNextSlash == std::string::npos )
osCurNode.assign(osXPath, iPos, std::string::npos);
else
osCurNode.assign(osXPath, iPos, iPosNextSlash - iPos);
// Translate the configuration prefix to the equivalent in
// this current schema
size_t iPosColumn = osCurNode.find(':');
if( iPosColumn != std::string::npos )
{
bool bIsAttr = ( osCurNode[0] == '@' );
CPLString osPrefix;
CPLString osLocalname;
osPrefix.assign(osCurNode,
bIsAttr ? 1 : 0,
iPosColumn - (bIsAttr ? 1 : 0));
osLocalname.assign(osCurNode, iPosColumn+1,
std::string::npos);
std::map<CPLString, CPLString>::const_iterator oIter =
m_oMapPrefixToURIReferenceXPaths.find(osPrefix);
if( oIter != m_oMapPrefixToURIReferenceXPaths.end() )
{
const CPLString& osURI( oIter->second );
oIter = oMapURIToPrefix.find( osURI );
if( oIter == oMapURIToPrefix.end() )
break;
osPrefix.assign(oIter->second);
}
osCurNode.clear();
if( bIsAttr )
osCurNode.append(1, '@');
osCurNode.append(osPrefix);
osCurNode.append(1, ':');
osCurNode.append(osLocalname);
}
XPathComponent comp;
comp.m_osValue = osCurNode;
comp.m_bDirectChild = bDirectChild;
oVector.push_back(comp);
if( iPosNextSlash == std::string::npos )
iPos = osXPath.size();
else
iPos = iPosNextSlash + 1;
bDirectChild = true;
}
if ( iPos < osXPath.size() )
oVector.clear();
m_aosReferenceXPaths.push_back(oVector);
}
}
示例9: ILSPage
/**
*\Brief Create a MRF file from an existing DS
*/
GDALDataset * GDALMRFDataset::CreateCopy( const char *pszFilename,
GDALDataset *poSrcDS, int bStrict, char **papszOptions,
GDALProgressFunc pfnProgress, void *pProgressData)
{
// short term temporaryBlock
const char *pszValue;
GDALColorTable *poColorTable=NULL;
// Defaults
int nBands = poSrcDS->GetRasterCount();
int nXSize = poSrcDS->GetRasterXSize();
int nYSize = poSrcDS->GetRasterYSize();
// Set some defaults
ILCompression comp=IL_PNG;
ILOrder ord=IL_Interleaved;
ILSize ILSPage(512,512,1,1);
int quality = -1;
bool nbo=NET_ORDER;
// Use the info from the input image
// Use the poSrcDS or the first band to find out info about the dataset
GDALRasterBand *poPBand=poSrcDS->GetRasterBand(1);
GDALDataType dt=poPBand->GetRasterDataType();
// Use the blocking from the input image, if the input uses blocks.
int srcXBlk,srcYBlk;
poPBand->GetBlockSize(&srcXBlk,&srcYBlk);
if ((srcXBlk!=nXSize) && (srcYBlk!=nYSize)) {
ILSPage.x=srcXBlk;
ILSPage.y=srcYBlk;
}
// Except if the BLOCKSIZE BLOCKXSIZE and BLOCKYSIZE are set
pszValue = CSLFetchNameValue(papszOptions,"BLOCKSIZE");
if ( pszValue != NULL ) ILSPage.x = ILSPage.y = atoi( pszValue );
pszValue = CSLFetchNameValue(papszOptions,"BLOCKXSIZE");
if ( pszValue != NULL ) ILSPage.x = atoi( pszValue );
pszValue = CSLFetchNameValue(papszOptions,"BLOCKYSIZE");
if ( pszValue != NULL ) ILSPage.y = atoi( pszValue );
// Get the quality setting
pszValue = CSLFetchNameValue(papszOptions,"QUALITY");
if ( pszValue != NULL ) quality = atoi( pszValue );
else quality = 85;
if ( quality < 0 || quality > 99 ) {
CPLError(CE_Warning, CPLE_AppDefined, "GDAL MRF: Quality setting should be between 0 and 99, using 85");
quality = 85;
}
// If the source has a NoDataValue, min or max, we keep them
CPLString NoData;
{
int bHasNoData=false; double dfNoData=poPBand->GetNoDataValue( &bHasNoData);
if (bHasNoData) {
NoData=CPLString().FormatC(dfNoData);
// And for the other bands, if they are there
for (int i=1;i<nBands;i++) {
double dfNoData=poSrcDS->GetRasterBand(i+1)->GetNoDataValue(&bHasNoData);
if (bHasNoData)
NoData.append(CPLString().Printf(" %s",CPLString().FormatC(dfNoData).c_str()));
}
}
}
CPLString Min;
{
int bHasMin=false; double dfMin=poPBand->GetMinimum( &bHasMin);
if (bHasMin) {
Min=CPLString().FormatC(dfMin);
// And for the other bands, if they are there
for (int i=1;i<nBands;i++) {
double dfMin=poSrcDS->GetRasterBand(i+1)->GetMinimum(&bHasMin);
if (bHasMin)
Min.append(CPLString().Printf(" %s",CPLString().FormatC(dfMin).c_str()));
}
}
}
CPLString Max;
{
int bHasMax=false; double dfMax=poPBand->GetMaximum( &bHasMax);
if (bHasMax) {
Max=CPLString().FormatC(dfMax);
// And for the other bands, if they are there
for (int i=1;i<nBands;i++) {
double dfMax=poSrcDS->GetRasterBand(i+1)->GetMaximum(&bHasMax);
if (bHasMax)
Max.append(CPLString().Printf(" %s",CPLString().FormatC(dfMax).c_str()));
}
}
}
// Network byte order requested?
pszValue = CSLFetchNameValue(papszOptions,"NETBYTEORDER");
//.........这里部分代码省略.........
示例10: CreatePath
static void CreatePath( HDF5GroupObjects *poH5Object )
{
// Recurse to the root path.
CPLString osPath;
if( poH5Object->poHparent != nullptr )
{
CreatePath(poH5Object->poHparent);
osPath = poH5Object->poHparent->pszPath;
}
// Add name to the path.
if( !EQUAL(poH5Object->pszName, "/") )
{
osPath.append("/");
osPath.append(poH5Object->pszName);
}
// Fill up path for each object.
CPLString osUnderscoreSpaceInName;
if( poH5Object->pszPath == nullptr )
{
if( strlen(poH5Object->pszName) == 1 )
{
osPath.append(poH5Object->pszName);
osUnderscoreSpaceInName = poH5Object->pszName;
}
else
{
// Change space for underscore.
char **papszPath =
CSLTokenizeString2(osPath.c_str(), " ", CSLT_HONOURSTRINGS);
for( int i = 0; papszPath[i] != nullptr ; i++ )
{
if( i > 0 )
osUnderscoreSpaceInName.append("_");
osUnderscoreSpaceInName.append(papszPath[i]);
}
CSLDestroy(papszPath);
}
// -1 to give room for NUL in C strings.
constexpr size_t MAX_PATH = 8192 - 1;
// TODO(schwehr): Is it an issue if the results are longer than 8192?
// It appears that the output can never be longer than the source.
if( osUnderscoreSpaceInName.size() > MAX_PATH )
CPLError(CE_Fatal, CPLE_AppDefined,
"osUnderscoreSpaceInName longer than MAX_PATH: "
"%u > %u",
static_cast<unsigned int>(osUnderscoreSpaceInName.size()),
static_cast<unsigned int>(MAX_PATH));
if( osPath.size() > MAX_PATH )
CPLError(CE_Fatal, CPLE_AppDefined,
"osPath longer than MAX_PATH: %u > %u",
static_cast<unsigned int>(osPath.size()),
static_cast<unsigned int>(MAX_PATH));
poH5Object->pszUnderscorePath =
CPLStrdup(osUnderscoreSpaceInName.c_str());
poH5Object->pszPath = CPLStrdup(osPath.c_str());
}
}