Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:15

0001 // Copyright Vladimir Prus 2004.
0002 // Distributed under the Boost Software License, Version 1.0.
0003 // (See accompanying file LICENSE_1_0.txt
0004 // or copy at http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 #ifndef BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14
0007 #define BOOST_ENVIRONMENT_ITERATOR_VP_2004_05_14
0008 
0009 #include "eof_iterator.hpp"
0010 
0011 #include <utility>
0012 #include <string>
0013 #include <cassert>
0014 
0015 namespace boost {
0016 
0017     class environment_iterator 
0018         : public eof_iterator<environment_iterator, 
0019                               std::pair<std::string, std::string> >
0020     {
0021     public:
0022         environment_iterator(char** environment)
0023         : m_environment(environment)
0024         {
0025             get();
0026         }
0027         
0028         environment_iterator()
0029         {
0030             found_eof();
0031         }
0032         
0033         void get()
0034         {
0035             if (*m_environment == 0)
0036                 found_eof();
0037             else {
0038                 std::string s(*m_environment);
0039                 std::string::size_type n = s.find('=');
0040                 assert(n != s.npos);
0041                 value().first = s.substr(0, n);
0042                 value().second = s.substr(n+1);
0043                 
0044                 ++m_environment;
0045             }
0046         }
0047         
0048     private:
0049         char** m_environment;
0050     };
0051 }
0052 #endif