blob: a7aa5fef54f028301fc40ea0acd5048c3084c23d [file] [log] [blame]
/*
* Copyright (C) 2019 CESNET, https://photonics.cesnet.cz/
*
* Written by Václav Kubernát <kubervac@fit.cvut.cz>
*
*/
#include "ast_values.hpp"
enum_::enum_() = default;
enum_::enum_(const std::string& value)
: m_value(value)
{
}
identityRef_::identityRef_() = default;
identityRef_::identityRef_(const std::string& value)
: m_value(value)
{
}
identityRef_::identityRef_(const std::string& module, const std::string& value)
: m_prefix(module_{module})
, m_value(value)
{
}
instanceIdentifier_::instanceIdentifier_(const std::string& xpath)
: m_xpath(xpath)
{
}
bool instanceIdentifier_::operator==(const instanceIdentifier_& other) const
{
return this->m_xpath == other.m_xpath;
}
bool instanceIdentifier_::operator<(const instanceIdentifier_& other) const
{
return this->m_xpath < other.m_xpath;
}
binary_::binary_() = default;
binary_::binary_(const std::string& value)
: m_value(value)
{
}
empty_::empty_() = default;
bool bits_::operator==(const bits_& other) const
{
return this->m_bits == other.m_bits;
}
bool bits_::operator<(const bits_& other) const
{
return this->m_bits < other.m_bits;
}
bool module_::operator<(const module_& b) const
{
return this->m_name < b.m_name;
}
bool identityRef_::operator==(const identityRef_& b) const
{
return this->m_prefix == b.m_prefix && this->m_value == b.m_value;
}
bool identityRef_::operator<(const identityRef_& b) const
{
return std::tie(this->m_prefix, this->m_value) < std::tie(b.m_prefix, b.m_value);
}
bool binary_::operator==(const binary_& b) const
{
return this->m_value == b.m_value;
}
bool binary_::operator<(const binary_& b) const
{
return this->m_value < b.m_value;
}
bool empty_::operator==(const empty_) const
{
return true;
}
bool empty_::operator<(const empty_) const
{
return false;
}
bool enum_::operator==(const enum_& b) const
{
return this->m_value == b.m_value;
}
bool enum_::operator<(const enum_& b) const
{
return this->m_value < b.m_value;
}
bool special_::operator==(const special_& b) const
{
return this->m_value == b.m_value;
}
bool special_::operator<(const special_& b) const
{
return this->m_value < b.m_value;
}
std::string specialValueToString(const special_& value)
{
switch (value.m_value) {
case SpecialValue::Container:
return "(container)";
case SpecialValue::PresenceContainer:
return "(presence container)";
case SpecialValue::List:
return "(list)";
case SpecialValue::LeafList:
return "(leaflist)";
}
__builtin_unreachable();
}