wordEndIndex={englishWord.find_last_of(Characters::Letters::ALL)+1};//find the last letter in the string to use as ending
//extract it and translate, sanity checking in the process
std::stringactualWord{};
if(wordStartIndex!=std::string::npos&&wordEndIndex!=std::string::npos)//make sure word is sane
actualWord={englishWord.substr(wordStartIndex,wordEndIndex-wordStartIndex)};//2nd param is count between start and end of actual word
else
returnenglishWord;//this sanity checking takes also care of the other englishWord.substr in the final assembly phase
//sanity check
#ifndef SKIP_SANITY_CHECKS
if(wordStartIndex==std::string::npos||wordEndIndex==std::string::npos)//make sure word indexes are sane
returnenglishWord;//if not, return original word as there are no letters
#endif
//extract word and translate
std::stringactualWord{englishWord.substr(wordStartIndex,wordEndIndex-wordStartIndex)};//2nd param is count between start and end of actual word
std::stringpig{wordToPig(actualWord)};//translate English word
//capatilization handeling
#ifndef IGNORE_CAPS
if(std::all_of(std::begin(actualWord),std::end(actualWord),isupper)&&actualWord!="I")//if entire original word was uppercase (except for the word "I")//fixme why no std::toupper
std::transform(std::begin(pig),std::end(pig),std::begin(pig),toupper);//make entire translated word uppercase
else
@ -199,7 +213,7 @@ namespace anslatortray
if(std::isupper(actualWord[0]))//if original word had an uppercase first letter
pig[0]={static_cast<char>(std::toupper(pig[0]))};//new word should have uppercase first letter; have to cast int to char
}
#endif
//prefix punctuation + pigified word + suffix punctuation
std::stringresult{englishWord.substr(0,wordStartIndex)};//up to the start of the word
@ -217,22 +231,23 @@ namespace anslatortray
{
conststd::string::size_typefirstVowel{englishWord.find_first_of(Characters::Letters::VOWELS)};//fixme y being a vowel depends on word