17 #ifndef PSTORE_CORE_INDIRECT_STRING_HPP 18 #define PSTORE_CORE_INDIRECT_STRING_HPP 48 constexpr indirect_string (
database const & db,
address const addr) noexcept
52 constexpr indirect_string (
database const & db,
57 PSTORE_ASSERT ((reinterpret_cast<std::uintptr_t> (str.get ()) & in_heap_mask) == 0);
60 bool operator== (indirect_string
const & rhs)
const;
61 bool operator!= (indirect_string
const & rhs)
const {
return !operator== (rhs); }
62 bool operator< (indirect_string
const & rhs)
const;
66 std::size_t length ()
const;
73 raise (error_code::bad_address);
75 return this->as_string_view (owner);
78 std::string to_string ()
const {
80 return this->as_string_view (&owner).to_string ();
85 return !is_pointer_ && !(
address_ & in_heap_mask);
110 static constexpr std::uint64_t in_heap_mask = 0x01;
111 bool equal_contents (indirect_string
const & rhs)
const;
125 template <
typename OStream>
128 return os << ind_str.as_string_view (&owner);
132 namespace serialize {
149 -> archive_result_type<archive::database_writer> {
150 return write_string_address (archive, value);
160 -> archive_result_type<archive::database_writer> {
161 return write_string_address (archive, value);
182 template <
typename DBArchive>
183 static auto write_string_address (DBArchive && archive, value_type
const & value)
184 -> archive_result_type<DBArchive>;
186 template <
typename DBArchive>
187 static void read_string_address (DBArchive && archive, value_type & value);
192 template <
typename DBArchive>
195 -> archive_result_type<DBArchive> {
198 PSTORE_ASSERT (value.is_pointer_);
199 constexpr
auto mask = indirect_string::in_heap_mask;
200 PSTORE_ASSERT (!(reinterpret_cast<std::uintptr_t> (value.
str_) & mask));
202 return archive.put (
address{
reinterpret_cast<std::uintptr_t
> (value.
str_) | mask});
214 return std::hash<pstore::raw_sstring_view>{}(str.as_string_view (&owner));
243 template <
typename Index>
245 std::shared_ptr<Index>
const & index,
251 std::vector<std::pair<raw_sstring_view const *, typed_address<address>>> views_;
256 template <
typename Index>
257 std::pair<typename Index::iterator, bool>
259 std::shared_ptr<Index>
const & index,
268 typename Index::iterator
const & pos = res.first;
305 #endif // PSTORE_CORE_INDIRECT_STRING_HPP address::value_type address_
The in-store/in-heap string address.
Definition: indirect_string.hpp:120
The primary template for serialization of non standard layout types.
Definition: types.hpp:118
An archive-reader which reads data from a database.
Definition: db_archive.hpp:102
constexpr bool is_in_store() const noexcept
Definition: indirect_string.hpp:84
Definition: address.hpp:81
constexpr address in_store_address() const noexcept
Definition: indirect_string.hpp:89
The string address can come in three forms:
Definition: indirect_string.hpp:44
Definition: chunked_sequence.hpp:607
raw_sstring_view const * str_
The address of the in-heap string.
Definition: indirect_string.hpp:121
Definition: transaction.hpp:191
Definition: address.hpp:231
static indirect_string read(database const &db, typed_address< indirect_string > addr)
Reads an indirect string from the store.
Definition: indirect_string.cpp:151
static auto write(archive::database_writer &archive, value_type const &value) -> archive_result_type< archive::database_writer >
Writes an instance of indirect_string to an archiver.
Definition: indirect_string.hpp:159
indirect_string_adder is a helper class which handles the details of adding strings to the "indirect"...
Definition: indirect_string.hpp:235
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...
Definition: indirect_string.cpp:95
Definition: nonpod2.cpp:40
Definition: database.hpp:40
Definition: db_archive.hpp:78
Definition: sstring_view.hpp:113
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 ch...
Definition: indirect_string.hpp:71
Defines serializer<> specializations for strings.
The database transaction class.
Definition: transaction.hpp:43
static auto write(archive::database_writer &&archive, value_type const &value) -> archive_result_type< archive::database_writer >
Writes an instance of indirect_string to an archiver.
Definition: indirect_string.hpp:148