Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

PrevUpHomeNext

Struct template basic_cstring_ref

boost::process::v2::basic_cstring_ref — Small wrapper for a null-terminated string that can be directly passed to C APIS.

Synopsis

// In header: <boost/process/v2/cstring_ref.hpp>

template<typename CharT, typename Traits = std::char_traits<CharT> > 
struct basic_cstring_ref {
  // types
  typedef CharT                                            value_type;            
  typedef Traits                                           traits_type;           
  typedef basic_string_view< value_type, Traits >          string_view_type;      
  typedef CharT *                                          pointer;               
  typedef const CharT *                                    const_pointer;         
  typedef CharT &                                          reference;             
  typedef const CharT &                                    const_reference;       
  typedef const_pointer                                    const_iterator;        
  typedef const_iterator                                   iterator;              
  typedef typename std::reverse_iterator< const_iterator > const_reverse_iterator;
  typedef typename std::reverse_iterator< iterator >       reverse_iterator;      
  typedef std::size_t                                      size_type;             
  typedef std::ptrdiff_t                                   difference_type;       

  // construct/copy/destruct
  basic_cstring_ref() noexcept;
  basic_cstring_ref(std::nullptr_t) = delete;
  basic_cstring_ref(const value_type *);
  template<typename Source, 
           typename  = typename std::enable_if<                    std::is_same<const value_type,                            typename std::remove_pointer<decltype(std::declval<Source>().c_str())>::type                    >::value>::type> 
    basic_cstring_ref(Source &&);

  // public member functions
  constexpr basic_string_view< value_type, Traits >::const_pointer 
  c_str() const noexcept;
  constexpr operator string_view_type() const;
  constexpr const_iterator begin() const noexcept;
  constexpr const_iterator end() const noexcept;
  constexpr const_iterator cbegin() const noexcept;
  constexpr const_iterator cend() const noexcept;
  constexpr const_reverse_iterator rbegin() const noexcept;
  constexpr const_reverse_iterator rend() const noexcept;
  constexpr const_reverse_iterator crbegin() const noexcept;
  constexpr const_reverse_iterator crend() const noexcept;
  constexpr size_type size() const noexcept;
  constexpr size_type length() const noexcept;
  constexpr size_type max_size() const noexcept;
  constexpr bool empty() const noexcept;
  constexpr const_reference operator[](size_type) const;
  constexpr const_reference at(size_type) const;
  constexpr const_reference front() const;
  constexpr const_reference back() const;
  constexpr const_pointer data() const noexcept;
  constexpr void remove_prefix(size_type);
  void swap(basic_cstring_ref &) noexcept;
  size_type copy(value_type *, size_type, size_type = 0) const;
  constexpr basic_cstring_ref substr(size_type = 0) const;
  constexpr string_view_type substr(size_type, size_type) const;
  constexpr int compare(basic_cstring_ref) const noexcept;
  constexpr bool starts_with(string_view_type) const noexcept;
  constexpr bool starts_with(value_type) const noexcept;
  constexpr size_type find(CharT, size_type = 0) const noexcept;
  void clear() noexcept;
  std::basic_string< value_type, traits_type > to_string() const;
  template<typename Allocator> 
    std::basic_string< value_type, traits_type, Allocator > 
    to_string(const Allocator &) const;

  // private static functions
  static constexpr const_pointer null_char_();

  // public data members
  static constexpr size_type npos;
};

Description

This ref can only be modified by moving the front pointer. It does not store the size, but can detect values that can directly be passed to system APIs.

It can be constructed from a char* pointer or any class that has a c_str() member function, e.g. std::string or boost::static_string.

basic_cstring_ref public construct/copy/destruct

  1. basic_cstring_ref() noexcept;
  2. basic_cstring_ref(std::nullptr_t) = delete;
  3. basic_cstring_ref(const value_type * s);
  4. template<typename Source, 
             typename  = typename std::enable_if<                    std::is_same<const value_type,                            typename std::remove_pointer<decltype(std::declval<Source>().c_str())>::type                    >::value>::type> 
      basic_cstring_ref(Source && src);

basic_cstring_ref public member functions

  1. constexpr basic_string_view< value_type, Traits >::const_pointer 
    c_str() const noexcept;
  2. constexpr operator string_view_type() const;
  3. constexpr const_iterator begin() const noexcept;
  4. constexpr const_iterator end() const noexcept;
  5. constexpr const_iterator cbegin() const noexcept;
  6. constexpr const_iterator cend() const noexcept;
  7. constexpr const_reverse_iterator rbegin() const noexcept;
  8. constexpr const_reverse_iterator rend() const noexcept;
  9. constexpr const_reverse_iterator crbegin() const noexcept;
  10. constexpr const_reverse_iterator crend() const noexcept;
  11. constexpr size_type size() const noexcept;
  12. constexpr size_type length() const noexcept;
  13. constexpr size_type max_size() const noexcept;
  14. constexpr bool empty() const noexcept;
  15. constexpr const_reference operator[](size_type pos) const;
  16. constexpr const_reference at(size_type pos) const;
  17. constexpr const_reference front() const;
  18. constexpr const_reference back() const;
  19. constexpr const_pointer data() const noexcept;
  20. constexpr void remove_prefix(size_type n);
  21. void swap(basic_cstring_ref & s) noexcept;
  22. size_type copy(value_type * s, size_type n, size_type pos = 0) const;
  23. constexpr basic_cstring_ref substr(size_type pos = 0) const;
  24. constexpr string_view_type substr(size_type pos, size_type length) const;
  25. constexpr int compare(basic_cstring_ref x) const noexcept;
  26. constexpr bool starts_with(string_view_type x) const noexcept;
  27. constexpr bool starts_with(value_type x) const noexcept;
  28. constexpr size_type find(CharT ch, size_type pos = 0) const noexcept;
  29. void clear() noexcept;
  30. std::basic_string< value_type, traits_type > to_string() const;
  31. template<typename Allocator> 
      std::basic_string< value_type, traits_type, Allocator > 
      to_string(const Allocator & a) const;

basic_cstring_ref private static functions

  1. static constexpr const_pointer null_char_();

PrevUpHomeNext