1
0
Fork 0
mirror of https://git.suyu.dev/suyu/sirit.git synced 2024-12-23 04:32:04 +00:00
sirit/src/literal_string.cpp

34 lines
825 B
C++
Raw Normal View History

2018-08-28 08:16:52 +01:00
/* This file is part of the sirit project.
2019-07-14 22:48:59 +01:00
* Copyright (c) 2019 sirit
* This software may be used and distributed according to the terms of the
* 3-Clause BSD License
2018-08-28 08:16:52 +01:00
*/
#include <string>
2019-03-11 06:26:21 +00:00
#include "common_types.h"
#include "literal_string.h"
2018-08-28 08:16:52 +01:00
namespace Sirit {
LiteralString::LiteralString(std::string string)
: Operand{OperandType::String}, string{std::move(string)} {}
2018-08-28 08:16:52 +01:00
LiteralString::~LiteralString() = default;
void LiteralString::Fetch(Stream& stream) const {
stream.Write(string);
2018-08-28 08:16:52 +01:00
}
u16 LiteralString::GetWordCount() const {
return static_cast<u16>(string.size() / 4 + 1);
}
bool LiteralString::operator==(const Operand& other) const {
if (GetType() == other.GetType()) {
return static_cast<const LiteralString&>(other).string == string;
2018-08-28 08:16:52 +01:00
}
return false;
}
} // namespace Sirit