1 #ifndef REFERENCE_CACHE_H
2 #define REFERENCE_CACHE_H
119 using map = std::map<std::string,entry>;
135 return get_map().insert(hint,v);
152 return get_map().lower_bound(key);
157 auto i =
get_map().lower_bound(
id);
159 std::string
const & key = i->first;
160 if (key.find(
id) == 0 &&
161 (key.length() ==
id.length() || key[
id.length()] ==
'(')) {
static iterator insert(value_type const &v, iterator hint)
Insert a value_type into the cache.
static bool at_end(Iter i)
Say whether an iterator points to the end of the cache.
void set_reported(bool value=true)
Mark the entry as reported, or not.
evaluation _eval
The evaluation of the cached reference.
bool _reported
Has the reference been reported.
static iterator lower_bound(std::string const &key)
Get an iteraror to the lower bound of a key in the cache.
static void clear()
Empty the cache.
map::iterator iterator
Iterator type on map
map::value_type value_type
Value-type of map
void set_complete(bool value=true)
Mark the entry as fully expanded, or not.
bool _complete
Is the cached expansion complete?
std::string _expansion
The expansion of the cached reference.
static iterator insert(std::string const &key, entry const &e, iterator hint)
Insert an entry by key into cache.
evaluation const & eval() const
Get a [const] reference to the evaluation of the cached reference.
std::map< std::string, entry > map
Type of map implementing the reference cache.
std::string const & expansion() const
Get the expansion of the cached reference.
static map & get_map()
The cache map.
struct reference_cache encapsulates a cache of the the expansions and evaluations of symbol reference...
entry(std::string const &expansion, evaluation const &eval, bool reported=false, bool complete=true)
std::pair< iterator, bool > insert_result
Type of result of insertion.
Encapsulates an entry in the reference cache.
static void erase_symbol(std::string const &id)
Delete all cached references of a given symbol.
bool complete() const
Is the cached reference fully expanded?
struct evaluation represents the result of evaluating a putative expression.
map::const_iterator const_iterator
Const-iterator type on map
bool reported() const
Has the cached reference been reported.