void Logstalgia::addGroup(const std::string& groupstr) { std::vector<std::string> group_definition; Regex groupregex("^([^,]+),(?:(HOST|CODE|URI)=)?([^,]+),([^,]+)(?:,([^,]+))?$"); groupregex.match(groupstr, &group_definition); vec3 colour(0.0f, 0.0f, 0.0f); if(group_definition.size()>=4) { std::string group_name = group_definition[0]; std::string group_type = group_definition[1]; std::string group_regex = group_definition[2]; if(group_type.empty()) group_type = "URI"; debugLog("group_name %s group_type %s group_regex %s", group_name.c_str(), group_type.c_str(), group_regex.c_str()); int percent = atoi(group_definition[3].c_str()); // TODO: allow ommiting percent, if percent == 0, divide up remaining space amoung groups with no percent //check for optional colour param if(group_definition.size()>=5) { int col; int r, g, b; if(sscanf(group_definition[4].c_str(), "%02x%02x%02x", &r, &g, &b) == 3) { colour = vec3( r, g, b ); debugLog("r = %d, g = %d, b = %d\n", r, g, b); colour /= 255.0f; } } addGroup(group_type, group_name, group_regex, percent, colour); } }
void Logstalgia::addGroup(std::string groupstr) { std::vector<std::string> groupdef; Regex groupregex("^([^,]+),([^,]+),([^,]+)(?:,([^,]+))?$"); groupregex.match(groupstr, &groupdef); vec3f colour(0.0f, 0.0f, 0.0f); if(groupdef.size()>=3) { std::string groupname = groupdef[0]; std::string groupregex = groupdef[1]; int percent = atoi(groupdef[2].c_str()); //check for optional colour param if(groupdef.size()>=4) { int col; int r, g, b; if(sscanf(groupdef[3].c_str(), "%02x%02x%02x", &r, &g, &b) == 3) { colour = vec3f( r, g, b ); debugLog("r = %d, g = %d, b = %d\n", r, g, b); colour /= 255.0f; } } addGroup(groupname, groupregex, percent, colour); } }