emlabcpp
modern opinionated embedded C++ library
emlabcpp::cfg Namespace Reference

MIT License. More...

Classes

struct  deser_res
 
struct  status
 
struct  read_iface
 
struct  iface_base
 
struct  locate_current_info
 
struct  locate_next_info
 
struct  update_iface
 
struct  load_iface
 

Typedefs

using cell = uint64_t
 
template<typename T >
using opt = std::optional< T >
 

Enumerations

enum class  cell_kind : uint8_t {
  SINGLE ,
  MULTI
}
 
enum class  cache_res {
  SEEN ,
  NOT_SEEN
}
 
enum class  update_status_e : uint8_t {
  SUCCESS = 0x00 ,
  FULL = 0x01 ,
  MISSING_PAGE = 0x02 ,
  SERIALIZE_VALUE_ERROR ,
  WRITE_ERROR ,
  READ_ERROR ,
  DESER_ERROR ,
  RESET_KEYS_ERROR ,
  CLEAR_ERROR ,
  LOCATE_FAILED_ERROR ,
  ON_KVAL_ERROR ,
  MEM_NOT_PAGE_MULTIPLY_ERROR
}
 
enum class  hdr_state : uint8_t {
  A = 0x40 ,
  B = A + 0x40 ,
  C = B + 0x40
}
 

Functions

constexpr uint32_t closest_multiple_of (uint32_t x, uint32_t r) noexcept
 
opt< cell_kindser_cell (uint32_t key, std::span< std::byte const > value, std::span< std::byte, cell_size > dest)
 
opt< deser_resdeser_cell (std::span< std::byte, cell_size > c)
 
opt< std::span< std::byte > > store_kval_impl (uint32_t key, std::byte *beg, std::byte *val_end, std::byte *end)
 
template<typename T >
opt< std::span< std::byte > > store_val (T const &val, std::span< std::byte > buffer)
 
opt< std::span< std::byte > > store_val (std::span< std::byte const > val, std::span< std::byte > buffer)
 
template<typename T >
opt< T > get_val (std::span< std::byte const > data)
 
bool is_free_cell (std::span< std::byte, cell_size > cell)
 
locate_current_info locate_current_page (std::size_t mem_size, std::size_t page_size, read_iface &iface)
 
locate_next_info locate_next_page (std::size_t mem_size, std::size_t page_size, read_iface &iface)
 
bool decr_addr (std::size_t &addr, std::size_t n, std::size_t start_addr)
 
std::span< std::byte > manifest_value (bool is_seq, auto &cell_val, std::size_t start_addr, auto &addr, auto &iface, auto &buffer)
 
status store_key (std::size_t &addr, std::size_t end_addr, uint32_t key, update_iface &iface)
 
status dump_unseen_keys (std::size_t addr, std::size_t end_addr, update_iface &iface)
 
status update_stored_config (std::size_t start_addr, std::size_t end_addr, update_iface &iface)
 
status update (std::size_t mem_size, std::size_t page_size, update_iface &iface)
 
status load_stored_config (std::size_t start_addr, std::size_t end_addr, load_iface &iface)
 
status load (std::size_t mem_size, std::size_t page_size, load_iface &iface)
 
bool is_prefix_of_with_zeros (std::span< std::byte const > a, std::span< std::byte const > b)
 
opt< std::size_t > pop_from_container (auto &cont)
 
cache_res key_check_unseen_container (auto &cont, uint32_t key)
 
hdr_state next (hdr_state cs) noexcept
 
opt< hdr_statebyte_to_hdr (std::byte b) noexcept
 
opt< hdr_statehdr_to_hdr_state (std::span< std::byte, cell_size > b) noexcept
 
std::array< std::byte, 2 > get_hdr (hdr_state hst) noexcept
 

Variables

static constexpr uint16_t cell_size = sizeof( cell )
 
static constexpr uint16_t hcell_size = sizeof( cell ) / 2
 
static constexpr uint32_t key_mask = 0x7FFFFFFF
 
static constexpr uint32_t sin_bit_mask = 0x80000000
 

Detailed Description

MIT License.

Copyright (c) 2025 Jan Veverak Koniarik

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Class Documentation

◆ emlabcpp::cfg::deser_res

struct emlabcpp::cfg::deser_res
Class Members
bool is_seq
uint32_t key
uint32_t val

◆ emlabcpp::cfg::locate_current_info

struct emlabcpp::cfg::locate_current_info
+ Collaboration diagram for emlabcpp::cfg::locate_current_info:
Class Members
size_t addr
status status

◆ emlabcpp::cfg::locate_next_info

struct emlabcpp::cfg::locate_next_info
+ Collaboration diagram for emlabcpp::cfg::locate_next_info:
Class Members
size_t addr
hdr_state state
status status

Typedef Documentation

◆ cell

using emlabcpp::cfg::cell = typedef uint64_t

◆ opt

template<typename T >
using emlabcpp::cfg::opt = typedef std::optional< T >

Enumeration Type Documentation

◆ cache_res

Enumerator
SEEN 
NOT_SEEN 

◆ cell_kind

enum emlabcpp::cfg::cell_kind : uint8_t
strong
Enumerator
SINGLE 
MULTI 

◆ hdr_state

enum emlabcpp::cfg::hdr_state : uint8_t
strong
Enumerator

◆ update_status_e

enum emlabcpp::cfg::update_status_e : uint8_t
strong
Enumerator
SUCCESS 
FULL 
MISSING_PAGE 
SERIALIZE_VALUE_ERROR 
WRITE_ERROR 
READ_ERROR 
DESER_ERROR 
RESET_KEYS_ERROR 
CLEAR_ERROR 
LOCATE_FAILED_ERROR 
ON_KVAL_ERROR 
MEM_NOT_PAGE_MULTIPLY_ERROR 

Function Documentation

◆ byte_to_hdr()

opt< hdr_state > emlabcpp::cfg::byte_to_hdr ( std::byte  b)
inlinenoexcept

References A, B, and C.

◆ closest_multiple_of()

constexpr uint32_t emlabcpp::cfg::closest_multiple_of ( uint32_t  x,
uint32_t  r 
)
constexprnoexcept

◆ decr_addr()

bool emlabcpp::cfg::decr_addr ( std::size_t &  addr,
std::size_t  n,
std::size_t  start_addr 
)
inline

References cell_size.

◆ deser_cell()

opt< deser_res > emlabcpp::cfg::deser_cell ( std::span< std::byte, cell_size c)
inline

◆ dump_unseen_keys()

status emlabcpp::cfg::dump_unseen_keys ( std::size_t  addr,
std::size_t  end_addr,
update_iface iface 
)
inline

◆ get_hdr()

std::array< std::byte, 2 > emlabcpp::cfg::get_hdr ( hdr_state  hst)
inlinenoexcept

◆ get_val()

template<typename T >
opt< T > emlabcpp::cfg::get_val ( std::span< std::byte const >  data)

◆ hdr_to_hdr_state()

opt< hdr_state > emlabcpp::cfg::hdr_to_hdr_state ( std::span< std::byte, cell_size b)
inlinenoexcept

References byte_to_hdr().

◆ is_free_cell()

bool emlabcpp::cfg::is_free_cell ( std::span< std::byte, cell_size cell)
inline

References emlabcpp::all_of().

◆ is_prefix_of_with_zeros()

bool emlabcpp::cfg::is_prefix_of_with_zeros ( std::span< std::byte const >  a,
std::span< std::byte const >  b 
)
inline

◆ key_check_unseen_container()

cache_res emlabcpp::cfg::key_check_unseen_container ( auto &  cont,
uint32_t  key 
)

◆ load()

status emlabcpp::cfg::load ( std::size_t  mem_size,
std::size_t  page_size,
load_iface iface 
)
inline

◆ load_stored_config()

◆ locate_current_page()

locate_current_info emlabcpp::cfg::locate_current_page ( std::size_t  mem_size,
std::size_t  page_size,
read_iface iface 
)
inline

◆ locate_next_page()

locate_next_info emlabcpp::cfg::locate_next_page ( std::size_t  mem_size,
std::size_t  page_size,
read_iface iface 
)
inline

◆ manifest_value()

std::span< std::byte > emlabcpp::cfg::manifest_value ( bool  is_seq,
auto &  cell_val,
std::size_t  start_addr,
auto &  addr,
auto &  iface,
auto &  buffer 
)

References cell_size, and decr_addr().

◆ next()

hdr_state emlabcpp::cfg::next ( hdr_state  cs)
inlinenoexcept

References A, B, and C.

◆ pop_from_container()

opt< std::size_t > emlabcpp::cfg::pop_from_container ( auto &  cont)

◆ ser_cell()

opt< cell_kind > emlabcpp::cfg::ser_cell ( uint32_t  key,
std::span< std::byte const >  value,
std::span< std::byte, cell_size dest 
)
inline

◆ store_key()

status emlabcpp::cfg::store_key ( std::size_t &  addr,
std::size_t  end_addr,
uint32_t  key,
update_iface iface 
)
inline

◆ store_kval_impl()

opt< std::span< std::byte > > emlabcpp::cfg::store_kval_impl ( uint32_t  key,
std::byte *  beg,
std::byte *  val_end,
std::byte *  end 
)
inline

References cell_size, MULTI, ser_cell(), and SINGLE.

◆ store_val() [1/2]

opt< std::span< std::byte > > emlabcpp::cfg::store_val ( std::span< std::byte const >  val,
std::span< std::byte >  buffer 
)
inline

◆ store_val() [2/2]

template<typename T >
opt< std::span< std::byte > > emlabcpp::cfg::store_val ( T const &  val,
std::span< std::byte >  buffer 
)

◆ update()

◆ update_stored_config()

Variable Documentation

◆ cell_size

constexpr uint16_t emlabcpp::cfg::cell_size = sizeof( cell )
staticconstexpr

◆ hcell_size

constexpr uint16_t emlabcpp::cfg::hcell_size = sizeof( cell ) / 2
staticconstexpr

◆ key_mask

constexpr uint32_t emlabcpp::cfg::key_mask = 0x7FFFFFFF
staticconstexpr

◆ sin_bit_mask

constexpr uint32_t emlabcpp::cfg::sin_bit_mask = 0x80000000
staticconstexpr