demo/device/main.cpp
// parses parameters stored as vector of strings and insersts them into map
parses parameters stored as vector of strings and insersts them into map
parses parameters stored as vector of strings and insersts them into map
void parse_parameters(std::map<std::string, std::string> &config, std::vector<std::string> &input) {
    std::regex regex[] = {
          std::regex("(--|-|\\/)([a-z][a-z\\-_]*)=(.*)")    
        , std::regex("(--|-|\\/)([a-z][a-z\\-_]*)")         
        , std::regex(".+")                                  
    };
    for(std::string &in : input) {
        std::cmatch result;
        const auto regex_count = sizeof(regex)/sizeof(regex[0]);
        const auto regex_last = regex_count-1;
        for(size_t index=0; index<regex_count; ++index)
            if(std::regex_match(in.c_str(), result, regex[index])) {
                std::string key   = index==regex_last ? std::string("input") : result[2];
                std::string value = result[index==regex_last ? 0 : 3];
                config.insert(std::make_pair(key, value));
                break;
            }
    }
}
void parse_parameters ( std :: map < std :: string , std :: string > & config , std :: vector < std :: string > & input ) { std :: regex regex [ ] = { std :: regex ( " \\ \\ " ) , std :: regex ( " \\ \\ " ) , std :: regex ( " " ) } ; for ( std :: string & in : input ) { std :: cmatch result ; const auto regex_count = sizeof ( regex ) / sizeof ( regex [ 0 ] ) ; const auto regex_last = regex_count - 1 ; for ( size_t index = 0 ; index < regex_count ; ++ index ) if ( std :: regex_match ( in . c_str ( ) , result , regex [ index ] ) ) { std :: string key = index == regex_last ? std :: string ( " " ) : result [ 2 ] ; std :: string value = result [ index == regex_last ? 0 : 3 ] ; config . insert ( std :: make_pair ( key , value ) ) ; break ; } } }
parses parameters stored as vector of strings and insersts them into map
parses parameters stored as vector of strings and insersts them into map
// key-value pair // key only // this must be last in regex[]; what is left is a filename