1/*
2 * Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
5
6#include "BulletData.h"
7
8#include <new>
9
10
11BulletData::BulletData()
12	:
13	fString(""),
14	fSpacing(0.0f)
15{
16}
17
18
19BulletData::BulletData(const BString& string, float spacing)
20	:
21	fString(string),
22	fSpacing(spacing)
23{
24}
25
26
27BulletData::BulletData(const BulletData& other)
28	:
29	fString(other.fString),
30	fSpacing(other.fSpacing)
31{
32}
33
34
35bool
36BulletData::operator==(const BulletData& other) const
37{
38	if (this == &other)
39		return true;
40
41	return fString == other.fString
42		&& fSpacing == other.fSpacing;
43}
44
45
46bool
47BulletData::operator!=(const BulletData& other) const
48{
49	return !(*this == other);
50}
51
52
53BulletDataRef
54BulletData::SetString(const BString& string)
55{
56	if (fString == string)
57		return BulletDataRef(this);
58
59	BulletData* ret = new(std::nothrow) BulletData(*this);
60	if (ret == NULL)
61		return BulletDataRef(this);
62
63	ret->fString = string;
64	return BulletDataRef(ret, true);
65}
66
67
68BulletDataRef
69BulletData::SetSpacing(float spacing)
70{
71	if (fSpacing == spacing)
72		return BulletDataRef(this);
73
74	BulletData* ret = new(std::nothrow) BulletData(*this);
75	if (ret == NULL)
76		return BulletDataRef(this);
77
78	ret->fSpacing = spacing;
79	return BulletDataRef(ret, true);
80}
81
82
83// #pragma mark - private
84
85
86BulletData&
87BulletData::operator=(const BulletData& other)
88{
89	return *this;
90}
91