OGLplus  (0.59.0) a C++ wrapper for rendering APIs

eagine::basic_identifier< M, B, CharSet, UIntT > Class Template Reference

Basic template for limited length, packed string identifiers. More...

#include <eagine/identifier.hpp>

Public Types

using encoding = identifier_encoding< CharSet >
 Alias for the encoding type.
 
using size_type = span_size_t
 Alias for the length type.
 
using value_type = char
 Alias for the element type.
 
using name_type = identifier_name< M >
 Alias for the unpacked identifier_name type.
 

Public Member Functions

constexpr basic_identifier () noexcept=default
 Default constructor. Constructs an empty identifier.
 
template<std::size_t L, typename = std::enable_if_t<(L <= M + 1)>>
constexpr basic_identifier (const char(&init)[L]) noexcept
 Construction from a C-string literal.
 
constexpr basic_identifier (span< const char > init) noexcept
 Construction from a const span of characters.
 
constexpr auto is_empty () const noexcept -> bool
 Returns the size of this identifier. More...
 
constexpr auto size () const noexcept -> size_type
 Returns the size of this identifier. More...
 
constexpr auto operator[] (size_type idx) const noexcept -> value_type
 Subscript operator. Allows to access individual characters.
 
constexpr auto name () const noexcept -> name_type
 Returns this identifier as unpacked identifier_name. More...
 
auto str () const -> std::string
 Returns this identifier as unpacked standard string. More...
 

Static Public Member Functions

static constexpr auto max_size () noexcept -> size_type
 Returns the maximum length of this identifier type.
 

Friends

constexpr friend auto operator== (const basic_identifier &a, const basic_identifier &b) noexcept
 Equality comparison.
 
constexpr friend auto operator!= (const basic_identifier &a, const basic_identifier &b) noexcept
 Nonequality comparison.
 
constexpr friend auto operator< (const basic_identifier &a, const basic_identifier &b) noexcept
 Less-than comparison. More...
 
constexpr friend auto operator<= (const basic_identifier &a, const basic_identifier &b) noexcept
 Less-equal comparison. More...
 
constexpr friend auto operator> (const basic_identifier &a, const basic_identifier &b) noexcept
 Greater-than comparison. More...
 
constexpr friend auto operator>= (const basic_identifier &a, const basic_identifier &b) noexcept
 Greater-equal comparison. More...
 

Detailed Description

template<std::size_t M, std::size_t B, typename CharSet, typename UIntT>
class eagine::basic_identifier< M, B, CharSet, UIntT >

Basic template for limited length, packed string identifiers.

See also
identifier
long_identifier
EAGINE_ID

Packed identifier store short constant strings with limited allowed set of characters that are used as object identifiers throughout the project. The strings are constexpr encoded into unsigned integer values and are stored without dynamic memory allocation. Comparison operations on identifiers are typically more efficient than regular character string comparisons, but note that integer comparisons are used instead lexicographical comparisons.

Examples
eagine/identifier.cpp.

Member Function Documentation

◆ is_empty()

template<std::size_t M, std::size_t B, typename CharSet , typename UIntT >
constexpr auto eagine::basic_identifier< M, B, CharSet, UIntT >::is_empty ( ) const -> bool
inlineconstexprnoexcept

Returns the size of this identifier.

See also
size()

Referenced by eagine::basic_identifier< 10, 6, default_identifier_char_set, identifier_t >::size().

◆ name()

template<std::size_t M, std::size_t B, typename CharSet , typename UIntT >
constexpr auto eagine::basic_identifier< M, B, CharSet, UIntT >::name ( ) const -> name_type
inlineconstexprnoexcept

◆ size()

template<std::size_t M, std::size_t B, typename CharSet , typename UIntT >
constexpr auto eagine::basic_identifier< M, B, CharSet, UIntT >::size ( ) const -> size_type
inlineconstexprnoexcept

Returns the size of this identifier.

See also
is_empty()

◆ str()

template<std::size_t M, std::size_t B, typename CharSet , typename UIntT >
auto eagine::basic_identifier< M, B, CharSet, UIntT >::str ( ) const -> std::string
inline

Returns this identifier as unpacked standard string.

See also
identifier_name

Friends And Related Function Documentation

◆ operator<

template<std::size_t M, std::size_t B, typename CharSet , typename UIntT >
constexpr friend auto operator< ( const basic_identifier< M, B, CharSet, UIntT > &  a,
const basic_identifier< M, B, CharSet, UIntT > &  b 
)
friend

Less-than comparison.

Note
This is not lexicographical string comparison.

◆ operator<=

template<std::size_t M, std::size_t B, typename CharSet , typename UIntT >
constexpr friend auto operator<= ( const basic_identifier< M, B, CharSet, UIntT > &  a,
const basic_identifier< M, B, CharSet, UIntT > &  b 
)
friend

Less-equal comparison.

Note
This is not lexicographical string comparison.

◆ operator>

template<std::size_t M, std::size_t B, typename CharSet , typename UIntT >
constexpr friend auto operator> ( const basic_identifier< M, B, CharSet, UIntT > &  a,
const basic_identifier< M, B, CharSet, UIntT > &  b 
)
friend

Greater-than comparison.

Note
This is not lexicographical string comparison.

◆ operator>=

template<std::size_t M, std::size_t B, typename CharSet , typename UIntT >
constexpr friend auto operator>= ( const basic_identifier< M, B, CharSet, UIntT > &  a,
const basic_identifier< M, B, CharSet, UIntT > &  b 
)
friend

Greater-equal comparison.

Note
This is not lexicographical string comparison.

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

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).