Merge pull request #3486 from akva2/backport_PR_3484

Backport #3484: fixed: missing serialization of tokens in UDQDefine
This commit is contained in:
Arne Morten Kvarving 2023-04-26 12:57:13 +02:00 committed by GitHub
commit 3f3a0c307d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 1 deletions

View File

@ -94,6 +94,7 @@ public:
void serializeOp(Serializer& serializer)
{
serializer(m_keyword);
serializer(m_tokens);
serializer(ast);
serializer(m_var_type);
serializer(m_location);

View File

@ -30,15 +30,29 @@ namespace Opm {
class UDQToken {
public:
UDQToken() = default;
UDQToken(const std::string& string_token, UDQTokenType token_type);
UDQToken(const std::string& string_token, const std::vector<std::string>& selector);
static UDQToken serializationTestObject();
const std::vector<std::string>& selector() const;
const std::variant<std::string, double>& value() const;
UDQTokenType type() const;
std::string str() const;
bool operator==(const UDQToken&) const;
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(token_type);
serializer(m_value);
serializer(m_selector);
}
private:
UDQTokenType token_type;
UDQTokenType token_type{UDQTokenType::error};
std::variant<std::string,double> m_value;
std::vector<std::string> m_selector;
};

View File

@ -279,6 +279,7 @@ UDQDefine UDQDefine::serializationTestObject()
{
UDQDefine result;
result.m_keyword = "test1";
result.m_tokens = {UDQToken::serializationTestObject()};
result.ast = std::make_shared<UDQASTNode>(UDQASTNode::serializationTestObject());
result.m_var_type = UDQVarType::SEGMENT_VAR;
result.string_data = "test2";
@ -404,6 +405,7 @@ bool UDQDefine::operator==(const UDQDefine& data) const
}
return (this->keyword() == data.keyword())
&& (this->m_tokens == data.m_tokens)
&& (this->m_location == data.location())
&& (this->var_type() == data.var_type())
&& (this->status() == data.status())

View File

@ -89,4 +89,16 @@ std::string UDQToken::str() const
}
}
UDQToken UDQToken::serializationTestObject()
{
return UDQToken{"test1", {"test2", "test3"}};
}
bool UDQToken::operator==(const UDQToken& rhs) const
{
return this->token_type == rhs.token_type &&
this->m_value == rhs.m_value &&
this->m_selector == rhs.m_selector;
}
} // namespace Opm