20#include <boost/functional/hash/hash.hpp>
59 result.
m_raw_name.assign(std::move(src_moved));
126 using flow::util::in_closed_range;
141 bool prev_is_sep =
false;
175 constexpr char SEPARATOR_ALT =
'/';
177 "The real separator and the alt must be different characters.");
178 constexpr const char SEPS[] = { SEPARATOR_ALT,
S_SEPARATOR,
'\0' };
189 const auto n =
size();
192 string sanitized_str;
193 sanitized_str.reserve(
size());
195 for (
auto ptr = start_ptr; ptr != end_ptr; ++ptr)
208 const bool is_sep = (ch ==
S_SEPARATOR) || (ch == SEPARATOR_ALT);
225 auto pos =
size_t(ptr - start_ptr);
228 pos =
m_raw_name.find_first_not_of(SEPS, pos + 1);
229 if (pos == string::npos)
235 ptr = start_ptr + pos;
251 return ((ch >=
'A') && (ch <=
'Z')) || ((ch >=
'a') && (ch <=
'z'))
252 || ((ch >=
'0') && (ch <=
'9'));
257 assert(!resource_type.
empty());
264 name /= resource_type;
274 if (val.
str().empty())
279 return os << val.
str().size() <<
'|' << val.
str();
297 return val1.
str() == val2.
str();
331 return val1.
str() < val2.
str();
339 return hash<string>()(val.
str());
String-wrapping abstraction representing a name uniquely distinguishing a kernel-persistent entity fr...
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+=(const Shared_name &src_to_append)
Appends the given other 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.
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().
util::Shared_name Shared_name
Convenience alias for the commonly used type util::Shared_name.
Flow-IPC module containing miscellaneous general-use facilities that are ubiquitously used by ~all Fl...
Shared_name operator/(const Shared_name &src1, const Shared_name &src2)
Returns new object equal to Shared_name(src1) /= src2.
std::ostream & operator<<(std::ostream &os, const Native_handle &val)
Prints string representation of the given Native_handle to the given ostream.
Shared_name operator+(const Shared_name &src1, const Shared_name &src2)
Returns new object equal to Shared_name(src1) += src2.
constexpr bool operator<(Native_handle val1, Native_handle val2) noexcept
Returns a less-than comparison of two Native_handle objects, with the usual total ordering guarantees...
Shared_name build_conventional_non_session_based_shared_name(const Shared_name &resource_type)
Builds an absolute name according to the path convention explained in Shared_name class doc header; t...
size_t hash_value(Native_handle val) noexcept
Hasher of Native_handle for boost.unordered et al.
void swap(Shared_name &val1, Shared_name &val2)
Swaps two objects.
constexpr void swap(Native_handle &val1, Native_handle &val2) noexcept
Standard swap.
bool operator==(util::String_view val1, const Shared_name &val2)
Returns true if and only if string(val1) == val2.str().
constexpr bool operator!=(Native_handle val1, Native_handle val2) noexcept
Negation of similar ==.
std::istream & operator>>(std::istream &is, Shared_name &val)
Reads Shared_name from the given istream; equivalent to reading string into Shared_name::str().
flow::util::String_view String_view
Short-hand for Flow's String_view.
constexpr bool operator==(Native_handle val1, Native_handle val2) noexcept
Returns true if and only if the two Native_handle objects are the same underlying handle.