initial commit
This commit is contained in:
commit
4b60ece582
327 changed files with 28286 additions and 0 deletions
146
lib/wType/boolean.cpp
Normal file
146
lib/wType/boolean.cpp
Normal file
|
@ -0,0 +1,146 @@
|
|||
#include "boolean.h"
|
||||
|
||||
W::Boolean::Boolean():
|
||||
Object(),
|
||||
data(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
W::Boolean::Boolean(bool value):
|
||||
Object(),
|
||||
data(value)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
W::Boolean::Boolean(const W::Boolean& original):
|
||||
Object(),
|
||||
data(original.data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
W::Boolean::~Boolean()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
W::Boolean& W::Boolean::operator=(const W::Boolean& original)
|
||||
{
|
||||
data = original.data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
W::Boolean& W::Boolean::operator=(bool original)
|
||||
{
|
||||
data = original;
|
||||
return *this;
|
||||
}
|
||||
|
||||
W::Object::StdStr W::Boolean::toString() const
|
||||
{
|
||||
StdStr str;
|
||||
if (data)
|
||||
{
|
||||
str = "true";
|
||||
}
|
||||
else
|
||||
{
|
||||
str = "false";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
W::Object::objectType W::Boolean::getType() const
|
||||
{
|
||||
return Boolean::type;
|
||||
}
|
||||
|
||||
W::Object::size_type W::Boolean::length() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
W::Object* W::Boolean::copy() const
|
||||
{
|
||||
return new Boolean(*this);
|
||||
}
|
||||
|
||||
bool W::Boolean::operator>(const W::Boolean& other) const
|
||||
{
|
||||
return data > other.data;
|
||||
}
|
||||
|
||||
bool W::Boolean::operator<(const W::Boolean& other) const
|
||||
{
|
||||
return data < other.data;
|
||||
}
|
||||
|
||||
bool W::Boolean::operator==(const W::Boolean& other) const
|
||||
{
|
||||
return data == other.data;
|
||||
}
|
||||
|
||||
bool W::Boolean::operator!=(const W::Boolean& other) const
|
||||
{
|
||||
return data != other.data;
|
||||
}
|
||||
|
||||
bool W::Boolean::operator<=(const W::Boolean& other) const
|
||||
{
|
||||
return data <= other.data;
|
||||
}
|
||||
|
||||
bool W::Boolean::operator>=(const W::Boolean& other) const
|
||||
{
|
||||
return data >= other.data;
|
||||
}
|
||||
|
||||
void W::Boolean::serialize(W::ByteArray& out) const
|
||||
{
|
||||
uint8_t val;
|
||||
if (data)
|
||||
{
|
||||
val = 253;
|
||||
}
|
||||
else
|
||||
{
|
||||
val = 0;
|
||||
}
|
||||
|
||||
out.push8(val);
|
||||
}
|
||||
|
||||
void W::Boolean::deserialize(W::ByteArray& in)
|
||||
{
|
||||
uint8_t val = in.pop8();
|
||||
|
||||
if (val == 253)
|
||||
{
|
||||
data = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = false;
|
||||
}
|
||||
}
|
||||
|
||||
W::Boolean::operator bool() const
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
bool W::Boolean::operator==(const W::Object& other) const
|
||||
{
|
||||
if (sameType(other)) {
|
||||
return operator==(static_cast<const W::Boolean&>(other));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
W::Object::size_type W::Boolean::size() const
|
||||
{
|
||||
return 1;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue