Clingo
Loading...
Searching...
No Matches
CppClingo::SharedSymbol Class Reference

Class managing the lifetime of a Symbol. More...

#include <symbol.hh>

Public Member Functions

constexpr SharedSymbol () noexcept=default
 Create a symbol for number zero.
 
 SharedSymbol (Symbol sym, bool acquire=true) noexcept
 Take ownership of the symbol.
 
 ~SharedSymbol ()
 Release ownership of the held symbol.
 
 SharedSymbol (SharedSymbol const &sym) noexcept
 Copy constructor.
 
 SharedSymbol (SharedSymbol &&sym) noexcept
 Move constructor.
 
auto operator= (SharedSymbol const &sym) noexcept -> SharedSymbol &
 Copy assignment.
 
auto operator= (SharedSymbol &&sym) noexcept -> SharedSymbol &
 Move assignment.
 
auto get () const -> Symbol const &
 Get a reference to the contained symbol.
 
auto operator* () const -> Symbol const &
 Get the contained string reference.
 
auto operator-> () const -> Symbol const *
 Get the contained string reference.
 
auto hash () const -> size_t
 Compute the hash of the symbol.
 

Static Public Member Functions

static auto to_rep (SharedSymbol const &sym) -> uint64_t
 Get an integer representation of the symbol.
 
static auto from_rep (uint64_t repr) -> SharedSymbol
 Create a shared symbol from its representation.
 

Friends

auto compare (SharedSymbol const &a, SharedSymbol const &b) -> int
 Compare two symbols.
 
auto operator== (SharedSymbol const &a, SharedSymbol const &b) -> bool
 Equality compare two symbols.
 
auto operator== (SharedSymbol const &a, Symbol const &b) -> bool
 Equality compare two symbols.
 
auto operator== (Symbol const &a, SharedSymbol const &b) -> bool
 Equality compare two symbols.
 
auto operator<=> (SharedSymbol const &a, SharedSymbol const &b) -> std::strong_ordering
 Less than compare two symbols.
 
auto operator<=> (SharedSymbol const &a, Symbol const &b) -> std::strong_ordering
 Less than compare two symbols.
 
auto operator<=> (Symbol const &a, SharedSymbol const &b) -> std::strong_ordering
 Less than compare two symbols.
 

Detailed Description

Class managing the lifetime of a Symbol.

References held by this class are not collected by the gc method of the symbol store.

Constructor & Destructor Documentation

◆ SharedSymbol()

constexpr CppClingo::SharedSymbol::SharedSymbol ( )
constexprdefaultnoexcept

Create a symbol for number zero.

Number zero can exist independently of a symbol store.

Member Function Documentation

◆ from_rep()

static auto CppClingo::SharedSymbol::from_rep ( uint64_t  repr) -> SharedSymbol
inlinestatic

Create a shared symbol from its representation.

No reference counts are touched here.

◆ get()

auto CppClingo::SharedSymbol::get ( ) const -> Symbol const &
inline

Get a reference to the contained symbol.

The lifetime is tied to the symbol.

◆ to_rep()

static auto CppClingo::SharedSymbol::to_rep ( SharedSymbol const &  sym) -> uint64_t
inlinestatic

Get an integer representation of the symbol.

The representation increments the reference count of the symbol. To correctly free the symbol, it has to passed to from_rep again.


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