/** 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 ); } }
hex_pair_iterator operator ++() { // We're at the end of the input. if (Current == End) { IsDone = true; return *this; } Pair = value_type(); for (; Current != End && Pair.size() != 2; ++Current) { // Is a valid hex digit. if ((*Current >= '0' && *Current <= '9') || (*Current >= 'a' && *Current <= 'f') || (*Current >= 'A' && *Current <= 'F')) Pair.push_back(*Current); } // Hit the end without getting 2 hex digits. Pair is invalid. if (Pair.size() != 2) IsDone = true; return *this; }
Permutation(IterBeg beg, IterEnd end) { oneLineNotation.reserve(std::distance(beg, end)); for (; beg != end; ++beg) oneLineNotation.push_back(*beg); assert(__validity_test()); }