bool Anagram::isAnagram( ) const { 
    if ( s1processed.empty( ) )
        throw BadString( "String 1 is empty after processing." );
    if ( s2processed.empty( ) )
        throw BadString( "String 2 is empty after processing." );

    return s1processed == s2processed; // string objects can be compared with ==
}
void Anagram::process( ) {
    if ( s1.empty( ) )
        throw BadString( "String 1 is empty." );
    if ( s2.empty( ) )
        throw BadString( "String 2 is empty." );

    s1processed = stringSort( lowerAlpha( s1 ) );
    s2processed = stringSort( lowerAlpha( s2 ) );
    return;
}
void Anagram::setString( string str, int i ) {
    if ( i == 1 ) {
        s1 = str;
        return;
    }
    if ( i == 2 ) {
        s2 = str;
        return;
    }
    throw BadString( "There is no string s" + i );
}
int32 UAudioTestCommandlet::Main(const FString& InParams)
{
#if ENABLE_UNREAL_AUDIO
    
    // Mac stupidly is adds "-NSDocumentRevisionsDebugMode YES" to command line args so lets remove that
    FString Params;
#if PLATFORM_MAC
    FString BadString(TEXT("-NSDocumentRevisionsDebugMode YES"));
    int32 DebugModeIndex = InParams.Find(BadString);
    if (DebugModeIndex != INDEX_NONE)
    {
        Params = InParams.LeftChop(BadString.Len());
    }
    else
#endif // #if PLATFORM_MAC
    {
        Params = InParams;
    }
   
	// Parse command line.
	TArray<FString> Tokens;
	TArray<FString> Switches;
	UCommandlet::ParseCommandLine(*Params, Tokens, Switches);

	// Check if we're switching to a different device API
	if (Switches.Num() == 1)
	{
		FString DeviceApiName(Switches[1]);
		if (!UnrealAudioLoad(&DeviceApiName))
		{
			UE_LOG(AudioTestCommandlet, Display, TEXT("Failed to load unreal audio module. Exiting."));
			return 0;
		}
	}
	else
	{
		if (!UnrealAudioLoad())
		{
			UE_LOG(AudioTestCommandlet, Display, TEXT("Failed to load unreal audio module. Exiting."));
			return 0;
		}
	}

	check(UnrealAudioModule != nullptr);

	if (Tokens.Num() < 3)
	{
		PrintUsage();
		return 0;
	}

	const int32 CategoryNameIndex = 1;
	const int32 TestNameIndex = 2;
	const int32 ArgStartIndex = 3;
	bool FoundTest = false;
	for (uint32 Index = 0; Index < AUDIO_TESTS; ++Index)
	{
		AudioTestInfo& Info = AudioTestInfoList[Index];
		if (Info.CategoryName == Tokens[CategoryNameIndex])
		{
			if (Info.TestName == Tokens[TestNameIndex])
			{
				FoundTest = true;
				TArray<FString> Args;
				for (int32 ArgIndex = ArgStartIndex; ArgIndex < Tokens.Num(); ++ArgIndex)
				{
					Args.Add(Tokens[ArgIndex]);
				}
				if (AudioTestInfoList[Index].TestFunction(Args))
				{
					UE_LOG(AudioTestCommandlet, Display, TEXT("Test %s succeeded."), *Info.TestName);
				}
				else
				{
					UE_LOG(AudioTestCommandlet, Display, TEXT("Test %s failed."), *Info.TestName);
				}
				break;
			}
		}
	}

	if (!FoundTest)
	{
		UE_LOG(AudioTestCommandlet, Display, TEXT("Unknown category or test. Exiting."));
		return 0;
	}

	UnrealAudioUnload();
#else // #if ENABLE_UNREAL_AUDIO
	UE_LOG(AudioTestCommandlet, Display, TEXT("Unreal Audio Module Not Enabled For This Platform"));
#endif // #else // #if ENABLE_UNREAL_AUDIO


	return 0;
}
const string Anagram::getProcessed( int i ) const {
    if ( i == 1 ) return s1processed;
    if ( i == 2 ) return s2processed;
    throw BadString( "There is no string s" + i );
}