Renamed common::id_t to eid_t to avoid conflicts with system id_t

This commit is contained in:
Bartek Kryza
2024-06-05 21:19:46 +02:00
parent 2cf9d2f22a
commit 420475ab64
57 changed files with 370 additions and 356 deletions

View File

@@ -20,25 +20,25 @@
namespace clanguml::common {
id_t::id_t()
eid_t::eid_t()
: value_{0ULL}
, is_global_{true}
{
}
id_t::id_t(int64_t id)
eid_t::eid_t(int64_t id)
: value_{static_cast<type>(id)}
, is_global_{false}
{
}
id_t::id_t(type id)
eid_t::eid_t(type id)
: value_{id}
, is_global_{true}
{
}
id_t &id_t::operator=(int64_t ast_id)
eid_t &eid_t::operator=(int64_t ast_id)
{
// Can't assign ast_id if the id is already a global one
assert(!is_global_);
@@ -47,16 +47,16 @@ id_t &id_t::operator=(int64_t ast_id)
return *this;
}
bool id_t::is_global() const { return is_global_; }
bool eid_t::is_global() const { return is_global_; }
bool operator==(const id_t &lhs, const id_t &rhs)
bool operator==(const eid_t &lhs, const eid_t &rhs)
{
return (lhs.is_global_ == rhs.is_global_) && (lhs.value_ == rhs.value_);
}
bool operator==(const id_t &lhs, const uint64_t &v) { return lhs.value_ == v; }
bool operator==(const eid_t &lhs, const uint64_t &v) { return lhs.value_ == v; }
bool operator!=(const id_t &lhs, const uint64_t &v)
bool operator!=(const eid_t &lhs, const uint64_t &v)
{
// This is sadly necessary to catch accidental comparisons to empty
// std::optional<id_t>:
@@ -69,9 +69,9 @@ bool operator!=(const id_t &lhs, const uint64_t &v)
return lhs.value_ != v;
}
bool operator!=(const id_t &lhs, const id_t &rhs) { return !(lhs == rhs); }
bool operator!=(const eid_t &lhs, const eid_t &rhs) { return !(lhs == rhs); }
bool operator<(const id_t &lhs, const id_t &rhs)
bool operator<(const eid_t &lhs, const eid_t &rhs)
{
if (lhs.is_global_ != rhs.is_global_) {
return lhs.value_ < rhs.value_ + 1;
@@ -80,9 +80,9 @@ bool operator<(const id_t &lhs, const id_t &rhs)
return lhs.value_ < rhs.value_; // Compare values if is_global_ are the same
}
id_t::type id_t::value() const { return value_; }
eid_t::type eid_t::value() const { return value_; }
int64_t id_t::ast_local_value() const
int64_t eid_t::ast_local_value() const
{
assert(!is_global_);