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 11 BulletData::BulletData() 12 : 13 fString(""), 14 fSpacing(0.0f) 15 { 16 } 17 18 19 BulletData::BulletData(const BString& string, float spacing) 20 : 21 fString(string), 22 fSpacing(spacing) 23 { 24 } 25 26 27 BulletData::BulletData(const BulletData& other) 28 : 29 fString(other.fString), 30 fSpacing(other.fSpacing) 31 { 32 } 33 34 35 bool 36 BulletData::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 46 bool 47 BulletData::operator!=(const BulletData& other) const 48 { 49 return !(*this == other); 50 } 51 52 53 BulletDataRef 54 BulletData::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 68 BulletDataRef 69 BulletData::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 86 BulletData& 87 BulletData::operator=(const BulletData& other) 88 { 89 return *this; 90 } 91