#include <sstream>
#include <string>
#include <bitset>
#include <iostream>
#include <iomanip>

int main()
{
    const std::string test[] = { "...|N|Y|N|N|...", "...|Y|N|Y|N|...", "...|N|Y|Y|N|..." } ;

    for( const std::string& str : test )
    {
        std::istringstream stm(str) ;

        // parse the four Y/N into bool values
        // and form a bitset of four bits with with 'Y' == 1

        constexpr std::size_t NBITS = 4 ;
        std::bitset<NBITS> bits ; // set of four bits
        char Y_or_N ;
        for( std::size_t i = 0 ; i < NBITS ; ++i )
        {
            stm.ignore( 100, '|' ) ; // throw characters away upto and including the next '|'
            stm >> Y_or_N ; // read the next char ('Y' or 'N')
            bits[ (NBITS-1) - i ] = Y_or_N == 'Y' ; // set the corrosponding bit to 1 if it is a 'Y'
        }

        // get the code by converting the bits to an integral value
        auto code = bits.to_ulong() ;

        // check it out
        std::cout << str << "  " << bits << "  " << std::setw(2) << std::setfill('0') << code << '\n' ;
    }
}
