Examples/HttpAnalyzer/main.cpp
/**
 * Print the hostname count map to a table sorted by popularity (most popular hostnames will be first)
 */
Print the hostname count map to a table sorted by popularity (most popular hostnames will be first)
Print the hostname count map to a table sorted by popularity ( most popular hostnames will be first )
void printHostnames(HttpRequestStats& reqStatscollector)
{
	std::vector<std::string> columnNames;
	columnNames.push_back("Hostname");
	columnNames.push_back("Count");
	std::vector<int> columnsWidths;
	columnsWidths.push_back(40);
	columnsWidths.push_back(5);
	pcpp::TablePrinter printer(columnNames, columnsWidths);
	std::vector<std::pair<std::string, int> > map2vec(reqStatscollector.hostnameCount.begin(), reqStatscollector.hostnameCount.end());
	std::sort(map2vec.begin(),map2vec.end(), &hostnameComparer);
	for(std::vector<std::pair<std::string, int> >::iterator iter = map2vec.begin();
			iter != map2vec.end();
			iter++)
	{
		std::stringstream values;
		values << iter->first << "|" << iter->second;
		printer.printRow(values.str(), '|');
	}
}
void printHostnames ( HttpRequestStats & reqStatscollector ) { std :: vector < std :: string > columnNames ; columnNames . push_back ( " " ) ; columnNames . push_back ( " " ) ; std :: vector < int > columnsWidths ; columnsWidths . push_back ( 40 ) ; columnsWidths . push_back ( 5 ) ; pcpp :: TablePrinter printer ( columnNames , columnsWidths ) ; std :: vector < std :: pair < std :: string , int > > map2vec ( reqStatscollector . hostnameCount . begin ( ) , reqStatscollector . hostnameCount . end ( ) ) ; std :: sort ( map2vec . begin ( ) , map2vec . end ( ) , & hostnameComparer ) ; for ( std :: vector < std :: pair < std :: string , int > > :: iterator iter = map2vec . begin ( ) ; iter != map2vec . end ( ) ; iter ++ ) { std :: stringstream values ; values << iter -> first << " " << iter -> second ; printer . printRow ( values . str ( ) , ' ' ) ; } }
Print the hostname count map to a table sorted by popularity (most popular hostnames will be first)
Print the hostname count map to a table sorted by popularity ( most popular hostnames will be first )
// create the table
 // sort the hostname count map so the most popular hostnames will be first
 // since it's not possible to sort a std::map you must copy it to a std::vector and sort it then
 // go over all items (hostname + count) in the sorted vector and print them
