belcard.hpp 1.49 KB
Newer Older
Sylvain Berfini's avatar
Sylvain Berfini committed
1 2 3
#ifndef belcard_hpp
#define belcard_hpp

Sylvain Berfini's avatar
Sylvain Berfini committed
4 5 6
#include "belcard_generic.hpp"
#include "belcard_identification.hpp"

Sylvain Berfini's avatar
Sylvain Berfini committed
7 8 9 10 11 12 13 14 15 16 17
#include <string>
#include <list>
#include <map>
#include <memory>

using namespace::std;

namespace belcard {
	class BelCard : public BelCardGeneric {
	private:
		shared_ptr<BelCardFN> _fn;
18
		shared_ptr<BelCardN> _n;
19
		list<shared_ptr<BelCardNickname>> _nicknames;
Sylvain Berfini's avatar
Sylvain Berfini committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
		list<shared_ptr<BelCardProperty>> _properties;
		
	public:
		static shared_ptr<BelCard> create() {
			return make_shared<BelCard>();
		}
		
		BelCard() {
			
		}
		
		void setFN(const shared_ptr<BelCardFN> &fn) {
			_fn = fn;
			addProperty(_fn);
		}
		const shared_ptr<BelCardFN> &getFN() const {
			return _fn;
		}
		
39 40 41 42 43 44 45 46
		void setN(const shared_ptr<BelCardN> &n) {
			_n = n;
			addProperty(_n);
		}
		const shared_ptr<BelCardN> &getN() const {
			return _n;
		}
		
47 48 49 50 51 52 53 54
		void addNickname(const shared_ptr<BelCardNickname> &nickname) {
			_nicknames.push_back(nickname);
			addProperty(nickname);
		}
		const list<shared_ptr<BelCardNickname>> &getNicknames() const {
			return _nicknames;
		}
		
Sylvain Berfini's avatar
Sylvain Berfini committed
55 56 57 58 59 60
		void addProperty(const shared_ptr<BelCardProperty> &property) {
			_properties.push_back(property);
		}
		const list<shared_ptr<BelCardProperty>> &getProperties() const {
			return _properties;
		}
61 62 63 64 65 66 67 68 69
		
		string toString() {
			string vcard = "BEGIN:VCARD\r\nVERSION:4.0\r\n";
			for (auto it = _properties.begin(); it != _properties.end(); ++it) {
				vcard += (*it)->toString(); 
			}
			vcard += "END:VCARD\r\n";
			return vcard;
		}
Sylvain Berfini's avatar
Sylvain Berfini committed
70
	};	
Sylvain Berfini's avatar
Sylvain Berfini committed
71 72 73
}

#endif