You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include "IntegerData.h"
|
|
|
|
|
#include <sstream>
|
|
|
|
|
#include <iomanip>
|
|
|
|
|
#include <ctime>
|
|
|
|
|
|
|
|
|
|
#include "Utils.h"
|
|
|
|
|
|
|
|
|
|
IntegerData::IntegerData()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IntegerData::IntegerData(int &data)
|
|
|
|
|
{
|
|
|
|
|
m_data = data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Data* IntegerData::clone()
|
|
|
|
|
{
|
|
|
|
|
Data* data = new IntegerData(m_data);
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IntegerData::copy(Data* data)
|
|
|
|
|
{
|
|
|
|
|
IntegerData *dt = dynamic_cast<IntegerData *>(data);
|
|
|
|
|
m_data = dt->getData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IntegerData::copy(Data& data)
|
|
|
|
|
{
|
|
|
|
|
IntegerData *dt = dynamic_cast<IntegerData *>(&data);
|
|
|
|
|
m_data = dt->getData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string IntegerData::toStr()
|
|
|
|
|
{
|
|
|
|
|
return std::to_string(m_data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string IntegerData::toByteStr()
|
|
|
|
|
{
|
|
|
|
|
return Utils::intToByteStr(m_data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string IntegerData::toHexStr()
|
|
|
|
|
{
|
|
|
|
|
return Utils::strToHexStr(Utils::intToByteStr(m_data));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IntegerData::fromByteStr(std::string str)
|
|
|
|
|
{
|
|
|
|
|
m_data = Utils::byteStrToInt(str);
|
|
|
|
|
return true;
|
|
|
|
|
}
|