| ColdFusion 9.0 Resources | CCFXStringSet classAbstract class that represents a set of ordered strings. You can add strings to a set and retrieve them by a numeric index (index values for strings are 1-based). To create a string set, use CCFXRequest::CreateStringSet. Class methods
 CCFXStringSet::AddStringExampleThe following example demonstrates adding three strings to a string set and saving the indexes of the items that are added: CCFXStringSet* pSet = pRequest->CreateStringSet() ; 
    int iRed = pSet->AddString( "Red" ) ; 
    int iGreen = pSet->AddString( "Green" ) ; 
    int iBlue = pSet->AddString( "Blue" ) ;CCFXStringSet::GetCountDescriptionGets the number of strings in a string set. The value can be used with CCFXStringSet::GetString to iterate over the strings in the set (recall that the index values for strings in the list begin at 1). ExampleThe following example demonstrates using GetCount with CCFXStringSet::GetString to iterate over a string set and write the contents of the list back to the user: int nNumItems = pStringSet->GetCount() ; 
    for ( int i=1; i<=nNumItems; i++ ) 
    { 
        pRequest->Write( pStringSet->GetString( i ) ) ; 
        pRequest->Write( "<BR>" ) ; 
    }CCFXStringSet::GetIndexForStringReturnsIf the string is found, its index within the string set is returned. If it is not found, the constant CFX_STRING_NOT_FOUND is returned. ExampleThe following example demonstrates a search for a string and throwing an exception if it is not found: CCFXStringSet* pAttribs = pRequest->GetAttributeList() ; 
     
    int iDestination = pAttribs->GetIndexForString("DESTINATION") ; 
    if ( iDestination == CFX_STRING_NOT_FOUND ) 
    { 
        pRequest->ThrowException( 
            "DESTINATION attribute not found." 
            "The DESTINATION attribute is required " 
            "by this tag." ) ; 
    }CCFXStringSet::GetStringExampleThe following example demonstrates GetString with CCFXStringSet::GetCount to iterate over a string set and write the contents of a list back to the user: int nNumItems = pStringSet->GetCount() ; 
    for ( int i=1; i<=nNumItems; i++ ) 
    { 
        pRequest->Write( pStringSet->GetString( i ) ) ; 
        pRequest->Write( "<BR>" ) ; 
    } |