vfs: check userland buffers before reading them.
[haiku.git] / src / apps / haikudepot / textview / Bullet.cpp
blobce1bbb30f5cff9e3ccde5b426ab00644e15dfc3b
1 /*
2 * Copyright 2013, Stephan Aßmus <superstippi@gmx.de>.
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
6 #include "Bullet.h"
9 static BulletData sEmptyBullet;
12 Bullet::Bullet()
14 fBulletData(&sEmptyBullet)
19 Bullet::Bullet(const BString& string, float spacing)
21 fBulletData(new BulletData(string, spacing), true)
26 Bullet::Bullet(const Bullet& other)
28 fBulletData(other.fBulletData)
33 Bullet&
34 Bullet::operator=(const Bullet& other)
36 if (this == &other)
37 return *this;
39 fBulletData = other.fBulletData;
40 return *this;
44 bool
45 Bullet::operator==(const Bullet& other) const
47 if (this == &other)
48 return true;
50 if (fBulletData == other.fBulletData)
51 return true;
53 if (fBulletData.Get() != NULL && other.fBulletData.Get() != NULL)
54 return *fBulletData.Get() == *other.fBulletData.Get();
56 return false;
60 bool
61 Bullet::operator!=(const Bullet& other) const
63 return !(*this == other);
67 bool
68 Bullet::SetString(const BString& string)
70 BulletDataRef data = fBulletData->SetString(string);
71 if (data == fBulletData)
72 return data->String() == string;
74 fBulletData = data;
75 return true;
79 const BString&
80 Bullet::String() const
82 return fBulletData->String();
86 bool
87 Bullet::SetSpacing(float spacing)
89 BulletDataRef data = fBulletData->SetSpacing(spacing);
90 if (data == fBulletData)
91 return data->Spacing() == spacing;
93 fBulletData = data;
94 return true;
98 float
99 Bullet::Spacing() const
101 return fBulletData->Spacing();