os/ossrv/ossrv_pub/boost_apis/boost/test/utils/iterator/ifstream_line_iterator.hpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
//  (C) Copyright Gennadiy Rozental 2004-2005.
sl@0
     2
//  Distributed under the Boost Software License, Version 1.0.
sl@0
     3
//  (See accompanying file LICENSE_1_0.txt or copy at 
sl@0
     4
//  http://www.boost.org/LICENSE_1_0.txt)
sl@0
     5
sl@0
     6
//  See http://www.boost.org/libs/test for the library home page.
sl@0
     7
//
sl@0
     8
//  File        : $RCSfile: ifstream_line_iterator.hpp,v $
sl@0
     9
//
sl@0
    10
//  Version     : $Revision: 1.7 $
sl@0
    11
//
sl@0
    12
//  Description : 
sl@0
    13
// ***************************************************************************
sl@0
    14
sl@0
    15
#ifndef BOOST_IFSTREAM_LINE_ITERATOR_HPP_071894GER
sl@0
    16
#define BOOST_IFSTREAM_LINE_ITERATOR_HPP_071894GER
sl@0
    17
sl@0
    18
// Boost
sl@0
    19
#include <boost/test/utils/iterator/istream_line_iterator.hpp>
sl@0
    20
sl@0
    21
// STL
sl@0
    22
#include <fstream>
sl@0
    23
sl@0
    24
#include <boost/test/detail/suppress_warnings.hpp>
sl@0
    25
sl@0
    26
//____________________________________________________________________________//
sl@0
    27
sl@0
    28
namespace boost {
sl@0
    29
sl@0
    30
namespace unit_test {
sl@0
    31
sl@0
    32
namespace ut_detail {
sl@0
    33
sl@0
    34
// ************************************************************************** //
sl@0
    35
// **************                ifstream_holder               ************** //
sl@0
    36
// ************************************************************************** //
sl@0
    37
sl@0
    38
template<typename CharT>
sl@0
    39
class ifstream_holder {
sl@0
    40
public:
sl@0
    41
    // Constructor
sl@0
    42
    explicit    ifstream_holder( basic_cstring<CharT const> file_name )
sl@0
    43
    {
sl@0
    44
        if( file_name.is_empty() )
sl@0
    45
            return;
sl@0
    46
sl@0
    47
        m_stream.open( file_name.begin(), std::ios::in );
sl@0
    48
    }
sl@0
    49
sl@0
    50
    bool is_valid()
sl@0
    51
    {
sl@0
    52
        return m_stream.is_open();
sl@0
    53
    }
sl@0
    54
sl@0
    55
protected:
sl@0
    56
#ifdef BOOST_CLASSIC_IOSTREAMS
sl@0
    57
    typedef std::ifstream                                       stream_t;
sl@0
    58
#else
sl@0
    59
    typedef std::basic_ifstream<CharT,std::char_traits<CharT> > stream_t;
sl@0
    60
#endif
sl@0
    61
sl@0
    62
    // Data members
sl@0
    63
    stream_t    m_stream;
sl@0
    64
};
sl@0
    65
sl@0
    66
} // namespace ut_detail
sl@0
    67
sl@0
    68
// ************************************************************************** //
sl@0
    69
// **************         basic_ifstream_line_iterator         ************** //
sl@0
    70
// ************************************************************************** //
sl@0
    71
sl@0
    72
#ifdef BOOST_MSVC
sl@0
    73
# pragma warning(push)
sl@0
    74
# pragma warning(disable: 4355) // 'this' : used in base member initializer list
sl@0
    75
#endif
sl@0
    76
sl@0
    77
template<typename CharT>
sl@0
    78
class basic_ifstream_line_iterator : ut_detail::ifstream_holder<CharT>, public basic_istream_line_iterator<CharT>
sl@0
    79
{
sl@0
    80
public:
sl@0
    81
    basic_ifstream_line_iterator( basic_cstring<CharT const> file_name, CharT delimeter )
sl@0
    82
    : ut_detail::ifstream_holder<CharT>( file_name ), basic_istream_line_iterator<CharT>( this->m_stream, delimeter ) {}
sl@0
    83
sl@0
    84
    explicit basic_ifstream_line_iterator( basic_cstring<CharT const> file_name = basic_cstring<CharT const>() )
sl@0
    85
    : ut_detail::ifstream_holder<CharT>( file_name ), basic_istream_line_iterator<CharT>( this->m_stream ) {}
sl@0
    86
};
sl@0
    87
sl@0
    88
#ifdef BOOST_MSVC
sl@0
    89
# pragma warning(default: 4355)
sl@0
    90
#endif
sl@0
    91
sl@0
    92
typedef basic_ifstream_line_iterator<char>      ifstream_line_iterator;
sl@0
    93
typedef basic_ifstream_line_iterator<wchar_t>   wifstream_line_iterator;
sl@0
    94
sl@0
    95
} // namespace unit_test
sl@0
    96
sl@0
    97
} // namespace boost
sl@0
    98
sl@0
    99
//____________________________________________________________________________//
sl@0
   100
sl@0
   101
#include <boost/test/detail/enable_warnings.hpp>
sl@0
   102
sl@0
   103
// ***************************************************************************
sl@0
   104
//  Revision History :
sl@0
   105
//  
sl@0
   106
//  $Log: ifstream_line_iterator.hpp,v $
sl@0
   107
//  Revision 1.7  2005/06/11 07:21:23  rogeeff
sl@0
   108
//  reverse prev fix
sl@0
   109
//
sl@0
   110
//  Revision 1.6  2005/06/07 05:08:03  rogeeff
sl@0
   111
//  gcc fix
sl@0
   112
//
sl@0
   113
//  Revision 1.5  2005/02/20 08:27:09  rogeeff
sl@0
   114
//  This a major update for Boost.Test framework. See release docs for complete list of fixes/updates
sl@0
   115
//
sl@0
   116
//  Revision 1.4  2005/02/01 06:40:08  rogeeff
sl@0
   117
//  copyright update
sl@0
   118
//  old log entries removed
sl@0
   119
//  minor stilistic changes
sl@0
   120
//  depricated tools removed
sl@0
   121
//
sl@0
   122
//  Revision 1.3  2005/01/30 01:44:14  rogeeff
sl@0
   123
//  warnings suppressed
sl@0
   124
//
sl@0
   125
//  Revision 1.2  2005/01/22 19:22:13  rogeeff
sl@0
   126
//  implementation moved into headers section to eliminate dependency of included/minimal component on src directory
sl@0
   127
//
sl@0
   128
//  Revision 1.1  2005/01/22 18:21:40  rogeeff
sl@0
   129
//  moved sharable staff into utils
sl@0
   130
//
sl@0
   131
// ***************************************************************************
sl@0
   132
sl@0
   133
#endif // BOOST_IFSTREAM_LINE_ITERATOR_HPP_071894GER
sl@0
   134