/** Parses the input string to a vector of pairs
     *
     *  Parses the input string in the form a,b,c{n},d{m},e,f
     *  to a vector of pairs with base number (a,b,c,d,e,f) and multipliers
     *  (1,1,n,m,e,f)
     *
     *  \param[in] s as const std::string in the form a,b{n}
     *  \return std::vector<pair> with uint32_t (base, multiplier)
     */
    void
    parseString( const std::string s )
    {
        boost::regex regFind( "[0-9]+(\\{[0-9]+\\})*",
                              boost::regex_constants::perl );

        boost::sregex_token_iterator iter( s.begin( ), s.end( ),
                                           regFind, 0 );
        boost::sregex_token_iterator end;

        parsedInput.clear();
        parsedInput.reserve( std::distance( iter, end ) );

        for(; iter != end; ++iter )
        {
            std::string pM = *iter;

            // find multiplier n and base b of b{n}
            boost::regex regMultipl( "(.*\\{)|(\\})",
                                     boost::regex_constants::perl );
            std::string multipl = boost::regex_replace( pM, regMultipl, "" );
            boost::regex regBase( "\\{.*\\}",
                                  boost::regex_constants::perl );
            std::string base = boost::regex_replace( pM, regBase, "" );

            // no Multiplier {n} given
            if( multipl == *iter )
                multipl = "1";

            const std::pair<uint32_t, uint32_t> g(
                      boost::lexical_cast<uint32_t > ( base ),
                      boost::lexical_cast<uint32_t > ( multipl ) );
            parsedInput.push_back( g );
        }
    }
Beispiel #2
0
 Permutation(IterBeg beg, IterEnd end) {
     oneLineNotation.reserve(std::distance(beg, end));
     for (; beg != end; ++beg)
         oneLineNotation.push_back(*beg);
     assert(__validity_test());
 }