Skip to content
Raymond Chen edited this page May 14, 2019 · 3 revisions

The xlang::meta::reader::cache structure is defined in meta_reader.h (via impl/meta_reader/cache.h) and accumulates information from zero or more metadata database files.

Construction

cache();
cache(std::vector<std::string> const& files);
cache(std::string const& file);

Creates a cache that aggregates information from the specified file or files.

If constructed with no operands, the cache is empty. An empty cache is not particularly useful seeing as there is no way to add anything to the cache later. But maybe you can use it as a sentinel or something.

Nested types

using namespace_type = std::pair<std::string_view const, namespace_members> const&;

The namespace_type provides a name for the key-value pair for the map returned by the namespaces() method.

Methods

databases

std::list<xlang::meta::reader::database> const& databases() const noexcept;

Returns a list of the databases that were loaded into the cache.

namespaces

std::map<std::string_view, namespace_members> const& namespaces() const;

Returns a map keyed by namespace name, whose values are the namespace_members objects that describe the contents of that namespace.

The underlying data for the std::string_view is the enclosing database. Therefore, the keys in the map are valid for as long as the database remains alive.

find

xlang::meta::reader::TypeDef
find(std::string_view const& type_namespace,
     std::string_view const& type_name) const noexcept; // (1)

xlang::meta::reader::TypeDef
find(std::string_view const& type_string) const; // (2)

Looks up a type in the cache.

The first version accepts the namespace and type name separately. The second version is a convenience overload which accepts the full type string and internally separates them into namespace and type name.

The second version throws std::invalid_argument if the full type string lacks a namespace qualifier.

If the type is not found, returns an empty TypeDef.

find_required

xlang::meta::reader::TypeDef
find_required(std::string_view const& type_namespace,
             std::string_view const& type_name) const noexcept; // (1)

xlang::meta::reader::TypeDef
find_required(std::string_view const& type_string) const; // (2)

Looks up a type in the cache. Behaves the same as find, but throws std::invalid_argument if the type is not found.

remove_type

void remove_type(std::string_view const& ns, std::string_view const name);

Removes the specified type from the cache's namespace_members.interfaces, namespace_members.classes, namespace_members.enums, namespace_members.structs, and namespace_members.delegates vectors.

Note that the type is not removed from the namespace_members.types map, in order not to invalidate references to the removed types.

Clone this wiki locally