2013-07-16 01:43:32 +00:00
|
|
|
/*
|
2013-07-19 17:29:33 +00:00
|
|
|
Copyright (c) 2013 Microsoft Corporation. All rights reserved.
|
2013-07-16 01:43:32 +00:00
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
2013-07-19 17:29:33 +00:00
|
|
|
Author: Leonardo de Moura
|
2013-07-16 01:43:32 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
|
|
|
|
constexpr char const * default_name_separator = "::";
|
|
|
|
|
|
|
|
/**
|
|
|
|
\brief Hierarchical names.
|
|
|
|
*/
|
|
|
|
class name {
|
|
|
|
enum class kind { ANONYMOUS, STRING, NUMERAL };
|
|
|
|
struct imp;
|
|
|
|
imp * m_imp;
|
|
|
|
name(imp * p);
|
|
|
|
public:
|
|
|
|
name();
|
2013-07-21 21:25:56 +00:00
|
|
|
explicit name(char const * name);
|
|
|
|
explicit name(unsigned k);
|
2013-07-16 01:43:32 +00:00
|
|
|
name(name const & prefix, char const * name);
|
|
|
|
name(name const & prefix, unsigned k);
|
|
|
|
name(name const & other);
|
|
|
|
name(name && other);
|
|
|
|
~name();
|
|
|
|
name & operator=(name const & other);
|
|
|
|
name & operator=(name && other);
|
|
|
|
bool operator==(name const & other) const;
|
|
|
|
bool operator!=(name const & other) const { return !operator==(other); }
|
|
|
|
kind get_kind() const;
|
|
|
|
bool is_anonymous() const { return get_kind() == kind::ANONYMOUS; }
|
|
|
|
bool is_string() const { return get_kind() == kind::STRING; }
|
|
|
|
bool is_numeral() const { return get_kind() == kind::NUMERAL; }
|
|
|
|
unsigned get_numeral() const;
|
|
|
|
char const * get_string() const;
|
|
|
|
bool is_atomic() const;
|
|
|
|
name get_prefix() const;
|
|
|
|
/**
|
|
|
|
\brief Size of the this name (in characters) when using the given separator.
|
|
|
|
*/
|
|
|
|
size_t size(char const * sep = default_name_separator) const;
|
2013-07-20 21:15:54 +00:00
|
|
|
unsigned hash() const;
|
2013-07-16 01:43:32 +00:00
|
|
|
friend std::ostream & operator<<(std::ostream & out, name const & n);
|
|
|
|
class sep {
|
|
|
|
name const & m_name;
|
|
|
|
char const * m_sep;
|
|
|
|
public:
|
|
|
|
sep(name const & n, char const * s);
|
|
|
|
friend std::ostream & operator<<(std::ostream & out, sep const & s);
|
|
|
|
};
|
|
|
|
friend std::ostream & operator<<(std::ostream & out, sep const & s);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|