2018-08-28 04:16:52 -03:00
|
|
|
/* This file is part of the sirit project.
|
2019-07-14 18:48:59 -03: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 04:16:52 -03:00
|
|
|
*/
|
|
|
|
|
|
2018-10-31 21:22:00 -03:00
|
|
|
#include <string>
|
2019-03-11 03:26:21 -03:00
|
|
|
#include "common_types.h"
|
|
|
|
|
#include "literal_string.h"
|
2018-08-28 04:16:52 -03:00
|
|
|
|
|
|
|
|
namespace Sirit {
|
|
|
|
|
|
2019-11-27 05:46:03 -03:00
|
|
|
LiteralString::LiteralString(std::string string_)
|
|
|
|
|
: Operand{OperandType::String}, string{std::move(string_)} {}
|
2018-08-28 04:16:52 -03:00
|
|
|
|
|
|
|
|
LiteralString::~LiteralString() = default;
|
|
|
|
|
|
|
|
|
|
void LiteralString::Fetch(Stream& stream) const {
|
2019-10-18 03:44:49 -03:00
|
|
|
stream.Write(string);
|
2018-08-28 04:16:52 -03:00
|
|
|
}
|
|
|
|
|
|
2019-11-27 05:25:27 -03:00
|
|
|
std::size_t LiteralString::GetWordCount() const noexcept {
|
|
|
|
|
return string.size() / 4 + 1;
|
2018-08-28 04:16:52 -03:00
|
|
|
}
|
|
|
|
|
|
2019-11-01 06:07:53 -03:00
|
|
|
bool LiteralString::operator==(const Operand& other) const noexcept {
|
|
|
|
|
if (!EqualType(other)) {
|
|
|
|
|
return false;
|
2018-08-28 04:16:52 -03:00
|
|
|
}
|
2019-11-01 06:07:53 -03:00
|
|
|
return static_cast<const LiteralString&>(other).string == string;
|
2018-08-28 04:16:52 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Sirit
|