summaryrefslogtreecommitdiff
path: root/mg_listitem.c
blob: b7cac689a134a3f815a44ff1439333a5f8745b71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*!
 * \file mg_listitem.c
 * \brief An item as delivered by mgSelection
 *
 * \version $Revision: 1.0 $
 * \date    $Date: 2004-12-07 10:10:35 +0200 (Tue, 07 Dec 2004) $
 * \author  Wolfgang Rohdewald
 * \author  Responsible author: $Author: wr $
 *
 */

#include "mg_listitem.h"
#include <assert.h>

mgListItem::mgListItem()
{
	m_valid=false;
	m_unique_id="0";
	m_count=0;
}

mgListItem::mgListItem(const mgListItem* from)
{
	assert(from);
	m_valid=from->m_valid;
	m_value=from->m_value;
	m_id=from->m_id;
	m_unique_id=from->m_unique_id;
	m_count=from->m_count;
}

mgListItem::mgListItem(string v,string i,unsigned int c)
{
	set(v,i,c);
}

mgListItem*
mgListItem::Clone()
{
	if (!this)
		return 0;
	else
		return new mgListItem(this);
}

void
mgListItem::set(string v,string i,unsigned int c)
{
	assert(this);
	m_valid=true;
	m_value=v;
	m_id=i;
	m_count=c;
}

void
mgListItem::set_unique_id(string uid)
{
	assert(this);
	m_unique_id=uid;
}

void 
mgListItem::operator=(const mgListItem& from)
{
	assert(this);
	m_valid=from.m_valid;
	m_value=from.m_value;
	m_id=from.m_id;
	m_unique_id=from.m_unique_id;
	m_count=from.m_count;
}

void
mgListItem::operator=(const mgListItem* from)
{
	assert(this);
	m_valid=from->valid();
	m_value=from->value();
	m_id=from->id();
	m_unique_id=from->unique_id();
	m_count=from->count();
}

bool
mgListItem::operator==(const mgListItem& other) const
{
	if (!this)
		return false;
	return m_value == other.m_value
		&& m_id == other.m_id
		&& m_unique_id == other.m_unique_id;
}

string
mgListItem::value() const
{
	if (!this)
		return "";
	else
		return m_value;
}

string
mgListItem::id() const
{
	if (!this)
		return "";
	else
		return m_id;
}

string
mgListItem::unique_id() const
{
	if (!this)
		return "";
	else
		return m_unique_id;
}

unsigned int
mgListItem::count() const
{
	if (!this)
		return 0;
	else
		return m_count;
}

bool
mgListItem::valid() const
{
	return this && m_valid;
}