本文整理汇总了C++中CPLString::find_first_of方法的典型用法代码示例。如果您正苦于以下问题:C++ CPLString::find_first_of方法的具体用法?C++ CPLString::find_first_of怎么用?C++ CPLString::find_first_of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPLString
的用法示例。
在下文中一共展示了CPLString::find_first_of方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Set
void ERSHdrNode::Set( const char *pszPath, const char *pszValue )
{
CPLString osPath = pszPath;
int iDot;
iDot = osPath.find_first_of('.');
/* -------------------------------------------------------------------- */
/* We have an intermediate node, find or create it and */
/* recurse. */
/* -------------------------------------------------------------------- */
if( iDot != -1 )
{
CPLString osPathFirst = osPath.substr(0,iDot);
CPLString osPathRest = osPath.substr(iDot+1);
ERSHdrNode *poFirst = FindNode( osPathFirst );
if( poFirst == NULL )
{
poFirst = new ERSHdrNode();
MakeSpace();
papszItemName[nItemCount] = CPLStrdup(osPathFirst);
papszItemValue[nItemCount] = NULL;
papoItemChild[nItemCount] = poFirst;
nItemCount++;
}
poFirst->Set( osPathRest, pszValue );
return;
}
/* -------------------------------------------------------------------- */
/* This is the final item name. Find or create it. */
/* -------------------------------------------------------------------- */
int i;
for( i = 0; i < nItemCount; i++ )
{
if( EQUAL(osPath,papszItemName[i])
&& papszItemValue[i] != NULL )
{
CPLFree( papszItemValue[i] );
papszItemValue[i] = CPLStrdup( pszValue );
return;
}
}
MakeSpace();
papszItemName[nItemCount] = CPLStrdup(osPath);
papszItemValue[nItemCount] = CPLStrdup(pszValue);
papoItemChild[nItemCount] = NULL;
nItemCount++;
}
示例2: ParseChildren
int ERSHdrNode::ParseChildren( VSILFILE * fp, int nRecLevel )
{
if( nRecLevel == 100 ) // arbitrary limit
{
CPLError(CE_Failure, CPLE_AppDefined,
"Too many recursion level while parsing .ers header");
return false;
}
while( true )
{
/* -------------------------------------------------------------------- */
/* Read the next line (or multi-line for bracketed value). */
/* -------------------------------------------------------------------- */
CPLString osLine;
if( !ReadLine( fp, osLine ) )
return FALSE;
/* -------------------------------------------------------------------- */
/* Got a Name=Value. */
/* -------------------------------------------------------------------- */
size_t iOff;
if( (iOff = osLine.find_first_of( '=' )) != std::string::npos )
{
CPLString osName = osLine.substr(0,iOff-1);
osName.Trim();
CPLString osValue = osLine.c_str() + iOff + 1;
osValue.Trim();
MakeSpace();
papszItemName[nItemCount] = CPLStrdup(osName);
papszItemValue[nItemCount] = CPLStrdup(osValue);
papoItemChild[nItemCount] = nullptr;
nItemCount++;
}
/* -------------------------------------------------------------------- */
/* Got a Begin for an object. */
/* -------------------------------------------------------------------- */
else if( (iOff = osLine.ifind( " Begin" )) != std::string::npos )
{
CPLString osName = osLine.substr(0,iOff);
osName.Trim();
MakeSpace();
papszItemName[nItemCount] = CPLStrdup(osName);
papszItemValue[nItemCount] = nullptr;
papoItemChild[nItemCount] = new ERSHdrNode();
nItemCount++;
if( !papoItemChild[nItemCount-1]->ParseChildren( fp, nRecLevel + 1 ) )
return FALSE;
}
/* -------------------------------------------------------------------- */
/* Got an End for our object. Well, at least we *assume* it */
/* must be for our object. */
/* -------------------------------------------------------------------- */
else if( osLine.ifind( " End" ) != std::string::npos )
{
return TRUE;
}
/* -------------------------------------------------------------------- */
/* Error? */
/* -------------------------------------------------------------------- */
else if( osLine.Trim().length() > 0 )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Unexpected line parsing .ecw:\n%s",
osLine.c_str() );
return FALSE;
}
}
}
示例3: ParseChildren
int ERSHdrNode::ParseChildren( VSILFILE * fp )
{
while( TRUE )
{
size_t iOff;
CPLString osLine;
/* -------------------------------------------------------------------- */
/* Read the next line (or multi-line for bracketed value). */
/* -------------------------------------------------------------------- */
if( !ReadLine( fp, osLine ) )
return FALSE;
/* -------------------------------------------------------------------- */
/* Got a Name=Value. */
/* -------------------------------------------------------------------- */
if( (iOff = osLine.find_first_of( '=' )) != std::string::npos )
{
CPLString osName = osLine.substr(0,iOff-1);
osName.Trim();
CPLString osValue = osLine.c_str() + iOff + 1;
osValue.Trim();
MakeSpace();
papszItemName[nItemCount] = CPLStrdup(osName);
papszItemValue[nItemCount] = CPLStrdup(osValue);
papoItemChild[nItemCount] = NULL;
nItemCount++;
}
/* -------------------------------------------------------------------- */
/* Got a Begin for an object. */
/* -------------------------------------------------------------------- */
else if( (iOff = osLine.ifind( " Begin" )) != std::string::npos )
{
CPLString osName = osLine.substr(0,iOff);
osName.Trim();
MakeSpace();
papszItemName[nItemCount] = CPLStrdup(osName);
papszItemValue[nItemCount] = NULL;
papoItemChild[nItemCount] = new ERSHdrNode();
nItemCount++;
if( !papoItemChild[nItemCount-1]->ParseChildren( fp ) )
return FALSE;
}
/* -------------------------------------------------------------------- */
/* Got an End for our object. Well, at least we *assume* it */
/* must be for our object. */
/* -------------------------------------------------------------------- */
else if( osLine.ifind( " End" ) != std::string::npos )
{
return TRUE;
}
/* -------------------------------------------------------------------- */
/* Error? */
/* -------------------------------------------------------------------- */
else if( osLine.Trim().length() > 0 )
{
CPLError( CE_Failure, CPLE_AppDefined,
"Unexpected line parsing .ecw:\n%s",
osLine.c_str() );
return FALSE;
}
}
}