Rumba C++ SDK
maquina::Token Class Reference

A token is a shared, constant and unique string. More...

#include <Token.h>

Public Member Functions

 Token ()=delete
 
 Token (Token &&)=delete
 
Tokenoperator= (Token &&)=delete
 
MAQUINA_EXPORT Token (const char *s)
 Build a token using a string. That operation is expensive. More...
 
 Token (const Token &o)
 Copy a token, this is fast. More...
 
Tokenoperator= (const Token &o)
 Copy a token, this is fast. More...
 
const char * c_str () const
 Return a string pointer, this is fast. More...
 
const std::string & string () const
 Return a string object, this is fast. More...
 
std::string_view string_view () const
 Return a string_view object, this is fast. More...
 
std::size_t size () const
 Return the token size, this is fast. More...
 
std::size_t hash () const
 Return a string hash, this is fast. More...
 
bool operator== (const Token &o) const
 Comparisons are fast. More...
 
bool operator!= (const Token &o) const
 
bool operator< (const Token &o) const
 
bool operator<= (const Token &o) const
 
bool operator> (const Token &o) const
 
bool operator>= (const Token &o) const
 

Friends

class TokenManager
 

Detailed Description

A token is a shared, constant and unique string.

For a given string, a token is unique. All comparisons, including order operators, are done using pointers. A token is small. Creating a token from a raw string is expensive. Comparing tokens is fast. Token comparison operators exists and the order is consistant, but the order itself is undefined. Once crafted, a token is never deleted. Token are thread safe. Most operations are lock free, except the creation of the first token for a given string in a thread.

Constructor & Destructor Documentation

◆ Token() [1/4]

maquina::Token::Token ( )
delete

◆ Token() [2/4]

maquina::Token::Token ( Token &&  )
delete

◆ Token() [3/4]

MAQUINA_EXPORT maquina::Token::Token ( const char *  s)
explicit

Build a token using a string. That operation is expensive.

◆ Token() [4/4]

maquina::Token::Token ( const Token o)
inline

Copy a token, this is fast.

Member Function Documentation

◆ c_str()

const char* maquina::Token::c_str ( ) const
inline

Return a string pointer, this is fast.

◆ hash()

std::size_t maquina::Token::hash ( ) const
inline

Return a string hash, this is fast.

◆ operator!=()

bool maquina::Token::operator!= ( const Token o) const
inline

◆ operator<()

bool maquina::Token::operator< ( const Token o) const
inline

◆ operator<=()

bool maquina::Token::operator<= ( const Token o) const
inline

◆ operator=() [1/2]

Token& maquina::Token::operator= ( Token &&  )
delete

◆ operator=() [2/2]

Token& maquina::Token::operator= ( const Token o)
inline

Copy a token, this is fast.

◆ operator==()

bool maquina::Token::operator== ( const Token o) const
inline

Comparisons are fast.

◆ operator>()

bool maquina::Token::operator> ( const Token o) const
inline

◆ operator>=()

bool maquina::Token::operator>= ( const Token o) const
inline

◆ size()

std::size_t maquina::Token::size ( ) const
inline

Return the token size, this is fast.

◆ string()

const std::string& maquina::Token::string ( ) const
inline

Return a string object, this is fast.

◆ string_view()

std::string_view maquina::Token::string_view ( ) const
inline

Return a string_view object, this is fast.

Friends And Related Function Documentation

◆ TokenManager

friend class TokenManager
friend

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