# CCFXStringSet Class

Abstract class that represents a set of ordered strings. Strings can be added to a set and can be retrieved by a numeric index (the index values for strings are 1-based). To create a string set, you should use CCFXRequest::CreateStringSet.

## Class members

    virtual int AddString( LPCSTR lpszString )

CCFXStringSet::AddString adds a string to the end of the list.

virtual int GetCount()

CCFXStringSet::GetCount gets the number of strings contained in the list.

virtual LPCSTR GetString( int iIndex )

CCFXStringSet::GetString gets the string located at the passed index.

virtual int GetIndexForString( LPCSTR lpszString )

CCFXStringSet::GetIndexForString gets the index for the passed string.

## CCFXStringSet::AddString

    int CCFXStringSet::AddString(LPCSTR lpszString)

Adds a string to the end of the list. Returns the index of the string that was added.

    lpszString

String to add to the list.

#### Example

The 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::GetCount

    int CCFXStringSet::GetCount(void)

Gets the number of strings contained in the string set. This value can be used along with CCFXStringSet::GetString to iterate over the strings in the set (when iterating, remember that the index values for strings in the list begin at 1).

Returns the number of strings contained in the string set.

#### Example

The following example demonstrates using `GetCount` along 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::GetIndexForString

    int CCFXStringSet::GetIndexForString(LPCSTR lpszString)

Does a case insensitive search for the passed string.

If 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.

    lpszString

String to search for.

#### Example

The following example illustrates searching 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::GetString

    LPCSTR CCFXStringSet::GetString(int iIndex)

Retrieves the string located at the passed index (note that index values are 1-based).

Returns the string located at the passed index.

    iIndex

Index of string to retrieve.

#### Example

The following example demonstrates using `GetString` along with CCFXStringSet::GetCount 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>" ) ;
    }