Imported existing code

This commit is contained in:
Hazim Gazov
2010-04-02 02:48:44 -03:00
parent 48fbc5ae91
commit 7a86d01598
13996 changed files with 2468699 additions and 0 deletions

View File

@@ -0,0 +1,229 @@
/*=============================================================================
Copyright (c) 2003 Giovanni Bajo
Copyright (c) 2003 Thomas Witt
Copyright (c) 2003 Hartmut Kaiser
http://spirit.sourceforge.net/
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
///////////////////////////////////////////////////////////////////////////////
//
// File Iterator structure
//
// The new structure is designed on layers. The top class (used by the user)
// is file_iterator, which implements a full random access iterator through
// the file, and some specific member functions (constructor that opens
// the file, make_end() to generate the end iterator, operator bool to check
// if the file was opened correctly).
//
// file_iterator implements the random access iterator interface by the means
// of boost::iterator_adaptor, that is inhering an object created with it.
// iterator_adaptor gets a low-level file iterator implementation (with just
// a few member functions) and a policy (that basically describes to it how
// the low-level file iterator interface is). The advantage is that
// with boost::iterator_adaptor only 5 functions are needed to implement
// a fully conformant random access iterator, instead of dozens of functions
// and operators.
//
// There are two low-level file iterators implemented in this module. The
// first (std_file_iterator) uses cstdio stream functions (fopen/fread), which
// support full buffering, and is available everywhere (it's standard C++).
// The second (mmap_file_iterator) is currently available only on Windows
// platforms, and uses memory mapped files, which gives a decent speed boost.
//
///////////////////////////////////////////////////////////////////////////////
//
// TODO LIST:
//
// - In the Win32 mmap iterator, we could check if keeping a handle to the
// opened file is really required. If it's not, we can just store the file
// length (for make_end()) and save performance. Notice that this should be
// tested under different Windows versions, the behaviour might change.
// - Add some error support (by the means of some exceptions) in case of
// low-level I/O failure.
//
///////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_SPIRIT_FILE_ITERATOR_HPP
#define BOOST_SPIRIT_FILE_ITERATOR_HPP
#include <string>
#include <boost/config.hpp>
#include <boost/iterator_adaptors.hpp>
#include <boost/spirit/home/classic/namespace.hpp>
#include <boost/spirit/home/classic/core/safe_bool.hpp>
#include <boost/spirit/home/classic/iterator/file_iterator_fwd.hpp>
#if !defined(BOOST_SPIRIT_FILEITERATOR_STD)
# if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \
&& !defined(BOOST_DISABLE_WIN32)
# define BOOST_SPIRIT_FILEITERATOR_WINDOWS
# elif defined(BOOST_HAS_UNISTD_H)
extern "C"
{
# include <unistd.h>
}
# ifdef _POSIX_MAPPED_FILES
# define BOOST_SPIRIT_FILEITERATOR_POSIX
# endif // _POSIX_MAPPED_FILES
# endif // BOOST_HAS_UNISTD_H
# if !defined(BOOST_SPIRIT_FILEITERATOR_WINDOWS) && \
!defined(BOOST_SPIRIT_FILEITERATOR_POSIX)
# define BOOST_SPIRIT_FILEITERATOR_STD
# endif
#endif // BOOST_SPIRIT_FILEITERATOR_STD
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit {
BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
template <
typename CharT = char,
typename BaseIterator =
#ifdef BOOST_SPIRIT_FILEITERATOR_STD
fileiter_impl::std_file_iterator<CharT>
#else
fileiter_impl::mmap_file_iterator<CharT>
#endif
> class file_iterator;
///////////////////////////////////////////////////////////////////////////////
namespace fileiter_impl {
/////////////////////////////////////////////////////////////////////////
//
// file_iter_generator
//
// Template meta-function to invoke boost::iterator_adaptor
// NOTE: This cannot be moved into the implementation file because of
// a bug of MSVC 7.0 and previous versions (base classes types are
// looked up at compilation time, not instantion types, and
// file_iterator would break).
//
/////////////////////////////////////////////////////////////////////////
#if !defined(BOOST_ITERATOR_ADAPTORS_VERSION) || \
BOOST_ITERATOR_ADAPTORS_VERSION < 0x0200
#error "Please use at least Boost V1.31.0 while compiling the file_iterator class!"
#else // BOOST_ITERATOR_ADAPTORS_VERSION < 0x0200
template <typename CharT, typename BaseIteratorT>
struct file_iter_generator
{
public:
typedef BaseIteratorT adapted_t;
typedef typename adapted_t::value_type value_type;
typedef boost::iterator_adaptor <
file_iterator<CharT, BaseIteratorT>,
adapted_t,
value_type const,
std::random_access_iterator_tag,
boost::use_default,
std::ptrdiff_t
> type;
};
#endif // BOOST_ITERATOR_ADAPTORS_VERSION < 0x0200
///////////////////////////////////////////////////////////////////////////////
} /* namespace impl */
///////////////////////////////////////////////////////////////////////////////
//
// file_iterator
//
// Iterates through an opened file.
//
// The main iterator interface is implemented by the iterator_adaptors
// library, which wraps a conforming iterator interface around the
// impl::BaseIterator class. This class merely derives the iterator_adaptors
// generated class to implement the custom constructors and make_end()
// member function.
//
///////////////////////////////////////////////////////////////////////////////
template<typename CharT, typename BaseIteratorT>
class file_iterator
: public fileiter_impl::file_iter_generator<CharT, BaseIteratorT>::type,
public safe_bool<file_iterator<CharT, BaseIteratorT> >
{
private:
typedef typename
fileiter_impl::file_iter_generator<CharT, BaseIteratorT>::type
base_t;
typedef typename
fileiter_impl::file_iter_generator<CharT, BaseIteratorT>::adapted_t
adapted_t;
public:
file_iterator()
{}
file_iterator(std::string fileName)
: base_t(adapted_t(fileName))
{}
file_iterator(const base_t& iter)
: base_t(iter)
{}
inline file_iterator& operator=(const base_t& iter);
file_iterator make_end(void);
// operator bool. This borrows a trick from boost::shared_ptr to avoid
// to interfere with arithmetic operations.
bool operator_bool(void) const
{ return this->base(); }
private:
friend class ::boost::iterator_core_access;
typename base_t::reference dereference() const
{
return this->base_reference().get_cur_char();
}
void increment()
{
this->base_reference().next_char();
}
void decrement()
{
this->base_reference().prev_char();
}
void advance(typename base_t::difference_type n)
{
this->base_reference().advance(n);
}
template <
typename OtherDerivedT, typename OtherIteratorT,
typename V, typename C, typename R, typename D
>
typename base_t::difference_type distance_to(
iterator_adaptor<OtherDerivedT, OtherIteratorT, V, C, R, D>
const &x) const
{
return x.base().distance(this->base_reference());
}
};
///////////////////////////////////////////////////////////////////////////////
BOOST_SPIRIT_CLASSIC_NAMESPACE_END
}} /* namespace BOOST_SPIRIT_CLASSIC_NS */
///////////////////////////////////////////////////////////////////////////////
#include <boost/spirit/home/classic/iterator/impl/file_iterator.ipp> /* implementation */
#endif /* BOOST_SPIRIT_FILE_ITERATOR_HPP */

View File

@@ -0,0 +1,39 @@
/*=============================================================================
Copyright (c) 2006 Tobias Schwinger
http://spirit.sourceforge.net/
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(BOOST_SPIRIT_FILE_ITERATOR_FWD_HPP)
#define BOOST_SPIRIT_FILE_ITERATOR_FWD_HPP
#include <boost/spirit/home/classic/namespace.hpp>
namespace boost { namespace spirit {
BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
namespace fileiter_impl
{
template <typename CharT = char>
class std_file_iterator;
// may never be defined -- so what...
template <typename CharT = char>
class mmap_file_iterator;
}
// no defaults here -- too much dependencies
template <
typename CharT,
typename BaseIterator
> class file_iterator;
BOOST_SPIRIT_CLASSIC_NAMESPACE_END
}} // namespace BOOST_SPIRIT_CLASSIC_NS
#endif

View File

@@ -0,0 +1,402 @@
/*=============================================================================
Copyright (c) 2001, Daniel C. Nuffer
Copyright (c) 2003, Hartmut Kaiser
http://spirit.sourceforge.net/
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#ifndef FIXED_SIZE_QUEUE
#define FIXED_SIZE_QUEUE
#include <cstdlib>
#include <iterator>
#include <cstddef>
#include <boost/spirit/home/classic/namespace.hpp>
#include <boost/spirit/home/classic/core/assert.hpp> // for BOOST_SPIRIT_ASSERT
// FIXES for broken compilers
#include <boost/config.hpp>
#include <boost/iterator_adaptors.hpp>
#define BOOST_SPIRIT_ASSERT_FSQ_SIZE \
BOOST_SPIRIT_ASSERT(((m_tail + N + 1) - m_head) % (N+1) == m_size % (N+1)) \
/**/
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit {
BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
///////////////////////////////////////////////////////////////////////////////
namespace impl {
#if !defined(BOOST_ITERATOR_ADAPTORS_VERSION) || \
BOOST_ITERATOR_ADAPTORS_VERSION < 0x0200
#error "Please use at least Boost V1.31.0 while compiling the fixed_size_queue class!"
#else // BOOST_ITERATOR_ADAPTORS_VERSION < 0x0200
template <typename QueueT, typename T, typename PointerT>
class fsq_iterator
: public boost::iterator_adaptor<
fsq_iterator<QueueT, T, PointerT>,
PointerT,
T,
std::random_access_iterator_tag
>
{
public:
typedef typename QueueT::position_t position;
typedef boost::iterator_adaptor<
fsq_iterator<QueueT, T, PointerT>, PointerT, T,
std::random_access_iterator_tag
> base_t;
fsq_iterator() {}
fsq_iterator(position const &p_) : p(p_) {}
position const &get_position() const { return p; }
private:
friend class boost::iterator_core_access;
typename base_t::reference dereference() const
{
return p.self->m_queue[p.pos];
}
void increment()
{
++p.pos;
if (p.pos == QueueT::MAX_SIZE+1)
p.pos = 0;
}
void decrement()
{
if (p.pos == 0)
p.pos = QueueT::MAX_SIZE;
else
--p.pos;
}
template <
typename OtherDerivedT, typename OtherIteratorT,
typename V, typename C, typename R, typename D
>
bool equal(iterator_adaptor<OtherDerivedT, OtherIteratorT, V, C, R, D>
const &x) const
{
position const &rhs_pos =
static_cast<OtherDerivedT const &>(x).get_position();
return (p.self == rhs_pos.self) && (p.pos == rhs_pos.pos);
}
template <
typename OtherDerivedT, typename OtherIteratorT,
typename V, typename C, typename R, typename D
>
typename base_t::difference_type distance_to(
iterator_adaptor<OtherDerivedT, OtherIteratorT, V, C, R, D>
const &x) const
{
typedef typename base_t::difference_type diff_t;
position const &p2 =
static_cast<OtherDerivedT const &>(x).get_position();
std::size_t pos1 = p.pos;
std::size_t pos2 = p2.pos;
// Undefined behaviour if the iterators come from different
// containers
BOOST_SPIRIT_ASSERT(p.self == p2.self);
if (pos1 < p.self->m_head)
pos1 += QueueT::MAX_SIZE;
if (pos2 < p2.self->m_head)
pos2 += QueueT::MAX_SIZE;
if (pos2 > pos1)
return diff_t(pos2 - pos1);
else
return -diff_t(pos1 - pos2);
}
void advance(typename base_t::difference_type n)
{
// Notice that we don't care values of n that can
// wrap around more than one time, since it would
// be undefined behaviour anyway (going outside
// the begin/end range). Negative wrapping is a bit
// cumbersome because we don't want to case p.pos
// to signed.
if (n < 0)
{
n = -n;
if (p.pos < (std::size_t)n)
p.pos = QueueT::MAX_SIZE+1 - (n - p.pos);
else
p.pos -= n;
}
else
{
p.pos += n;
if (p.pos >= QueueT::MAX_SIZE+1)
p.pos -= QueueT::MAX_SIZE+1;
}
}
private:
position p;
};
#endif // BOOST_ITERATOR_ADAPTORS_VERSION < 0x0200
///////////////////////////////////////////////////////////////////////////////
} /* namespace impl */
template <typename T, std::size_t N>
class fixed_size_queue
{
private:
struct position
{
fixed_size_queue* self;
std::size_t pos;
position() : self(0), pos(0) {}
// The const_cast here is just to avoid to have two different
// position structures for the const and non-const case.
// The const semantic is guaranteed by the iterator itself
position(const fixed_size_queue* s, std::size_t p)
: self(const_cast<fixed_size_queue*>(s)), pos(p)
{}
};
public:
// Declare the iterators
typedef impl::fsq_iterator<fixed_size_queue<T, N>, T, T*> iterator;
typedef impl::fsq_iterator<fixed_size_queue<T, N>, T const, T const*>
const_iterator;
typedef position position_t;
friend class impl::fsq_iterator<fixed_size_queue<T, N>, T, T*>;
friend class impl::fsq_iterator<fixed_size_queue<T, N>, T const, T const*>;
fixed_size_queue();
fixed_size_queue(const fixed_size_queue& x);
fixed_size_queue& operator=(const fixed_size_queue& x);
~fixed_size_queue();
void push_back(const T& e);
void push_front(const T& e);
void serve(T& e);
void pop_front();
bool empty() const
{
return m_size == 0;
}
bool full() const
{
return m_size == N;
}
iterator begin()
{
return iterator(position(this, m_head));
}
const_iterator begin() const
{
return const_iterator(position(this, m_head));
}
iterator end()
{
return iterator(position(this, m_tail));
}
const_iterator end() const
{
return const_iterator(position(this, m_tail));
}
std::size_t size() const
{
return m_size;
}
T& front()
{
return m_queue[m_head];
}
const T& front() const
{
return m_queue[m_head];
}
private:
// Redefine the template parameters to avoid using partial template
// specialization on the iterator policy to extract N.
BOOST_STATIC_CONSTANT(std::size_t, MAX_SIZE = N);
std::size_t m_head;
std::size_t m_tail;
std::size_t m_size;
T m_queue[N+1];
};
template <typename T, std::size_t N>
inline
fixed_size_queue<T, N>::fixed_size_queue()
: m_head(0)
, m_tail(0)
, m_size(0)
{
BOOST_SPIRIT_ASSERT(m_size <= N+1);
BOOST_SPIRIT_ASSERT_FSQ_SIZE;
BOOST_SPIRIT_ASSERT(m_head <= N+1);
BOOST_SPIRIT_ASSERT(m_tail <= N+1);
}
template <typename T, std::size_t N>
inline
fixed_size_queue<T, N>::fixed_size_queue(const fixed_size_queue& x)
: m_head(x.m_head)
, m_tail(x.m_tail)
, m_size(x.m_size)
{
copy(x.begin(), x.end(), begin());
BOOST_SPIRIT_ASSERT(m_size <= N+1);
BOOST_SPIRIT_ASSERT_FSQ_SIZE;
BOOST_SPIRIT_ASSERT(m_head <= N+1);
BOOST_SPIRIT_ASSERT(m_tail <= N+1);
}
template <typename T, std::size_t N>
inline fixed_size_queue<T, N>&
fixed_size_queue<T, N>::operator=(const fixed_size_queue& x)
{
if (this != &x)
{
m_head = x.m_head;
m_tail = x.m_tail;
m_size = x.m_size;
copy(x.begin(), x.end(), begin());
}
BOOST_SPIRIT_ASSERT(m_size <= N+1);
BOOST_SPIRIT_ASSERT_FSQ_SIZE;
BOOST_SPIRIT_ASSERT(m_head <= N+1);
BOOST_SPIRIT_ASSERT(m_tail <= N+1);
return *this;
}
template <typename T, std::size_t N>
inline
fixed_size_queue<T, N>::~fixed_size_queue()
{
BOOST_SPIRIT_ASSERT(m_size <= N+1);
BOOST_SPIRIT_ASSERT_FSQ_SIZE;
BOOST_SPIRIT_ASSERT(m_head <= N+1);
BOOST_SPIRIT_ASSERT(m_tail <= N+1);
}
template <typename T, std::size_t N>
inline void
fixed_size_queue<T, N>::push_back(const T& e)
{
BOOST_SPIRIT_ASSERT(m_size <= N+1);
BOOST_SPIRIT_ASSERT_FSQ_SIZE;
BOOST_SPIRIT_ASSERT(m_head <= N+1);
BOOST_SPIRIT_ASSERT(m_tail <= N+1);
BOOST_SPIRIT_ASSERT(!full());
m_queue[m_tail] = e;
++m_size;
++m_tail;
if (m_tail == N+1)
m_tail = 0;
BOOST_SPIRIT_ASSERT(m_size <= N+1);
BOOST_SPIRIT_ASSERT_FSQ_SIZE;
BOOST_SPIRIT_ASSERT(m_head <= N+1);
BOOST_SPIRIT_ASSERT(m_tail <= N+1);
}
template <typename T, std::size_t N>
inline void
fixed_size_queue<T, N>::push_front(const T& e)
{
BOOST_SPIRIT_ASSERT(m_size <= N+1);
BOOST_SPIRIT_ASSERT_FSQ_SIZE;
BOOST_SPIRIT_ASSERT(m_head <= N+1);
BOOST_SPIRIT_ASSERT(m_tail <= N+1);
BOOST_SPIRIT_ASSERT(!full());
if (m_head == 0)
m_head = N;
else
--m_head;
m_queue[m_head] = e;
++m_size;
BOOST_SPIRIT_ASSERT(m_size <= N+1);
BOOST_SPIRIT_ASSERT_FSQ_SIZE;
BOOST_SPIRIT_ASSERT(m_head <= N+1);
BOOST_SPIRIT_ASSERT(m_tail <= N+1);
}
template <typename T, std::size_t N>
inline void
fixed_size_queue<T, N>::serve(T& e)
{
BOOST_SPIRIT_ASSERT(m_size <= N+1);
BOOST_SPIRIT_ASSERT_FSQ_SIZE;
BOOST_SPIRIT_ASSERT(m_head <= N+1);
BOOST_SPIRIT_ASSERT(m_tail <= N+1);
e = m_queue[m_head];
pop_front();
}
template <typename T, std::size_t N>
inline void
fixed_size_queue<T, N>::pop_front()
{
BOOST_SPIRIT_ASSERT(m_size <= N+1);
BOOST_SPIRIT_ASSERT_FSQ_SIZE;
BOOST_SPIRIT_ASSERT(m_head <= N+1);
BOOST_SPIRIT_ASSERT(m_tail <= N+1);
++m_head;
if (m_head == N+1)
m_head = 0;
--m_size;
BOOST_SPIRIT_ASSERT(m_size <= N+1);
BOOST_SPIRIT_ASSERT_FSQ_SIZE;
BOOST_SPIRIT_ASSERT(m_head <= N+1);
BOOST_SPIRIT_ASSERT(m_tail <= N+1);
}
///////////////////////////////////////////////////////////////////////////////
BOOST_SPIRIT_CLASSIC_NAMESPACE_END
}} // namespace BOOST_SPIRIT_CLASSIC_NS
#undef BOOST_SPIRIT_ASSERT_FSQ_SIZE
#endif

View File

@@ -0,0 +1,463 @@
/*=============================================================================
Copyright (c) 2003 Giovanni Bajo
Copyright (c) 2003 Martin Wille
Copyright (c) 2003 Hartmut Kaiser
http://spirit.sourceforge.net/
Use, modification and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#ifndef BOOST_SPIRIT_FILE_ITERATOR_IPP
#define BOOST_SPIRIT_FILE_ITERATOR_IPP
#ifdef BOOST_SPIRIT_FILEITERATOR_WINDOWS
# include <windows.h>
#endif
#include <cstdio>
#include <boost/shared_ptr.hpp>
#ifdef BOOST_SPIRIT_FILEITERATOR_WINDOWS
# include <boost/type_traits/remove_pointer.hpp>
#endif
#ifdef BOOST_SPIRIT_FILEITERATOR_POSIX
# include <sys/types.h> // open, stat, mmap, munmap
# include <sys/stat.h> // stat
# include <fcntl.h> // open
# include <unistd.h> // stat, mmap, munmap
# include <sys/mman.h> // mmap, mmunmap
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit {
BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
///////////////////////////////////////////////////////////////////////////////
namespace fileiter_impl {
///////////////////////////////////////////////////////////////////////////////
//
// std_file_iterator
//
// Base class that implements iteration through a file using standard C
// stream library (fopen and friends). This class and the following are
// the base components on which the iterator is built (through the
// iterator adaptor library).
//
// The opened file stream (FILE) is held with a shared_ptr<>, whose
// custom deleter invokes fcose(). This makes the syntax of the class
// very easy, especially everything related to copying.
//
///////////////////////////////////////////////////////////////////////////////
template <typename CharT>
class std_file_iterator
{
public:
typedef CharT value_type;
std_file_iterator()
{}
explicit std_file_iterator(std::string fileName)
{
using namespace std;
FILE* f = fopen(fileName.c_str(), "rb");
// If the file was opened, store it into
// the smart pointer.
if (f)
{
m_file.reset(f, fclose);
m_pos = 0;
m_eof = false;
update_char();
}
}
std_file_iterator(const std_file_iterator& iter)
{ *this = iter; }
std_file_iterator& operator=(const std_file_iterator& iter)
{
m_file = iter.m_file;
m_curChar = iter.m_curChar;
m_eof = iter.m_eof;
m_pos = iter.m_pos;
return *this;
}
// Nasty bug in Comeau up to 4.3.0.1, we need explicit boolean context
// for shared_ptr to evaluate correctly
operator bool() const
{ return m_file ? true : false; }
bool operator==(const std_file_iterator& iter) const
{
return (m_file == iter.m_file) && (m_eof == iter.m_eof) &&
(m_pos == iter.m_pos);
}
const CharT& get_cur_char(void) const
{
return m_curChar;
}
void prev_char(void)
{
m_pos -= sizeof(CharT);
update_char();
}
void next_char(void)
{
m_pos += sizeof(CharT);
update_char();
}
void seek_end(void)
{
using namespace std;
fseek(m_file.get(), 0, SEEK_END);
m_pos = ftell(m_file.get()) / sizeof(CharT);
m_eof = true;
}
void advance(std::ptrdiff_t n)
{
m_pos += n * sizeof(CharT);
update_char();
}
std::ptrdiff_t distance(const std_file_iterator& iter) const
{
return (std::ptrdiff_t)(m_pos - iter.m_pos) / sizeof(CharT);
}
private:
boost::shared_ptr<std::FILE> m_file;
std::size_t m_pos;
CharT m_curChar;
bool m_eof;
void update_char(void)
{
using namespace std;
if ((std::size_t)ftell(m_file.get()) != m_pos)
fseek(m_file.get(), m_pos, SEEK_SET);
m_eof = (fread(&m_curChar, sizeof(CharT), 1, m_file.get()) < 1);
}
};
///////////////////////////////////////////////////////////////////////////////
//
// mmap_file_iterator
//
// File iterator for memory mapped files, for now implemented on Windows and
// POSIX platforms. This class has the same interface of std_file_iterator,
// and can be used in its place (in fact, it's the default for Windows and
// POSIX).
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// mmap_file_iterator, Windows version
#ifdef BOOST_SPIRIT_FILEITERATOR_WINDOWS
template <typename CharT>
class mmap_file_iterator
{
public:
typedef CharT value_type;
mmap_file_iterator()
{}
explicit mmap_file_iterator(std::string fileName)
{
HANDLE hFile = ::CreateFileA(
fileName.c_str(),
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_FLAG_SEQUENTIAL_SCAN,
NULL
);
if (hFile == INVALID_HANDLE_VALUE)
return;
// Store the size of the file, it's used to construct
// the end iterator
m_filesize = ::GetFileSize(hFile, NULL);
HANDLE hMap = ::CreateFileMapping(
hFile,
NULL,
PAGE_READONLY,
0, 0,
NULL
);
if (hMap == NULL)
{
::CloseHandle(hFile);
return;
}
LPVOID pMem = ::MapViewOfFile(
hMap,
FILE_MAP_READ,
0, 0, 0
);
if (pMem == NULL)
{
::CloseHandle(hMap);
::CloseHandle(hFile);
return;
}
// We hold both the file handle and the memory pointer.
// We can close the hMap handle now because Windows holds internally
// a reference to it since there is a view mapped.
::CloseHandle(hMap);
// It seems like we can close the file handle as well (because
// a reference is hold by the filemap object).
::CloseHandle(hFile);
// Store the handles inside the shared_ptr (with the custom destructors)
m_mem.reset(static_cast<CharT*>(pMem), ::UnmapViewOfFile);
// Start of the file
m_curChar = m_mem.get();
}
mmap_file_iterator(const mmap_file_iterator& iter)
{ *this = iter; }
mmap_file_iterator& operator=(const mmap_file_iterator& iter)
{
m_curChar = iter.m_curChar;
m_mem = iter.m_mem;
m_filesize = iter.m_filesize;
return *this;
}
// Nasty bug in Comeau up to 4.3.0.1, we need explicit boolean context
// for shared_ptr to evaluate correctly
operator bool() const
{ return m_mem ? true : false; }
bool operator==(const mmap_file_iterator& iter) const
{ return m_curChar == iter.m_curChar; }
const CharT& get_cur_char(void) const
{ return *m_curChar; }
void next_char(void)
{ m_curChar++; }
void prev_char(void)
{ m_curChar--; }
void advance(std::ptrdiff_t n)
{ m_curChar += n; }
std::ptrdiff_t distance(const mmap_file_iterator& iter) const
{ return m_curChar - iter.m_curChar; }
void seek_end(void)
{
m_curChar = m_mem.get() +
(m_filesize / sizeof(CharT));
}
private:
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
typedef boost::remove_pointer<HANDLE>::type handle_t;
#else
typedef void handle_t;
#endif
boost::shared_ptr<CharT> m_mem;
std::size_t m_filesize;
CharT* m_curChar;
};
#endif // BOOST_SPIRIT_FILEITERATOR_WINDOWS
///////////////////////////////////////////////////////////////////////////////
// mmap_file_iterator, POSIX version
#ifdef BOOST_SPIRIT_FILEITERATOR_POSIX
template <typename CharT>
class mmap_file_iterator
{
private:
struct mapping
{
mapping(void *p, off_t len)
: data(p)
, size(len)
{ }
CharT const *begin() const
{
return static_cast<CharT *>(data);
}
CharT const *end() const
{
return static_cast<CharT *>(data) + size/sizeof(CharT);
}
~mapping()
{
munmap(static_cast<char*>(data), size);
}
private:
void *data;
off_t size;
};
public:
typedef CharT value_type;
mmap_file_iterator()
{}
explicit mmap_file_iterator(std::string file_name)
{
// open the file
int fd = open(file_name.c_str(),
#ifdef O_NOCTTY
O_NOCTTY | // if stdin was closed then opening a file
// would cause the file to become the controlling
// terminal if the filename refers to a tty. Setting
// O_NOCTTY inhibits this.
#endif
O_RDONLY);
if (fd == -1)
return;
// call fstat to find get information about the file just
// opened (size and file type)
struct stat stat_buf;
if ((fstat(fd, &stat_buf) != 0) || !S_ISREG(stat_buf.st_mode))
{ // if fstat returns an error or if the file isn't a
// regular file we give up.
close(fd);
return;
}
// perform the actual mapping
void *p = mmap(0, stat_buf.st_size, PROT_READ, MAP_SHARED, fd, 0);
// it is safe to close() here. POSIX requires that the OS keeps a
// second handle to the file while the file is mmapped.
close(fd);
if (p == MAP_FAILED)
return;
mapping *m = 0;
try
{
m = new mapping(p, stat_buf.st_size);
}
catch(...)
{
munmap(static_cast<char*>(p), stat_buf.st_size);
throw;
}
m_mem.reset(m);
// Start of the file
m_curChar = m_mem->begin();
}
mmap_file_iterator(const mmap_file_iterator& iter)
{ *this = iter; }
mmap_file_iterator& operator=(const mmap_file_iterator& iter)
{
m_curChar = iter.m_curChar;
m_mem = iter.m_mem;
return *this;
}
// Nasty bug in Comeau up to 4.3.0.1, we need explicit boolean context
// for shared_ptr to evaluate correctly
operator bool() const
{ return m_mem ? true : false; }
bool operator==(const mmap_file_iterator& iter) const
{ return m_curChar == iter.m_curChar; }
const CharT& get_cur_char(void) const
{ return *m_curChar; }
void next_char(void)
{ m_curChar++; }
void prev_char(void)
{ m_curChar--; }
void advance(signed long n)
{ m_curChar += n; }
long distance(const mmap_file_iterator& iter) const
{ return m_curChar - iter.m_curChar; }
void seek_end(void)
{
m_curChar = m_mem->end();
}
private:
boost::shared_ptr<mapping> m_mem;
CharT const* m_curChar;
};
#endif // BOOST_SPIRIT_FILEITERATOR_POSIX
///////////////////////////////////////////////////////////////////////////////
} /* namespace boost::spirit::fileiter_impl */
template <typename CharT, typename BaseIteratorT>
file_iterator<CharT,BaseIteratorT>
file_iterator<CharT,BaseIteratorT>::make_end(void)
{
file_iterator iter(*this);
iter.base_reference().seek_end();
return iter;
}
template <typename CharT, typename BaseIteratorT>
file_iterator<CharT,BaseIteratorT>&
file_iterator<CharT,BaseIteratorT>::operator=(const base_t& iter)
{
base_t::operator=(iter);
return *this;
}
///////////////////////////////////////////////////////////////////////////////
BOOST_SPIRIT_CLASSIC_NAMESPACE_END
}} /* namespace boost::spirit */
#endif /* BOOST_SPIRIT_FILE_ITERATOR_IPP */

View File

@@ -0,0 +1,138 @@
/*=============================================================================
Copyright (c) 2002 Juan Carlos Arevalo-Baeza
Copyright (c) 2002-2006 Hartmut Kaiser
Copyright (c) 2003 Giovanni Bajo
http://spirit.sourceforge.net/
Use, modification and distribution is subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#ifndef POSITION_ITERATOR_IPP
#define POSITION_ITERATOR_IPP
#include <boost/config.hpp>
#include <boost/iterator_adaptors.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/spirit/home/classic/core/nil.hpp> // for nil_t
#include <boost/detail/iterator.hpp> // for boost::detail::iterator_traits
namespace boost { namespace spirit {
BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
///////////////////////////////////////////////////////////////////////////////
//
// position_policy<file_position_without_column>
//
// Specialization to handle file_position_without_column. Only take care of
// newlines since no column tracking is needed.
//
///////////////////////////////////////////////////////////////////////////////
template <typename String>
class position_policy<file_position_without_column_base<String> > {
public:
void next_line(file_position_without_column_base<String>& pos)
{
++pos.line;
}
void set_tab_chars(unsigned int /*chars*/){}
void next_char(file_position_without_column_base<String>& /*pos*/) {}
void tabulation(file_position_without_column_base<String>& /*pos*/) {}
};
///////////////////////////////////////////////////////////////////////////////
//
// position_policy<file_position>
//
// Specialization to handle file_position. Track characters and tabulation
// to compute the current column correctly.
//
// Default tab size is 4. You can change this with the set_tabchars member
// of position_iterator.
//
///////////////////////////////////////////////////////////////////////////////
template <typename String>
class position_policy<file_position_base<String> > {
public:
position_policy()
: m_CharsPerTab(4)
{}
void next_line(file_position_base<String>& pos)
{
++pos.line;
pos.column = 1;
}
void set_tab_chars(unsigned int chars)
{
m_CharsPerTab = chars;
}
void next_char(file_position_base<String>& pos)
{
++pos.column;
}
void tabulation(file_position_base<String>& pos)
{
pos.column += m_CharsPerTab - (pos.column - 1) % m_CharsPerTab;
}
private:
unsigned int m_CharsPerTab;
};
/* namespace boost::spirit { */ namespace iterator_ { namespace impl {
///////////////////////////////////////////////////////////////////////////////
//
// position_iterator_base_generator
//
// Metafunction to generate the iterator type using boost::iterator_adaptors,
// hiding all the metaprogramming thunking code in it. It is used
// mainly to keep the public interface (position_iterator) cleanear.
//
///////////////////////////////////////////////////////////////////////////////
template <typename MainIterT, typename ForwardIterT, typename PositionT>
struct position_iterator_base_generator
{
private:
typedef boost::detail::iterator_traits<ForwardIterT> traits;
typedef typename traits::value_type value_type;
typedef typename traits::iterator_category iter_category_t;
// Position iterator is always a non-mutable iterator
typedef typename boost::add_const<value_type>::type const_value_type;
public:
// Check if the MainIterT is nil. If it's nil, it means that the actual
// self type is position_iterator. Otherwise, it's a real type we
// must use
typedef typename boost::mpl::if_<
typename boost::is_same<MainIterT, nil_t>::type,
position_iterator<ForwardIterT, PositionT, nil_t>,
MainIterT
>::type main_iter_t;
typedef boost::iterator_adaptor<
main_iter_t,
ForwardIterT,
const_value_type,
boost::forward_traversal_tag
> type;
};
}}
BOOST_SPIRIT_CLASSIC_NAMESPACE_END
}} /* namespace boost::spirit::iterator_::impl */
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,47 @@
/*=============================================================================
Copyright (c) 2006 Tobias Schwinger
http://spirit.sourceforge.net/
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(BOOST_SPIRIT_ITERATOR_MULTI_PASS_FWD_HPP)
#define BOOST_SPIRIT_ITERATOR_MULTI_PASS_FWD_HPP
#include <cstddef>
#include <boost/spirit/home/classic/namespace.hpp>
namespace boost { namespace spirit {
BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
namespace multi_pass_policies
{
class ref_counted;
class first_owner;
class buf_id_check;
class no_check;
class std_deque;
template<std::size_t N> class fixed_size_queue;
class input_iterator;
class lex_input;
class functor_input;
}
template
<
typename InputT,
typename InputPolicy = multi_pass_policies::input_iterator,
typename OwnershipPolicy = multi_pass_policies::ref_counted,
typename CheckingPolicy = multi_pass_policies::buf_id_check,
typename StoragePolicy = multi_pass_policies::std_deque
>
class multi_pass;
BOOST_SPIRIT_CLASSIC_NAMESPACE_END
}} // namespace BOOST_SPIRIT_CLASSIC_NS
#endif

View File

@@ -0,0 +1,436 @@
/*=============================================================================
Copyright (c) 2002 Juan Carlos Arevalo-Baeza
Copyright (c) 2002-2006 Hartmut Kaiser
Copyright (c) 2003 Giovanni Bajo
http://spirit.sourceforge.net/
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#ifndef BOOST_SPIRIT_POSITION_ITERATOR_HPP
#define BOOST_SPIRIT_POSITION_ITERATOR_HPP
#include <string>
#include <boost/config.hpp>
#include <boost/concept_check.hpp>
#include <boost/spirit/home/classic/namespace.hpp>
#include <boost/spirit/home/classic/iterator/position_iterator_fwd.hpp>
namespace boost { namespace spirit {
BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
///////////////////////////////////////////////////////////////////////////////
//
// file_position_without_column
//
// A structure to hold positional information. This includes the file,
// and the line number
//
///////////////////////////////////////////////////////////////////////////////
template <typename String>
struct file_position_without_column_base {
String file;
int line;
file_position_without_column_base(String const& file_ = String(),
int line_ = 1):
file (file_),
line (line_)
{}
bool operator==(const file_position_without_column_base& fp) const
{ return line == fp.line && file == fp.file; }
};
///////////////////////////////////////////////////////////////////////////////
//
// file_position
//
// This structure holds complete file position, including file name,
// line and column number
//
///////////////////////////////////////////////////////////////////////////////
template <typename String>
struct file_position_base : public file_position_without_column_base<String> {
int column;
file_position_base(String const& file_ = String(),
int line_ = 1, int column_ = 1):
file_position_without_column_base<String> (file_, line_),
column (column_)
{}
bool operator==(const file_position_base& fp) const
{ return column == fp.column && this->line == fp.line && this->file == fp.file; }
};
///////////////////////////////////////////////////////////////////////////////
//
// position_policy<>
//
// This template is the policy to handle the file position. It is specialized
// on the position type. Providing a custom file_position also requires
// providing a specialization of this class.
//
// Policy interface:
//
// Default constructor of the custom position class must be accessible.
// set_tab_chars(unsigned int chars) - Set the tabstop width
// next_char(PositionT& pos) - Notify that a new character has been
// processed
// tabulation(PositionT& pos) - Notify that a tab character has been
// processed
// next_line(PositionT& pos) - Notify that a new line delimiter has
// been reached.
//
///////////////////////////////////////////////////////////////////////////////
template <typename PositionT> class position_policy;
///////////////////////////////////////////////////////////////////////////////
BOOST_SPIRIT_CLASSIC_NAMESPACE_END
}} /* namespace BOOST_SPIRIT_CLASSIC_NS */
// This must be included here for full compatibility with old MSVC
#include "boost/spirit/home/classic/iterator/impl/position_iterator.ipp"
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace spirit {
BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
///////////////////////////////////////////////////////////////////////////////
//
// position_iterator
//
// It wraps an iterator, and keeps track of the current position in the input,
// as it gets incremented.
//
// The wrapped iterator must be at least a Forward iterator. The position
// iterator itself will always be a non-mutable Forward iterator.
//
// In order to have begin/end iterators constructed, the end iterator must be
// empty constructed. Similar to what happens with stream iterators. The begin
// iterator must be constructed from both, the begin and end iterators of the
// wrapped iterator type. This is necessary to implement the lookahead of
// characters necessary to parse CRLF sequences.
//
// In order to extract the current positional data from the iterator, you may
// use the get_position member function.
//
// You can also use the set_position member function to reset the current
// position to something new.
//
// The structure that holds the current position can be customized through a
// template parameter, and the class position_policy must be specialized
// on the new type to define how to handle it. Currently, it's possible
// to choose between the file_position and file_position_without_column
// (which saves some overhead if managing current column is not required).
//
///////////////////////////////////////////////////////////////////////////////
#if !defined(BOOST_ITERATOR_ADAPTORS_VERSION) || \
BOOST_ITERATOR_ADAPTORS_VERSION < 0x0200
#error "Please use at least Boost V1.31.0 while compiling the position_iterator class!"
#else // BOOST_ITERATOR_ADAPTORS_VERSION < 0x0200
///////////////////////////////////////////////////////////////////////////////
//
// Uses the newer iterator_adaptor version (should be released with
// Boost V1.31.0)
//
///////////////////////////////////////////////////////////////////////////////
template <
typename ForwardIteratorT,
typename PositionT,
typename SelfT
>
class position_iterator
: public iterator_::impl::position_iterator_base_generator<
SelfT,
ForwardIteratorT,
PositionT
>::type,
public position_policy<PositionT>
{
private:
typedef position_policy<PositionT> position_policy_t;
typedef typename iterator_::impl::position_iterator_base_generator<
SelfT,
ForwardIteratorT,
PositionT
>::type base_t;
typedef typename iterator_::impl::position_iterator_base_generator<
SelfT,
ForwardIteratorT,
PositionT
>::main_iter_t main_iter_t;
public:
typedef PositionT position_t;
position_iterator()
: _isend(true)
{}
position_iterator(
const ForwardIteratorT& begin,
const ForwardIteratorT& end)
: base_t(begin), _end(end), _pos(PositionT()), _isend(begin == end)
{}
template <typename FileNameT>
position_iterator(
const ForwardIteratorT& begin,
const ForwardIteratorT& end,
FileNameT fileName)
: base_t(begin), _end(end), _pos(PositionT(fileName)),
_isend(begin == end)
{}
template <typename FileNameT, typename LineT>
position_iterator(
const ForwardIteratorT& begin,
const ForwardIteratorT& end,
FileNameT fileName, LineT line)
: base_t(begin), _end(end), _pos(PositionT(fileName, line)),
_isend(begin == end)
{}
template <typename FileNameT, typename LineT, typename ColumnT>
position_iterator(
const ForwardIteratorT& begin,
const ForwardIteratorT& end,
FileNameT fileName, LineT line, ColumnT column)
: base_t(begin), _end(end), _pos(PositionT(fileName, line, column)),
_isend(begin == end)
{}
position_iterator(
const ForwardIteratorT& begin,
const ForwardIteratorT& end,
const PositionT& pos)
: base_t(begin), _end(end), _pos(pos), _isend(begin == end)
{}
position_iterator(const position_iterator& iter)
: base_t(iter.base()), position_policy_t(iter),
_end(iter._end), _pos(iter._pos), _isend(iter._isend)
{}
position_iterator& operator=(const position_iterator& iter)
{
base_t::operator=(iter);
position_policy_t::operator=(iter);
_end = iter._end;
_pos = iter._pos;
_isend = iter._isend;
return *this;
}
void set_position(PositionT const& newpos) { _pos = newpos; }
PositionT& get_position() { return _pos; }
PositionT const& get_position() const { return _pos; }
void set_tabchars(unsigned int chars)
{
// This function (which comes from the position_policy) has a
// different name on purpose, to avoid messing with using
// declarations or qualified calls to access the base template
// function, which might break some compilers.
this->position_policy_t::set_tab_chars(chars);
}
private:
friend class boost::iterator_core_access;
void increment()
{
typename base_t::reference val = *(this->base());
if (val == '\n') {
++this->base_reference();
this->next_line(_pos);
static_cast<main_iter_t &>(*this).newline();
}
else if ( val == '\r') {
++this->base_reference();
if (this->base_reference() == _end || *(this->base()) != '\n')
{
this->next_line(_pos);
static_cast<main_iter_t &>(*this).newline();
}
}
else if (val == '\t') {
this->tabulation(_pos);
++this->base_reference();
}
else {
this->next_char(_pos);
++this->base_reference();
}
// The iterator is at the end only if it's the same
// of the
_isend = (this->base_reference() == _end);
}
template <
typename OtherDerivedT, typename OtherIteratorT,
typename V, typename C, typename R, typename D
>
bool equal(iterator_adaptor<OtherDerivedT, OtherIteratorT, V, C, R, D>
const &x) const
{
OtherDerivedT const &rhs = static_cast<OtherDerivedT const &>(x);
bool x_is_end = rhs._isend;
return (_isend == x_is_end) && (_isend || this->base() == rhs.base());
}
protected:
void newline(void)
{}
ForwardIteratorT _end;
PositionT _pos;
bool _isend;
};
#endif // BOOST_ITERATOR_ADAPTORS_VERSION < 0x0200
///////////////////////////////////////////////////////////////////////////////
//
// position_iterator2
//
// Equivalent to position_iterator, but it is able to extract the current
// line into a string. This is very handy for error reports.
//
// Notice that the footprint of this class is higher than position_iterator,
// (how much depends on how bulky the underlying iterator is), so it should
// be used only if necessary.
//
///////////////////////////////////////////////////////////////////////////////
template
<
typename ForwardIteratorT,
typename PositionT
>
class position_iterator2
: public position_iterator
<
ForwardIteratorT,
PositionT,
position_iterator2<ForwardIteratorT, PositionT>
>
{
typedef position_iterator
<
ForwardIteratorT,
PositionT,
position_iterator2<ForwardIteratorT, PositionT> // JDG 4-15-03
> base_t;
public:
typedef typename base_t::value_type value_type;
typedef PositionT position_t;
position_iterator2()
{}
position_iterator2(
const ForwardIteratorT& begin,
const ForwardIteratorT& end):
base_t(begin, end),
_startline(begin)
{}
template <typename FileNameT>
position_iterator2(
const ForwardIteratorT& begin,
const ForwardIteratorT& end,
FileNameT file):
base_t(begin, end, file),
_startline(begin)
{}
template <typename FileNameT, typename LineT>
position_iterator2(
const ForwardIteratorT& begin,
const ForwardIteratorT& end,
FileNameT file, LineT line):
base_t(begin, end, file, line),
_startline(begin)
{}
template <typename FileNameT, typename LineT, typename ColumnT>
position_iterator2(
const ForwardIteratorT& begin,
const ForwardIteratorT& end,
FileNameT file, LineT line, ColumnT column):
base_t(begin, end, file, line, column),
_startline(begin)
{}
position_iterator2(
const ForwardIteratorT& begin,
const ForwardIteratorT& end,
const PositionT& pos):
base_t(begin, end, pos),
_startline(begin)
{}
position_iterator2(const position_iterator2& iter)
: base_t(iter), _startline(iter._startline)
{}
position_iterator2& operator=(const position_iterator2& iter)
{
base_t::operator=(iter);
_startline = iter._startline;
return *this;
}
ForwardIteratorT get_currentline_begin(void) const
{ return _startline; }
ForwardIteratorT get_currentline_end(void) const
{ return get_endline(); }
std::basic_string<value_type> get_currentline(void) const
{
return std::basic_string<value_type>
(get_currentline_begin(), get_currentline_end());
}
protected:
ForwardIteratorT _startline;
friend class position_iterator<ForwardIteratorT, PositionT,
position_iterator2<ForwardIteratorT, PositionT> >;
ForwardIteratorT get_endline() const
{
ForwardIteratorT endline = _startline;
while (endline != this->_end && *endline != '\r' && *endline != '\n')
{
++endline;
}
return endline;
}
void newline(void)
{ _startline = this->base(); }
};
BOOST_SPIRIT_CLASSIC_NAMESPACE_END
}} // namespace BOOST_SPIRIT_CLASSIC_NS
#endif

View File

@@ -0,0 +1,60 @@
/*=============================================================================
Copyright (c) 2006 Tobias Schwinger
Copyright (c) 2002-2006 Hartmut Kaiser
http://spirit.sourceforge.net/
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(BOOST_SPIRIT_POSITION_ITERATOR_FWD_HPP)
#define BOOST_SPIRIT_POSITION_ITERATOR_FWD_HPP
#include <string>
#include <boost/detail/iterator.hpp> // for boost::detail::iterator_traits
#include <boost/spirit/home/classic/namespace.hpp>
#include <boost/spirit/home/classic/core/nil.hpp>
namespace boost { namespace spirit {
BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
template <typename String = std::string>
struct file_position_base;
typedef file_position_base<std::string> file_position;
template <typename String = std::string>
struct file_position_without_column_base;
typedef file_position_without_column_base<std::string> file_position_without_column;
template <
typename ForwardIteratorT,
typename PositionT = file_position_base<
std::basic_string<
typename boost::detail::iterator_traits<ForwardIteratorT>::value_type
>
>,
typename SelfT = nil_t
>
class position_iterator;
template
<
typename ForwardIteratorT,
typename PositionT = file_position_base<
std::basic_string<
typename boost::detail::iterator_traits<ForwardIteratorT>::value_type
>
>
>
class position_iterator2;
template <typename PositionT> class position_policy;
BOOST_SPIRIT_CLASSIC_NAMESPACE_END
}} // namespace BOOST_SPIRIT_CLASSIC_NS
#endif

View File

@@ -0,0 +1,94 @@
/*=============================================================================
Copyright (c) 2006 Tobias Schwinger
http://spirit.sourceforge.net/
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#if !defined(BOOST_SPIRIT_ITERATOR_TYPEOF_HPP)
#define BOOST_SPIRIT_ITERATOR_TYPEOF_HPP
#include <boost/typeof/typeof.hpp>
#include <boost/typeof/std/string.hpp>
#include <boost/spirit/home/classic/namespace.hpp>
#include <boost/spirit/home/classic/iterator/multi_pass_fwd.hpp>
#include <boost/spirit/home/classic/iterator/file_iterator_fwd.hpp>
#include <boost/spirit/home/classic/iterator/position_iterator_fwd.hpp>
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
namespace boost { namespace spirit {
BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
// external (from core)
struct nil_t;
// fixed_size_queue.hpp
template<typename T, std::size_t N> class fixed_size_queue;
template<typename QueueT, typename T, typename PointerT>
class fsq_iterator;
BOOST_SPIRIT_CLASSIC_NAMESPACE_END
}} // namespace BOOST_SPIRIT_CLASSIC_NS
#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
#if !defined(BOOST_SPIRIT_NIL_T_TYPEOF_REGISTERED)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::nil_t)
# define BOOST_SPIRIT_NIL_T_TYPEOF_REGISTERED
#endif
// multi_pass.hpp (has forward header)
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::multi_pass,5)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::multi_pass_policies::ref_counted)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::multi_pass_policies::first_owner)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::multi_pass_policies::buf_id_check)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::multi_pass_policies::no_check)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::multi_pass_policies::std_deque)
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::multi_pass_policies::fixed_size_queue,(BOOST_TYPEOF_INTEGRAL(std::size_t)))
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::multi_pass_policies::input_iterator)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::multi_pass_policies::lex_input)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::multi_pass_policies::functor_input)
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::multi_pass,3)
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::multi_pass,1)
// file_iterator.hpp
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::file_iterator,2)
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::fileiter_impl::std_file_iterator,1)
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::fileiter_impl::mmap_file_iterator,1)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::fileiter_impl::std_file_iterator<char>)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::fileiter_impl::std_file_iterator<wchar_t>)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::fileiter_impl::mmap_file_iterator<char>)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::fileiter_impl::mmap_file_iterator<wchar_t>)
// fixed_size_queue.hpp
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::fixed_size_queue,(typename)(BOOST_TYPEOF_INTEGRAL(std::size_t)))
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::fsq_iterator,3)
// position_iterator.hpp
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::position_iterator,3)
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::position_iterator2,2)
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::position_policy,1)
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::file_position_base,1)
BOOST_TYPEOF_REGISTER_TEMPLATE(BOOST_SPIRIT_CLASSIC_NS::file_position_without_column_base,1)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::file_position)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::file_position_base<std::basic_string<wchar_t> >)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::file_position_without_column)
BOOST_TYPEOF_REGISTER_TYPE(BOOST_SPIRIT_CLASSIC_NS::file_position_without_column_base<std::basic_string<wchar_t> >)
#endif