Spicy
Classes | Public Member Functions | List of all members
hilti::detail::IDBase< Derived, N > Class Template Reference

#include <id-base.h>

Classes

struct  AlreadyNormalized
 

Public Member Functions

 IDBase (const char *s)
 
 IDBase (std::string s)
 
 IDBase (std::string id, AlreadyNormalized)
 
template<typename... T, typename enable = std::enable_if_t<(... && std::is_convertible_v<T, std::string>)>>
 IDBase (const T &... s)
 
 IDBase (const std::initializer_list< std::string > &x)
 
const auto & str () const
 
Derived namespace_ () const
 
Derived local () const
 
bool empty () const
 
Derived sub (int i) const
 
Derived sub (int from, int to) const
 
Derived firstN (int n) const
 
Derived lastN (int n) const
 
Derived relativeTo (const Derived &root) const
 
Derived operator+ (const std::string &other) const
 
Derived operator+ (const Derived &other) const
 
Derived & operator+= (std::string other)
 
Derived & operator+= (const Derived &other)
 
bool operator== (const Derived &other) const
 
bool operator!= (const Derived &other) const
 
bool operator== (const std::string &other) const
 
bool operator!= (const std::string &other) const
 
bool operator< (const Derived &other) const
 
 operator bool () const
 
 operator std::string () const
 

Detailed Description

template<class Derived, normalizer_func N = identity_normalizer>
class hilti::detail::IDBase< Derived, N >

Base class for representing scoped language IDs. It provides a number of standard accesasorsd and manipulators to support operations on/with namespaces. This class assumes that namespaces are seperated with ::.

Template Parameters
Derivedname of the class deriving from this one (CRTP).
Na function that may preprocess/normalize all ID components before storing them

Constructor & Destructor Documentation

◆ IDBase() [1/2]

template<class Derived, normalizer_func N = identity_normalizer>
template<typename... T, typename enable = std::enable_if_t<(... && std::is_convertible_v<T, std::string>)>>
hilti::detail::IDBase< Derived, N >::IDBase ( const T &...  s)
inlineexplicit

Concatenates multiple strings into a single ID, separating them with ::.

◆ IDBase() [2/2]

template<class Derived, normalizer_func N = identity_normalizer>
hilti::detail::IDBase< Derived, N >::IDBase ( const std::initializer_list< std::string > &  x)
inline

Concatenates multiple strings into a single ID, separating them with ::.

Member Function Documentation

◆ empty()

template<class Derived, normalizer_func N = identity_normalizer>
bool hilti::detail::IDBase< Derived, N >::empty ( ) const
inline

Returns true if the ID's value has length zero.

◆ firstN()

template<class Derived, normalizer_func N = identity_normalizer>
Derived hilti::detail::IDBase< Derived, N >::firstN ( int  n) const
inline

Returns a new ID containing the a subpath of the ID, starting at the beginning.

Parameters
nnumber of path components to include

◆ lastN()

template<class Derived, normalizer_func N = identity_normalizer>
Derived hilti::detail::IDBase< Derived, N >::lastN ( int  n) const
inline

Returns a new ID containing the a subpath of the ID, starting at the end.

Parameters
nnumber of path components to include

◆ local()

template<class Derived, normalizer_func N = identity_normalizer>
Derived hilti::detail::IDBase< Derived, N >::local ( ) const
inline

Returns the ID local part.

◆ namespace_()

template<class Derived, normalizer_func N = identity_normalizer>
Derived hilti::detail::IDBase< Derived, N >::namespace_ ( ) const
inline

Returns the ID's namespace. That's everything except the local part.

◆ operator+() [1/2]

template<class Derived, normalizer_func N = identity_normalizer>
Derived hilti::detail::IDBase< Derived, N >::operator+ ( const std::string &  other) const
inline

Concantenates two IDs, separating them wiht ::.

◆ operator+() [2/2]

template<class Derived, normalizer_func N = identity_normalizer>
Derived hilti::detail::IDBase< Derived, N >::operator+ ( const Derived &  other) const
inline

Concantenates two IDs, separating them wiht ::.

◆ operator+=() [1/2]

template<class Derived, normalizer_func N = identity_normalizer>
Derived& hilti::detail::IDBase< Derived, N >::operator+= ( std::string  other)
inline

Appends an ID, separating it with ::.

◆ operator+=() [2/2]

template<class Derived, normalizer_func N = identity_normalizer>
Derived& hilti::detail::IDBase< Derived, N >::operator+= ( const Derived &  other)
inline

Appends an ID, separating it with ::.

◆ relativeTo()

template<class Derived, normalizer_func N = identity_normalizer>
Derived hilti::detail::IDBase< Derived, N >::relativeTo ( const Derived &  root) const
inline

"Rebases" the ID relative to another one.

If the ID already starts with root, the remaining part is returned. If not, the returned value is root plus the ID.

◆ str()

template<class Derived, normalizer_func N = identity_normalizer>
const auto& hilti::detail::IDBase< Derived, N >::str ( ) const
inline

Returns the ID's full name as a string.

◆ sub() [1/2]

template<class Derived, normalizer_func N = identity_normalizer>
Derived hilti::detail::IDBase< Derived, N >::sub ( int  i) const
inline

Returns a new ID containing just single component of the path;s of the ID. Indices are zero-based and, if negative, counted from the end Python-style.

Parameters
iindex of path component to return

◆ sub() [2/2]

template<class Derived, normalizer_func N = identity_normalizer>
Derived hilti::detail::IDBase< Derived, N >::sub ( int  from,
int  to 
) const
inline

Returns a new ID containing a subpath of the ID. Indices are zero-based and, if negative, counted from the end Python-style.

Parameters
from1st index to include
toone beyond last index to include

The documentation for this class was generated from the following file: