Show cache_entry.cc syntax highlighted
#include <IMAPTypes.h>
#include <string>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
using namespace IMAP;
struct crap
{
std::string msg;
crap(const std::string &s) : msg(s) {}
};
typedef map<long, IMAP::CacheEntry<crap> > crapmap;
typedef vector<IMAP::CacheEntry<crap> > craplist;
int main()
{
crapmap idmap;
craplist *stuff;
stuff = new craplist();
cout << "Making cache entries" << endl;
idmap[1] = CacheEntry<crap>(new crap("a"));
idmap[2] = CacheEntry<crap>(new crap("b"));
idmap[3] = CacheEntry<crap>(new crap("c"));
idmap[4] = CacheEntry<crap>(new crap("d"));
cout << "Looking at an empty cache entry:" << endl;
if(idmap[5].isEmpty())
cout << "It is properly empty" << endl;
else
cout << "ERROR! It is NOT properly empty" << endl;
cout << "Copying entries to craplist:" << endl;
stuff->push_back(idmap[2]);
stuff->push_back(idmap[4]);
craplist::iterator i;
cout << "Looking at craplist" << endl;
for(i=stuff->begin(); i != stuff->end(); i++)
{
cout << i->getItem().msg << endl;
}
cout << "Deleting craplist" << endl;
delete stuff;
}
See more files for this project here