pstore2
Public Member Functions | Static Public Member Functions | Friends | List of all members
pstore::indirect_string Class Reference

The string address can come in three forms: More...

#include <indirect_string.hpp>

Collaboration diagram for pstore::indirect_string:
Collaboration graph
[legend]

Public Member Functions

constexpr indirect_string (database const &db, address const addr) noexcept
 
constexpr indirect_string (database const &db, gsl::not_null< raw_sstring_view const *> const str) noexcept
 
bool operator== (indirect_string const &rhs) const
 
bool operator!= (indirect_string const &rhs) const
 
bool operator< (indirect_string const &rhs) const
 
raw_sstring_view as_string_view (gsl::not_null< shared_sstring_view *> owner) const
 
std::size_t length () const
 
raw_sstring_view as_db_string_view (gsl::not_null< shared_sstring_view *> const owner) const
 When it is known that the string body is a store address use this function to carry out additional checks that the address is reasonable. More...
 
std::string to_string () const
 
constexpr bool is_in_store () const noexcept
 
constexpr address in_store_address () const noexcept
 

Static Public Member Functions

static address write_body_and_patch_address (transaction_base &transaction, raw_sstring_view const &str, typed_address< address > address_to_patch)
 Write the body of a string and updates the indirect pointer so that it points to that body. More...
 
static indirect_string read (database const &db, typed_address< indirect_string > addr)
 Reads an indirect string from the store.
 

Friends

struct serialize::serializer< indirect_string >
 

Detailed Description

The string address can come in three forms:

  1. An shared_sstring_view string that hasn't been added to the index yet. This is indicated when is_pointer_ is true. The str_ member points to the string view.
  2. A database address which points to an in-memory shared_sstring_view. This happens when the string has been inserted, but the index has not yet been flushed. In this case, is_pointer_ is false and the LBS of address_ is set.
  3. An address of a string in the store. In this case, is_pointer_ is false and the LSB of address_ is clear.

The use of the LBS of the address field to distinguish between in-heap and in-store addresses means that the in-store string bodies must be 2-byte aligned.

Member Function Documentation

◆ as_db_string_view()

raw_sstring_view pstore::indirect_string::as_db_string_view ( gsl::not_null< shared_sstring_view *> const  owner) const
inline

When it is known that the string body is a store address use this function to carry out additional checks that the address is reasonable.

◆ in_store_address()

constexpr address pstore::indirect_string::in_store_address ( ) const
inlinenoexcept
Returns
The pstore address of the start of the string instance.

◆ is_in_store()

constexpr bool pstore::indirect_string::is_in_store ( ) const
inlinenoexcept
Returns
True if the pointee is in the store rather than on the heap.

◆ write_body_and_patch_address()

address pstore::indirect_string::write_body_and_patch_address ( transaction_base transaction,
raw_sstring_view const &  str,
typed_address< address address_to_patch 
)
static

Write the body of a string and updates the indirect pointer so that it points to that body.

Parameters
transactionThe transaction to which the string body is appended.
strThe string to be written.
address_to_patchThe in-store address of the indirect_string instance which will point to the string.
Returns
The address at which the string body was written.

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