Headings.Cpp
Comparing C++ And Perl
#include "Headings.h"
#include "MyException.h"
using namespace std;
Headings::Headings(Technologies const &technologies){
headings.insert(
pair <string,string>
("ntruencrypt",
"NTRUEncrypt; Analysis, Modifications and Enhancements"));
headings.insert(
pair <string,string>
("ntrusign",
"NTRUSign; Analysis, Modifications and Enhancements"));
headings.insert(
pair <string,string>
("lattice_reduction",
"Lattice Reduction"));
headings.insert(
pair <string,string>
("implementations",
"Implementations"));
headings.insert(
pair <string,string>
("variants",
"Variants"));
// make sure that every technology has a heading
int i;
map <string,string>::const_iterator it;
for (i=0; i<technologies.size(); i++){
it = headings.find( technologies[i] );
if (it == headings.end()){
throw MyException("no heading for technology: "
+ technologies[i]);
}
}
// make sure that only the defined technologies have headings
for (it = headings.begin(); it != headings.end(); ++it){
if (!technologies.entry_num(it->first, i)){
throw MyException("heading defined for non-existent technology: "
+ it->first);
}
}
}
Headings::~Headings(){
}
bool Headings::get(
string const &key,
string &value) const
{
map <string, string>::const_iterator it = headings.find(key);
if (it == headings.end()){
return false;
}
value = it->second;
return true;
}
Wednesday, April 29, 2009 (1)