Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template basic_environment

boost::process::basic_environment — Type definition to hold a seperate environment.

Synopsis

// In header: <boost/process/environment.hpp>

template<typename Char> 
class basic_environment {
public:
  // types
  typedef std::basic_string< Char >                               string_type;   
  typedef boost::transform_iterator< entry_maker, Char ** >       iterator;      
  typedef boost::transform_iterator< const_entry_maker, Char ** > const_iterator;
  typedef std::size_t                                             size_type;     
  typedef unspecified                                             native_handle; 
  typedef unspecified                                             base_type;     

  // member classes/structs/unions
  template<typename Char, typename Environment> 
  struct const_entry_type {
    // types
    typedef Char                             value_type;   
    typedef const value_type *               pointer;      
    typedef std::basic_string< value_type >  string_type;  
    typedef boost::iterator_range< pointer > range;        
    typedef Environment                      environment_t;

    // construct/copy/destruct
    const_entry & operator=(const const_entry &) = default;

    // public member functions
    std::vector< string_type > to_vector() const;
     const_entry(const const_entry &) = default;
    bool empty() const;
  };
  template<typename Char, typename Environment> 
  struct entry_type {
    // types
    typedef Char                             value_type;   
    typedef const value_type *               pointer;      
    typedef std::basic_string< value_type >  string_type;  
    typedef boost::iterator_range< pointer > range;        
    typedef Environment                      environment_t;

    // construct/copy/destruct
    entry & operator=(const entry &) = default;
    entry & operator=(const string_type &);
    entry & operator=(const std::vector< string_type > &);

    // public member functions
    std::vector< string_type > to_vector() const;
     entry(const entry &) = default;
    bool empty() const;
    void assign(const string_type &);
    void assign(const std::vector< string_type > &);
    void append(const string_type &);
    void clear();
    entry & operator+=(const string_type &);
  };

  // construct/copy/destruct
  basic_environment();
  basic_environment(const basic_environment &);
  basic_environment(basic_environment &&);
  basic_environment & operator=(const basic_environment &);
  basic_environment & operator=(basic_environment &&);

  // public member functions
  iterator begin();
  const_iterator begin() const;
  const_iterator cbegin() const;
  iterator end();
  const_iterator end() const;
  const_iterator cend() const;
  iterator find(const string_type &);
  const_iterator find(const string_type &) const;
  std::size_t count(const string_type &) const;
  void erase(const string_type &);
  std::pair< iterator, bool > 
  emplace(const string_type &, const string_type &);
  bool empty();
  std::size_t size() const;
  void clear();
  entry_type at(const string_type &);
  const_entry_type at(const string_type &) const;
  entry_type operator[](const string_type &);
};

Description

Template representation of environments. It takes a character type (char or wchar_t) as template parameter to implement the environment

basic_environment public construct/copy/destruct

  1. basic_environment();
    Default constructor.
  2. basic_environment(const basic_environment &);
    Copy constructor.
  3. basic_environment(basic_environment &&);
    Move constructor.
  4. basic_environment & operator=(const basic_environment &);
    Copy assignment.
  5. basic_environment & operator=(basic_environment &&);
    Move assignment.

basic_environment public member functions

  1. iterator begin();
    Returns an iterator to the beginning.
  2. const_iterator begin() const;
    Returns an iterator to the beginning.
  3. const_iterator cbegin() const;
    Returns an iterator to the beginning.
  4. iterator end();
    Returns an iterator to the end.
  5. const_iterator end() const;
    Returns an iterator to the end.
  6. const_iterator cend() const;
    Returns an iterator to the end.
  7. iterator find(const string_type & key);
    Find a variable by its name.
  8. const_iterator find(const string_type & key) const;
    Find a variable by its name.
  9. std::size_t count(const string_type & st) const;
    Number of variables.
  10. void erase(const string_type & id);

    Erase variable by id.

  11. std::pair< iterator, bool > 
    emplace(const string_type & id, const string_type & value);
    Emplace an environment variable.
  12. bool empty();
    Check if environment has entries.
  13. std::size_t size() const;
    Get the number of variables.
  14. void clear();
    Clear the environment.
    [Note] Note

    Use with care, passed environment cannot be empty.

  15. entry_type at(const string_type & key);
    Get the entry with the key. Throws if it does not exist.
  16. const_entry_type at(const string_type & key) const;
    Get the entry with the key. Throws if it does not exist.
  17. entry_type operator[](const string_type & key);
    Get the entry with the given key. It creates the entry if it doesn't exist.

PrevUpHomeNext