All pastes #399149 Raw Edit

Untitled

public cpp v1 · immutable
·published 2007-03-17 19:52 UTC
rendered paste body
#include <string>#include <vector>#include <fstream>#include <iostream>#include "Database.h"#include "Entry.h"using namespace std;Database::~Database() {		}void Database::initialize(std::string file) {	string line;	datafile.open(file.c_str());	if(datafile.good()){		while(!datafile.eof()) {			getline(datafile, line);    		vector<string*> *v;     		v = split_line(line);    		    		Entry *entry = new Entry();    		entry->setType(*v[0]);    		entry->setTitle(*v[1]);    		entry->setInterpret(*v[2]);    		entry->setInfo(*v[3]);    		entryList.push_back(entry);			}		/*		for( vector< Entry* >::iterator it = list.begin(); it != list.end(); ++it ) 			cout << ( *it )->getTitle();			*/ 		datafile.close();	} else {		cout << "couldn't open datafile";	}}std::vector<Entry*> Database::find(std::string search) {	}void Database::add(std::string entry){	}void Database::close() {	datafile.close();	}vector<string *>* split_line (const string& line){	string::size_type pos = 0;	bool inq = false;	vector<string *> *v;	const char *lp, *cp;	v  = new vector<string *> ( );	lp = line.c_str ();	for (cp = lp; *cp != '\0'; cp++) {				//skip whitespaces outside strings		if (*cp == ' ' && inq == false) {			continue;		} else if (*cp == '"') {			string::size_type cpos = cp - lp;			if (inq == true) {				string::size_type len = cpos - pos;				v->push_back (new string (line, pos, len));							} else {				pos = cpos + 1;			}			inq = !inq;		}	}	return v;}