374 template<
typename Input_it>
375 explicit Shared_name(Input_it begin, Input_it end);
398 template<
typename Source>
437 template<
typename Integer>
471 const std::string&
str()
const;
630 template<
typename Source>
670 template<
typename Source>
707template<
typename Input_it>
709 m_raw_name(begin, end)
714template<
typename Source>
727template<
typename Integer>
730 using std::is_same_v;
731 using std::is_integral_v;
732 using std::make_unsigned_t;
736 using int_t = Integer;
737 static_assert(is_integral_v<int_t>,
"Use an integer type please.");
738 static_assert(!is_same_v<int_t, bool>,
"Just use actual integer types please (char/uchar/int8_t/uint8_t are fine).");
739 using unsigned_t = make_unsigned_t<int_t>;
750 static_assert(
sizeof(unsigned_t) <= (64 / 8),
751 "Please use one of the integer types of bit width in [8, 64].");
754 if constexpr(
sizeof(unsigned_t) ==
sizeof(uint8_t)) { name.resize(
sizeof(
"-128") - 1); }
755 else if constexpr(
sizeof(unsigned_t) ==
sizeof(uint16_t)) { name.resize(
sizeof(
"-32768") - 1); }
756 else if constexpr(
sizeof(unsigned_t) ==
sizeof(uint32_t)) { name.resize(
sizeof(
"-2147483648") - 1); }
760 else if constexpr(
sizeof(unsigned_t) ==
sizeof(uint64_t)) { name.resize(20); }
762 const auto start_ptr = &(name.front());
763 const auto to_chars_result = to_chars(start_ptr, &(name.back()) + 1, src);
764 assert((to_chars_result.ec == errc{}) &&
"Did we not reserve enough space in target string?!");
766 name.resize(to_chars_result.ptr - start_ptr);
771template<
typename Source>
791template<
typename Source>
794 using std::is_convertible_v;
797 using std::string_view;
839 if constexpr(is_convertible_v<const Source&, string_view>)
845 const string_view view_to_append{raw_name_to_append};
846 const less<const char*> lt;
848 if (view_to_append.empty())
853 && lt(
m_raw_name.data(), view_to_append.data() + view_to_append.size()))
855 const string copy_to_append{view_to_append};
876template<
typename Source>
884template<
typename Source>
892template<
typename Source>
900template<
typename Source>
908template<
typename Persistent_
object,
typename Filter_func>
914 unsigned int count = 0;
916 Persistent_object::for_each_persistent([&](
const Shared_name& name)
918 if (filter_func(name))
920 Persistent_object::remove_persistent(logger_ptr, name, &err_code);
932template<
typename Persistent_
object>
938 FLOW_LOG_SET_CONTEXT(logger_ptr, Log_component::S_TRANSPORT);
939 FLOW_LOG_TRACE(
"Will attempt to remove-persistent objects (type [" <<
typeid(Persistent_object).name() <<
"]) with "
940 "prefix [" << name_prefix_or_empty.
str() <<
"] (<-- may be blank; then all are removed).");
943 const auto count = remove_each_persistent_if<Persistent_object>(get_logger(), [&](
const Shared_name& name)
945 return name_prefix_view.empty() ||
String_view{name.
str()}.starts_with(name_prefix_view);
950 FLOW_LOG_INFO(
"Removed-persistent successfully [" << count <<
"] objects "
951 "(type [" <<
typeid(Persistent_object).name() <<
"]) with "
952 "prefix [" << name_prefix_or_empty <<
"] (<-- may be blank; then all were potentially removed). "
953 "Note this counts only successful removals (not ones that failed due to permissions, say). "
954 "Details potentially logged above (including any errors which are otherwise ignored).");
String-wrapping abstraction representing a name uniquely distinguishing a kernel-persistent entity fr...
static Shared_name ct_from_int(Integer src)
Constructs from a value of an integer type, efficiently converting to a string representation of the ...
bool sanitized() const
Returns true if and only if the contained name/fragment is sanitized according to length,...
const char * native_str() const
Returns (sans copying) pointer to NUL-terminated wrapped name string, suitable to pass into sys calls...
Shared_name & operator=(Shared_name &&src_moved)
Move-assigns from an existing Shared_name.
Shared_name & operator+=(const Shared_name &src_to_append)
Appends the given other Shared_name.
Shared_name(const Shared_name &src)
Copy-constructs from an existing Shared_name.
Shared_name()
Constructs empty() name.
static constexpr size_t S_MAX_LENGTH
Max value of size() such that, if str() used to name a supported shared resource, sys call safely won...
static const Shared_name S_SENTINEL
A Shared_name fragment, with no S_SEPARATOR characters inside, that represents a path component that ...
static Shared_name ct(const Source &src)
Copy-constructs from a char-sequence container such as string or util::String_view.
static const Shared_name S_RESOURCE_TYPE_ID_SHM
Relative-folder fragment (no separators) identifying the resource type for: SHM pools.
std::string m_raw_name
The name or name fragment; see str().
static const Shared_name S_RESOURCE_TYPE_ID_MUTEX
Relative-folder fragment (no separators) identifying the resource type for: boost....
static bool sanitized_non_sep(char ch)
Helper that returns true if and only if: ch is a valid character for purposes of ....
static const Shared_name S_EMPTY
A (default-cted) Shared_name. May be useful for functions returning const Shared_name&.
bool has_trailing_separator() const
Returns true if and only if !this->empty(), and str() ends with the S_SEPARATOR character.
Shared_name(Shared_name &&src_moved)
Move-constructs from an existing Shared_name, which is made empty() if not already so.
void clear()
Makes it so empty() == true.
bool empty() const
Returns true if and only if str().empty() == true.
Shared_name & operator/=(const Shared_name &src_to_append)
Appends a folder separator followed by the given other Shared_name.
friend void swap(Shared_name &val1, Shared_name &val2)
Swaps two objects.
static const Shared_name S_1ST_OR_ONLY
A Shared_name fragment, with no S_SEPARATOR characters inside, that represents a path component that ...
bool absolute() const
Returns true if and only if the first character is S_SEPARATOR.
Shared_name & operator=(const Shared_name &src)
Copy-assigns from an existing Shared_name.
bool sanitize()
Best-effort attempt to turn sanitized() from false to true, unless it is already true; returns the fi...
static constexpr char S_SEPARATOR
Character we use, by convention, to separate conceptual folders within str().
const std::string & str() const
Returns (sans copying) ref to immutable entire wrapped name string, suitable to pass into sys calls w...
static const Shared_name S_ROOT_MAGIC
A Shared_name fragment, with no S_SEPARATOR characters inside, to be used in any Shared_name maintain...
size_t size() const
Returns str().size().
Flow-IPC module containing miscellaneous general-use facilities that are ubiquitously used by ~all Fl...
unsigned int remove_each_persistent_if(flow::log::Logger *logger_ptr, const Filter_func &filter_func)
Utility that invokes Persistent_object::for_each_persistent() and synchronously invokes Persistent_ob...
Shared_name operator/(const Shared_name &src1, const Shared_name &src2)
Returns new object equal to Shared_name(src1) /= src2.
Shared_name operator+(const Shared_name &src1, const Shared_name &src2)
Returns new object equal to Shared_name(src1) += src2.
unsigned int remove_each_persistent_with_name_prefix(flow::log::Logger *logger_ptr, const Shared_name &name_prefix_or_empty)
Utility that invokes remove_each_persistent_if() with the filter that returns true (yes,...
flow::util::String_view String_view
Short-hand for Flow's String_view.
flow::Error_code Error_code
Short-hand for flow::Error_code which is very common.