SObjectizer 5.8
Loading...
Searching...
No Matches
so_5::name_for_agent_t Class Reference

Type for holding agent name. More...

#include <agent_tuning_options.hpp>

Public Member Functions

 name_for_agent_t ()
 Default constructor makes an null value.
 
 name_for_agent_t (std::string_view value)
 Initializing constructor.
 
 name_for_agent_t (const name_for_agent_t &)
 
name_for_agent_toperator= (const name_for_agent_t &)
 
 name_for_agent_t (name_for_agent_t &&other) noexcept
 
name_for_agent_toperator= (name_for_agent_t &&other) noexcept
 
 ~name_for_agent_t ()
 
std::string_view as_string_view () const
 Get the value as a string_view.
 
bool has_value () const noexcept
 Does this object have a value?
 
 operator bool () const noexcept
 Does this object have a value?
 

Private Attributes

std::unique_ptr< char[] > m_value
 Name storage.
 
unsigned int m_length
 Name length.
 

Friends

SO_5_FUNC void swap (name_for_agent_t &a, name_for_agent_t &b)
 

Detailed Description

Type for holding agent name.

Unlike std::string it has no small-string optimization, but its size is just a (sizeof(char *)+sizeof(unsigned int)), so it is smaller than std::string in cases when agent's name is empty.

Note
This type holds a copy of name (without the terminal 0-symbol). If name is not set (or if the content of the object is moved out) then a nullptr is held and the object is treated as empty or null-object.
Attention
The size of a name has to be fit into unsigned int, not into std::size_t, so name of agent can't exceed 4GiB if unsigned int is 32-bit.
Since
v.5.8.2

Definition at line 85 of file agent_tuning_options.hpp.

Constructor & Destructor Documentation

◆ name_for_agent_t() [1/4]

so_5::name_for_agent_t::name_for_agent_t ( )

Default constructor makes an null value.

Definition at line 104 of file agent.cpp.

◆ name_for_agent_t() [2/4]

so_5::name_for_agent_t::name_for_agent_t ( std::string_view value)
explicit

Initializing constructor.

Attention
It throws is value has zero length.
It throws is the length of value can't fit into unsigned int.

Definition at line 108 of file agent.cpp.

◆ name_for_agent_t() [3/4]

so_5::name_for_agent_t::name_for_agent_t ( const name_for_agent_t & other)

Definition at line 115 of file agent.cpp.

◆ name_for_agent_t() [4/4]

so_5::name_for_agent_t::name_for_agent_t ( name_for_agent_t && other)
noexcept

Definition at line 136 of file agent.cpp.

◆ ~name_for_agent_t()

so_5::name_for_agent_t::~name_for_agent_t ( )
default

Member Function Documentation

◆ as_string_view()

std::string_view so_5::name_for_agent_t::as_string_view ( ) const
nodiscard

Get the value as a string_view.

Note
If the object is null, then it produces an empty string_view.

Definition at line 160 of file agent.cpp.

◆ has_value()

bool so_5::name_for_agent_t::has_value ( ) const
nodiscardnoexcept

Does this object have a value?

Definition at line 169 of file agent.cpp.

◆ operator bool()

so_5::name_for_agent_t::operator bool ( ) const
inlineexplicitnoexcept

Does this object have a value?

Definition at line 143 of file agent_tuning_options.hpp.

◆ operator=() [1/2]

name_for_agent_t & so_5::name_for_agent_t::operator= ( const name_for_agent_t & other)

Definition at line 129 of file agent.cpp.

◆ operator=() [2/2]

name_for_agent_t & so_5::name_for_agent_t::operator= ( name_for_agent_t && other)
noexcept

Definition at line 142 of file agent.cpp.

Friends And Related Symbol Documentation

◆ swap

SO_5_FUNC void swap ( name_for_agent_t & a,
name_for_agent_t & b )
friend

Definition at line 150 of file agent.cpp.

Member Data Documentation

◆ m_length

unsigned int so_5::name_for_agent_t::m_length
private

Name length.

Definition at line 98 of file agent_tuning_options.hpp.

◆ m_value

std::unique_ptr< char[] > so_5::name_for_agent_t::m_value
private

Name storage.

Note
It doesn't have a terminating 0-symbol.

Definition at line 95 of file agent_tuning_options.hpp.


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