LLFIO  v2.00
llfio_v2_xxx::path_view_component Class Reference

An iterated part of a path_view. More...

#include "path_view.hpp"

Inheritance diagram for llfio_v2_xxx::path_view_component:
llfio_v2_xxx::path_view

Classes

class  rendered_path
 

Public Types

enum  format : uint8_t {
  unknown , native_format , generic_format , auto_format ,
  binary_format
}
 How to interpret separators. More...
 
enum  zero_termination { zero_terminated , not_zero_terminated }
 The zero termination to use. More...
 
using size_type = filesystem::path::string_type::size_type
 The size type.
 
using byte = llfio_v2_xxx::byte
 Character type for passthrough input.
 
using char16_t = detail::char16_t
 
template<class T >
using default_rendered_path_deleter = std::default_delete< T >
 The default deleter to use.
 
template<class T = typename filesystem::path::value_type, class AllocatorOrDeleter = default_rendered_path_deleter<T[]>, size_t _internal_buffer_size = default_internal_buffer_size>
using zero_terminated_rendered_path = rendered_path< zero_termination::zero_terminated, T, AllocatorOrDeleter, _internal_buffer_size >
 Convenience type alias.
 
template<class T = typename filesystem::path::value_type, class AllocatorOrDeleter = default_rendered_path_deleter<T[]>, size_t _internal_buffer_size = default_internal_buffer_size>
using not_zero_terminated_rendered_path = rendered_path< zero_termination::not_zero_terminated, T, AllocatorOrDeleter, _internal_buffer_size >
 Convenience type alias.
 

Public Member Functions

constexpr path_view_component () noexcept
 Constructs an empty path view component (DEVIATES from P1030, is not trivial due to C++ 14 compatibility)
 
constexpr path_view_component (path_view_component p, format fmt) noexcept
 Constructs a path view component identical to the input, except with different format interpretation.
 
 path_view_component (const filesystem::path &v, format fmt=auto_format) noexcept
 
template<class Char , typename std::enable_if<(is_source_chartype_acceptable< Char >), bool >::type = true>
constexpr path_view_component (const std::basic_string< Char > &v, format fmt=binary_format) noexcept
 
constexpr path_view_component (const char *b, size_t l, enum zero_termination zt, format fmt=binary_format) noexcept
 
constexpr path_view_component (const wchar_t *b, size_t l, enum zero_termination zt, format fmt=binary_format) noexcept
 
constexpr path_view_component (const char8_t *b, size_t l, enum zero_termination zt, format fmt=binary_format) noexcept
 
constexpr path_view_component (const char16_t *b, size_t l, enum zero_termination zt, format fmt=binary_format) noexcept
 
constexpr path_view_component (const byte *b, size_t l, enum zero_termination zt) noexcept
 
template<class Char , typename std::enable_if<(is_source_chartype_acceptable< Char >), bool >::type = true>
constexpr path_view_component (const Char *s, format fmt=binary_format) noexcept
 
constexpr path_view_component (const byte *s) noexcept
 
template<class Char , typename std::enable_if<(is_source_chartype_acceptable< Char >), bool >::type = true>
constexpr path_view_component (basic_string_view< Char > v, enum zero_termination zt, format fmt=binary_format) noexcept
 
constexpr path_view_component (span< const byte > v, enum zero_termination zt) noexcept
 
template<class It , class End , typename std::enable_if<(is_source_chartype_acceptable< typename It::value_type >), bool >::type = true, typename std::enable_if<(is_source_chartype_acceptable< typename End::value_type >), bool >::type = true>
constexpr path_view_component (It b, End e, enum zero_termination zt, format fmt=binary_format) noexcept
 
template<class It , class End , typename std::enable_if<(is_source_chartype_acceptable< std::decay_t< It >>), bool >::type = true, typename std::enable_if<(is_source_chartype_acceptable< std::decay_t< End >>), bool >::type = true>
constexpr path_view_component (It *b, End *e, enum zero_termination zt, format fmt=binary_format) noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<class It , class End , typename std::enable_if<(std::is_same< typename It::value_type, byte >::value), bool >::type = true, typename std::enable_if<(std::is_same< typename End::value_type, byte >::value), bool >::type = true>
constexpr path_view_component (It b, End e, enum zero_termination zt) noexcept
 
template<class It , class End , typename std::enable_if<(std::is_same< std::decay_t< It >, byte >::value), bool >::type = true, typename std::enable_if<(std::is_same< std::decay_t< End >, byte >::value), bool >::type = true>
constexpr path_view_component (It *b, End *e, enum zero_termination zt) noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
 path_view_component (const path_view_component &)=default
 
 path_view_component (path_view_component &&)=default
 
path_view_componentoperator= (const path_view_component &)=default
 
path_view_componentoperator= (path_view_component &&)=default
 
const byte_raw_data () const noexcept
 
constexpr void swap (path_view_component &o) noexcept
 Swap the view with another.
 
constexpr QUICKCPPLIB_NODISCARD bool empty () const noexcept
 True if empty.
 
constexpr size_t native_size () const noexcept
 Returns the size of the view in characters.
 
constexpr format formatting () const noexcept
 How path separators shall be interpreted.
 
constexpr bool has_zero_termination () const noexcept
 True if input is declared to be zero terminated.
 
constexpr enum zero_termination zero_termination () const noexcept
 The zero termination during construction.
 
constexpr bool has_stem () const noexcept
 True if stem() returns a non-empty path.
 
constexpr bool has_extension () const noexcept
 True if extension() returns a non-empty path.
 
constexpr bool contains_glob () const noexcept
 True if the view contains any of the characters *, ?, (POSIX only: [ or ]).
 
constexpr path_view_component stem () const noexcept
 Returns a view of the filename without any file extension.
 
constexpr path_view_component extension () const noexcept
 Returns a view of the file extension part of this view.
 
filesystem::path path () const
 Return the path view as a path. Allocates and copies memory!
 
template<class T = typename filesystem::path::value_type, class Deleter = default_rendered_path_deleter<T[]>, size_t _internal_buffer_size = default_internal_buffer_size, typename std::enable_if<(is_source_acceptable< T >), bool >::type = true>
constexpr int compare (path_view_component p, const std::locale &loc) const
 
template<class T = typename filesystem::path::value_type, class Deleter = default_rendered_path_deleter<T[]>, size_t _internal_buffer_size = default_internal_buffer_size, typename std::enable_if<(is_source_acceptable< T >), bool >::type = true>
constexpr int compare (path_view_component p) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<enum path_view_component::zero_termination ZeroTermination, class T = typename filesystem::path::value_type, class AllocatorOrDeleter = default_rendered_path_deleter<T[]>, size_t _internal_buffer_size = default_internal_buffer_size, class... Args, typename std::enable_if<(is_source_acceptable< T >), bool >::type = true, typename = decltype( std::is_constructible<rendered_path<ZeroTermination, T, AllocatorOrDeleter, _internal_buffer_size>, path_view_component, Args...>::value )>
rendered_path< ZeroTermination, T, AllocatorOrDeleter, _internal_buffer_size > render (path_view_component view, Args &&...args) const
 Convenience function.
 
template<class T = typename filesystem::path::value_type, class AllocatorOrDeleter = default_rendered_path_deleter<T[]>, size_t _internal_buffer_size = default_internal_buffer_size, class... Args, typename std::enable_if<(is_source_acceptable< T >), bool >::type = true, typename = decltype( std::is_constructible<rendered_path<zero_termination::zero_terminated, T, AllocatorOrDeleter, _internal_buffer_size>, path_view_component, Args...>::value )>
rendered_path< zero_termination::zero_terminated, T, AllocatorOrDeleter, _internal_buffer_size > render_zero_terminated (path_view_component view, Args &&...args) const
 Convenience function.
 
template<class T = typename filesystem::path::value_type, class AllocatorOrDeleter = default_rendered_path_deleter<T[]>, size_t _internal_buffer_size = default_internal_buffer_size, class... Args, typename std::enable_if<(is_source_acceptable< T >), bool >::type = true, typename = decltype( std::is_constructible<rendered_path<zero_termination::zero_terminated, T, AllocatorOrDeleter, _internal_buffer_size>, path_view_component, Args...>::value )>
rendered_path< zero_termination::not_zero_terminated, T, AllocatorOrDeleter, _internal_buffer_size > render_not_zero_terminated (path_view_component view, Args &&...args) const
 Convenience function.
 

Static Public Attributes

static constexpr auto preferred_separator = filesystem::path::preferred_separator
 The preferred separator type.
 
template<class Char >
static constexpr bool is_source_chartype_acceptable = detail::is_source_chartype_acceptable<Char>::value
 
template<class Char >
static constexpr bool is_source_acceptable = detail::is_source_acceptable<Char>::value
 
static constexpr size_t default_internal_buffer_size = 1024
 The default internal buffer size used by rendered_path.
 

Friends

class path_view
 
template<enum path_view_component::zero_termination ZeroTermination, class T , class Deleter , size_t _internal_buffer_size, typename std::enable_if<(is_source_acceptable< T >), bool >::type >
class rendered_path
 
constexpr friend bool llfio_v2_xxx::operator== (path_view_component x, path_view_component y) noexcept
 
constexpr friend bool llfio_v2_xxx::operator!= (path_view_component x, path_view_component y) noexcept
 
constexpr friend bool llfio_v2_xxx::operator< (path_view_component x, path_view_component y) noexcept
 
constexpr friend size_t hash_value (path_view_component x) noexcept
 Hashes a path_view_component.
 
template<class F >
constexpr friend auto llfio_v2_xxx::visit (path_view_component view, F &&f)
 
template<class F >
constexpr friend auto llfio_v2_xxx::visit (F &&f, path_view_component view)
 
std::ostream & llfio_v2_xxx::operator<< (std::ostream &s, const path_view_component &v)
 

Detailed Description

An iterated part of a path_view.

Member Enumeration Documentation

◆ format

How to interpret separators.

Enumerator
native_format 

Separate at the native path separator only.

generic_format 

Separate at the generic path separator only.

auto_format 

Separate at both the native and generic path separators.

binary_format 

Do not separate at any path separator.

283  {
284  unknown,
285  native_format, //!< Separate at the native path separator only.
286  generic_format, //!< Separate at the generic path separator only.
287  auto_format, //!< Separate at both the native and generic path separators.
288  binary_format //!< Do not separate at any path separator.
289  };
@ generic_format
Separate at the generic path separator only.
Definition: path_view.hpp:286
@ binary_format
Do not separate at any path separator.
Definition: path_view.hpp:288
@ auto_format
Separate at both the native and generic path separators.
Definition: path_view.hpp:287
@ native_format
Separate at the native path separator only.
Definition: path_view.hpp:285

◆ zero_termination

The zero termination to use.

Enumerator
zero_terminated 

The input is zero terminated, or requested output ought to be zero terminated.

not_zero_terminated 

The input is not zero terminated, or requested output ought to not be zero terminated.

293  {
294  zero_terminated, //!< The input is zero terminated, or requested output ought to be zero terminated.
295  not_zero_terminated, //!< The input is not zero terminated, or requested output ought to not be zero terminated.
296  };
@ not_zero_terminated
The input is not zero terminated, or requested output ought to not be zero terminated.
Definition: path_view.hpp:295
@ zero_terminated
The input is zero terminated, or requested output ought to be zero terminated.
Definition: path_view.hpp:294

Constructor & Destructor Documentation

◆ path_view_component() [1/13]

llfio_v2_xxx::path_view_component::path_view_component ( const filesystem::path &  v,
format  fmt = auto_format 
)
inlinenoexcept

Implicitly constructs a path view from a path. The input path MUST continue to exist for this view to be valid (DEVIATES from P1030 due to filesystem::path not exposing its path formatting).

352  : path_view_component(v.native().c_str(), v.native().size(), zero_terminated, fmt)
353  {
354  }
constexpr path_view_component() noexcept
Constructs an empty path view component (DEVIATES from P1030, is not trivial due to C++ 14 compatibil...
Definition: path_view.hpp:324

◆ path_view_component() [2/13]

template<class Char , typename std::enable_if<(is_source_chartype_acceptable< Char >), bool >::type = true>
constexpr llfio_v2_xxx::path_view_component::path_view_component ( const std::basic_string< Char > &  v,
format  fmt = binary_format 
)
inlineconstexprnoexcept

Constructs from a basic string if the character type is one of char, wchar_t, char8_t or char16_t.

361  : path_view_component(v.data(), v.size(), zero_terminated, fmt)
362  {
363  }

◆ path_view_component() [3/13]

constexpr llfio_v2_xxx::path_view_component::path_view_component ( const char *  b,
size_t  l,
enum zero_termination  zt,
format  fmt = binary_format 
)
inlineconstexprnoexcept

Constructs from a lengthed array of one of char, wchar_t, char8_t or char16_t. The input string MUST continue to exist for this view to be valid.

368  : _charstr((l == 0) ? nullptr : b)
369  , _length((l == 0) ? 0 : l)
370  , _zero_terminated((l == 0) ? false : (zt == zero_terminated))
371  , _passthrough(false)
372  , _char((l == 0) ? false : true)
373  , _wchar(false)
374  , _utf8(false)
375  , _utf16(false)
376  , _reserved1(0)
377  , _format(fmt)
378  {
379  }

◆ path_view_component() [4/13]

constexpr llfio_v2_xxx::path_view_component::path_view_component ( const wchar_t *  b,
size_t  l,
enum zero_termination  zt,
format  fmt = binary_format 
)
inlineconstexprnoexcept

Constructs from a lengthed array of one of char, wchar_t, char8_t or char16_t. The input string MUST continue to exist for this view to be valid.

384  : _wcharstr((l == 0) ? nullptr : b)
385  , _length((l == 0) ? 0 : l)
386  , _zero_terminated((l == 0) ? false : (zt == zero_terminated))
387  , _passthrough(false)
388  , _char(false)
389  , _wchar((l == 0) ? false : true)
390  , _utf8(false)
391  , _utf16(false)
392  , _reserved1(0)
393  , _format(fmt)
394  {
395  }

◆ path_view_component() [5/13]

constexpr llfio_v2_xxx::path_view_component::path_view_component ( const char8_t *  b,
size_t  l,
enum zero_termination  zt,
format  fmt = binary_format 
)
inlineconstexprnoexcept

Constructs from a lengthed array of one of char, wchar_t, char8_t or char16_t. The input string MUST continue to exist for this view to be valid.

400  : _char8str((l == 0) ? nullptr : b)
401  , _length((l == 0) ? 0 : l)
402  , _zero_terminated((l == 0) ? false : (zt == zero_terminated))
403  , _passthrough(false)
404  , _char(false)
405  , _wchar(false)
406  , _utf8((l == 0) ? false : true)
407  , _utf16(false)
408  , _reserved1(0)
409  , _format(fmt)
410  {
411  }

◆ path_view_component() [6/13]

constexpr llfio_v2_xxx::path_view_component::path_view_component ( const char16_t *  b,
size_t  l,
enum zero_termination  zt,
format  fmt = binary_format 
)
inlineconstexprnoexcept

Constructs from a lengthed array of one of char, wchar_t, char8_t or char16_t. The input string MUST continue to exist for this view to be valid.

416  : _char16str((l == 0) ? nullptr : b)
417  , _length((l == 0) ? 0 : l)
418  , _zero_terminated((l == 0) ? false : (zt == zero_terminated))
419  , _passthrough(false)
420  , _char(false)
421  , _wchar(false)
422  , _utf8(false)
423  , _utf16((l == 0) ? false : true)
424  , _reserved1(0)
425  , _format(fmt)
426  {
427  }

◆ path_view_component() [7/13]

constexpr llfio_v2_xxx::path_view_component::path_view_component ( const byte b,
size_t  l,
enum zero_termination  zt 
)
inlineconstexprnoexcept

Constructs from a lengthed array of byte. The input array MUST continue to exist for this view to be valid.

432  : _bytestr((l == 0) ? nullptr : b)
433  , _length((l == 0) ? 0 : l)
434  , _zero_terminated((l == 0) ? false : (zt == zero_terminated))
435  , _passthrough((l == 0) ? false : true)
436  , _char(false)
437  , _wchar(false)
438  , _utf8(false)
439  , _utf16(false)
440  , _reserved1(0)
441  , _format(binary_format)
442  {
443  }

◆ path_view_component() [8/13]

template<class Char , typename std::enable_if<(is_source_chartype_acceptable< Char >), bool >::type = true>
constexpr llfio_v2_xxx::path_view_component::path_view_component ( const Char *  s,
format  fmt = binary_format 
)
inlineconstexprnoexcept

Implicitly constructs a path view from a zero terminated pointer to a character array, which must be one of char, wchar_t, char8_t or char16_t. The input string MUST continue to exist for this view to be valid.

452  : path_view_component(s, detail::constexpr_strlen(s), zero_terminated, fmt)
453  {
454  }

◆ path_view_component() [9/13]

constexpr llfio_v2_xxx::path_view_component::path_view_component ( const byte s)
inlineconstexprnoexcept

Implicitly constructs a path view from a zero terminated pointer to byte array. The input array MUST continue to exist for this view to be valid.

459  : path_view_component(s, detail::constexpr_strlen(s), zero_terminated)
460  {
461  }

◆ path_view_component() [10/13]

template<class Char , typename std::enable_if<(is_source_chartype_acceptable< Char >), bool >::type = true>
constexpr llfio_v2_xxx::path_view_component::path_view_component ( basic_string_view< Char >  v,
enum zero_termination  zt,
format  fmt = binary_format 
)
inlineconstexprnoexcept

Constructs from a basic string view if the character type is one of char, wchar_t, char8_t or char16_t.

469  : path_view_component(v.data(), v.size(), zt, fmt)
470  {
471  }

◆ path_view_component() [11/13]

constexpr llfio_v2_xxx::path_view_component::path_view_component ( span< const byte v,
enum zero_termination  zt 
)
inlineconstexprnoexcept

Constructs from a span<const byte>.

475  : path_view_component(v.data(), v.size(), zt)
476  {
477  }

◆ path_view_component() [12/13]

template<class It , class End , typename std::enable_if<(is_source_chartype_acceptable< typename It::value_type >), bool >::type = true, typename std::enable_if<(is_source_chartype_acceptable< typename End::value_type >), bool >::type = true>
constexpr llfio_v2_xxx::path_view_component::path_view_component ( It  b,
End  e,
enum zero_termination  zt,
format  fmt = binary_format 
)
inlineconstexprnoexcept

Constructs from an iterator sequence if the iterator is contiguous, if its value type is one of char, wchar_t, char8_t or char16_t.

(DEVIATES from P1030, cannot detect contiguous iterator in SFINAE in C++ 14)

487  : path_view_component(addressof(*b), e - b, zt, fmt)
488  {
489  }

◆ path_view_component() [13/13]

template<class It , class End , typename std::enable_if<(std::is_same< typename It::value_type, byte >::value), bool >::type = true, typename std::enable_if<(std::is_same< typename End::value_type, byte >::value), bool >::type = true>
constexpr llfio_v2_xxx::path_view_component::path_view_component ( It  b,
End  e,
enum zero_termination  zt 
)
inlineconstexprnoexcept

Constructs from an iterator sequence if the iterator is contiguous, if its value type is byte.

(DEVIATES from P1030, cannot detect contiguous iterator in SFINAE in C++ 14)

505  : path_view_component(addressof(*b), e - b, zt, binary_format)
506  {
507  }

Member Function Documentation

◆ compare()

template<class T = typename filesystem::path::value_type, class Deleter = default_rendered_path_deleter<T[]>, size_t _internal_buffer_size = default_internal_buffer_size, typename std::enable_if<(is_source_acceptable< T >), bool >::type = true>
constexpr int llfio_v2_xxx::path_view_component::compare ( path_view_component  p,
const std::locale &  loc 
) const
inlineconstexpr

Compares the two path views for equivalence or ordering using T as the destination encoding, if necessary.

If the source encodings of the two path views are compatible, a lexicographical comparison is performed. If they are incompatible, either or both views are converted to the destination encoding using rendered_path<T, Delete, _internal_buffer_size>, and then a lexicographical comparison is performed.

This can, for obvious reasons, be expensive. It can also throw exceptions, as rendered_path does.

If the destination encoding is byte, memcmp() is used, and rendered_path is never invoked as the two sources are byte compared directly.

861  {
862  return _invoke(
863  [&](const auto &self)
864  {
865  return p._invoke([&](const auto &other)
866  { return _compare<T, Deleter, _internal_buffer_size>(self, zero_termination(), other, p.zero_termination(), &loc); });
867  });
868  }
zero_termination
The zero termination to use.
Definition: path_view.hpp:293

Member Data Documentation

◆ is_source_acceptable

template<class Char >
constexpr bool llfio_v2_xxx::path_view_component::is_source_acceptable = detail::is_source_acceptable<Char>::value
staticconstexpr

True if path views can be constructed from this source. i.e. is_source_chartype_acceptable, or is byte

◆ is_source_chartype_acceptable

template<class Char >
constexpr bool llfio_v2_xxx::path_view_component::is_source_chartype_acceptable = detail::is_source_chartype_acceptable<Char>::value
staticconstexpr

True if path views can be constructed from this character type. i.e. is one of char, wchar_t, char8_t, char16_t


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