]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/program_options/include/boost/program_options/environment_iterator.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / program_options / include / boost / program_options / environment_iterator.hpp
CommitLineData
7c673cae
FG
1// Copyright Vladimir Prus 2004.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt
4// or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6#ifndef BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14
7#define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14
8
9#include "eof_iterator.hpp"
10
11#include <utility>
12#include <string>
13#include <cassert>
14
15namespace boost {
16
17 class environment_iterator
18 : public eof_iterator<environment_iterator,
19 std::pair<std::string, std::string> >
20 {
21 public:
22 environment_iterator(char** environment)
23 : m_environment(environment)
24 {
25 get();
26 }
27
28 environment_iterator()
29 {
30 found_eof();
31 }
32
33 void get()
34 {
35 if (*m_environment == 0)
36 found_eof();
37 else {
38 std::string s(*m_environment);
39 std::string::size_type n = s.find('=');
40 assert(n != s.npos);
41 value().first = s.substr(0, n);
42 value().second = s.substr(n+1);
43
44 ++m_environment;
45 }
46 }
47
48 private:
49 char** m_environment;
50 };
51}
52#endif