Add scope_t::empty and scope_t::size

This commit is contained in:
Allan Odgaard
2013-08-30 12:07:11 +02:00
parent 79dc48acc3
commit 62e3db265c
2 changed files with 15 additions and 3 deletions

View File

@@ -83,10 +83,20 @@ namespace scope
return NULL_STR;
}
bool scope_t::operator== (scope_t const& rhs) const { return (!path && !rhs.path) || (path && rhs.path && *path == *rhs.path); }
size_t scope_t::size () const
{
return path ? path->scopes.size() : 0;
}
bool scope_t::empty () const
{
return size() == 0;
}
bool scope_t::operator== (scope_t const& rhs) const { return (empty() && rhs.empty()) || (path && rhs.path && *path == *rhs.path); }
bool scope_t::operator!= (scope_t const& rhs) const { return !(*this == rhs); }
bool scope_t::operator< (scope_t const& rhs) const { return (!path && rhs.path) || (path && rhs.path && *path < *rhs.path); }
scope_t::operator bool () const { return path && !path->scopes.empty(); }
bool scope_t::operator< (scope_t const& rhs) const { return (empty() && !rhs.empty()) || (path && rhs.path && *path < *rhs.path); }
scope_t::operator bool () const { return !empty(); }
scope_t shared_prefix (scope_t const& lhs, scope_t const& rhs)
{

View File

@@ -33,6 +33,8 @@ namespace scope
void push_scope (std::string const& atom, bool contentScope = false);
void pop_scope ();
std::string back () const;
size_t size () const;
bool empty () const;
bool operator== (scope_t const& rhs) const;
bool operator!= (scope_t const& rhs) const;