mirror of
https://github.com/boostorg/regex.git
synced 2025-07-15 05:16:37 +02:00
Remove dead files.
Strip tabs from files. [SVN r30003]
This commit is contained in:
@ -1,3 +0,0 @@
|
|||||||
#include <cregex.h>
|
|
||||||
|
|
||||||
|
|
@ -1,126 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 1998-2000
|
|
||||||
* John Maddock
|
|
||||||
*
|
|
||||||
* Use, modification and distribution are 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)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* FILE cregex.h
|
|
||||||
* VERSION see <boost/version.hpp>
|
|
||||||
* deprecated regular expression matching algorithms
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef BOOST_OLD_CREGEX_H
|
|
||||||
#define BOOST_OLD_CREGEX_H
|
|
||||||
|
|
||||||
#include <boost/cregex.hpp>
|
|
||||||
|
|
||||||
//
|
|
||||||
// macro defs:
|
|
||||||
#define JM_STD std
|
|
||||||
#define JM_CSTD std
|
|
||||||
#define JM jm
|
|
||||||
|
|
||||||
#ifdef BOOST_RE_OLD_IOSTREAM
|
|
||||||
#define JM_OLD_IOSTREAM
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
|
|
||||||
namespace jm = boost;
|
|
||||||
|
|
||||||
#if !defined(BOOST_RE_NO_USING)
|
|
||||||
using boost::regex_tA;
|
|
||||||
using boost::regex_t;
|
|
||||||
using boost::regoff_t;
|
|
||||||
using boost::regmatch_t;
|
|
||||||
using boost::regcompA;
|
|
||||||
using boost::regerrorA;
|
|
||||||
using boost::regexecA;
|
|
||||||
using boost::regfreeA;
|
|
||||||
|
|
||||||
#ifndef BOOST_NO_WREGEX
|
|
||||||
using boost::regex_tW;
|
|
||||||
using boost::regcompW;
|
|
||||||
using boost::regerrorW;
|
|
||||||
using boost::regexecW;
|
|
||||||
using boost::regfreeW;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using boost::RegEx;
|
|
||||||
using boost::GrepCallback;
|
|
||||||
using boost::GrepFileCallback;
|
|
||||||
using boost::FindFilesCallback;
|
|
||||||
|
|
||||||
using boost::match_flags;
|
|
||||||
using boost::reg_errcode_t;
|
|
||||||
|
|
||||||
using boost::REG_NOERROR;
|
|
||||||
using boost::REG_NOMATCH;
|
|
||||||
using boost::REG_BADPAT;
|
|
||||||
using boost::REG_ECOLLATE;
|
|
||||||
using boost::REG_ECTYPE;
|
|
||||||
using boost::REG_EESCAPE;
|
|
||||||
using boost::REG_ESUBREG;
|
|
||||||
using boost::REG_EBRACK;
|
|
||||||
using boost::REG_EPAREN;
|
|
||||||
using boost::REG_EBRACE;
|
|
||||||
using boost::REG_BADBR;
|
|
||||||
using boost::REG_ERANGE;
|
|
||||||
using boost::REG_ESPACE;
|
|
||||||
using boost::REG_BADRPT;
|
|
||||||
using boost::REG_EEND;
|
|
||||||
using boost::REG_ESIZE;
|
|
||||||
using boost::REG_ERPAREN;
|
|
||||||
using boost::REG_EMPTY;
|
|
||||||
using boost::REG_E_MEMORY;
|
|
||||||
using boost::REG_E_UNKNOWN;
|
|
||||||
using boost::match_default;
|
|
||||||
using boost::match_not_bol;
|
|
||||||
using boost::match_not_eol;
|
|
||||||
using boost::match_not_bob;
|
|
||||||
using boost::match_not_eob;
|
|
||||||
using boost::match_not_bow;
|
|
||||||
using boost::match_not_eow;
|
|
||||||
using boost::match_not_dot_newline;
|
|
||||||
using boost::match_not_dot_null;
|
|
||||||
using boost::match_prev_avail;
|
|
||||||
using boost::match_init;
|
|
||||||
using boost::match_any;
|
|
||||||
using boost::match_not_null;
|
|
||||||
using boost::match_continuous;
|
|
||||||
using boost::match_stop;
|
|
||||||
|
|
||||||
using boost::REG_BASIC;
|
|
||||||
using boost::REG_EXTENDED;
|
|
||||||
using boost::REG_ICASE;
|
|
||||||
using boost::REG_NOSUB;
|
|
||||||
using boost::REG_NEWLINE;
|
|
||||||
using boost::REG_NOSPEC;
|
|
||||||
using boost::REG_PEND;
|
|
||||||
using boost::REG_DUMP;
|
|
||||||
using boost::REG_NOCOLLATE;
|
|
||||||
|
|
||||||
using boost::REG_ASSERT;
|
|
||||||
using boost::REG_INVARG;
|
|
||||||
using boost::REG_ATOI;
|
|
||||||
using boost::REG_ITOA;
|
|
||||||
|
|
||||||
using boost::REG_NOTBOL;
|
|
||||||
using boost::REG_NOTEOL;
|
|
||||||
using boost::REG_STARTEND;
|
|
||||||
|
|
||||||
#endif // BOOST_RE_NO_USING
|
|
||||||
#endif // __cplusplus
|
|
||||||
|
|
||||||
#ifdef BOOST_RE_USING_HACK
|
|
||||||
using namespace boost;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // include guard
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 1998-2000
|
|
||||||
* John Maddock
|
|
||||||
*
|
|
||||||
* Use, modification and distribution are 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_FILEITER_H
|
|
||||||
#define BOOST_FILEITER_H
|
|
||||||
|
|
||||||
#include <boost/regex/v3/fileiter.hpp>
|
|
||||||
|
|
||||||
using boost::re_detail::directory_iterator;
|
|
||||||
using boost::re_detail::file_iterator;
|
|
||||||
using boost::re_detail::mapfile;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
|||||||
#include <regex.h>
|
|
||||||
|
|
||||||
|
|
@ -1,436 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 1998-2000
|
|
||||||
* John Maddock
|
|
||||||
*
|
|
||||||
* Use, modification and distribution are 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)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* FILE regex.h
|
|
||||||
* VERSION see <boost/version.hpp>
|
|
||||||
* deprecated regular expression matching algorithms
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef BOOST_OLD_REGEX_H
|
|
||||||
#define BOOST_OLD_REGEX_H
|
|
||||||
|
|
||||||
#include <cregex.h>
|
|
||||||
#include <boost/regex.hpp>
|
|
||||||
|
|
||||||
namespace boost{
|
|
||||||
|
|
||||||
namespace deprecated{
|
|
||||||
//
|
|
||||||
// class reg_match:
|
|
||||||
// old name for match_results, this ones just a thin wrapper:
|
|
||||||
//
|
|
||||||
template <class iterator, class Allocator = BOOST_DEFAULT_ALLOCATOR(typename boost::re_detail::def_alloc_param_traits<iterator>::type)>
|
|
||||||
class reg_match : public boost::match_results<iterator, Allocator>
|
|
||||||
{
|
|
||||||
typedef boost::match_results<iterator, Allocator> base_type;
|
|
||||||
typedef boost::re_detail::match_results_base<iterator, Allocator> ancestor;
|
|
||||||
public:
|
|
||||||
reg_match(const Allocator& a = Allocator())
|
|
||||||
: base_type(a){}
|
|
||||||
|
|
||||||
reg_match(const ancestor& m)
|
|
||||||
: base_type(m){}
|
|
||||||
|
|
||||||
reg_match& operator=(const ancestor& m)
|
|
||||||
{
|
|
||||||
// shallow copy
|
|
||||||
ancestor::operator=(m);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
reg_match(const base_type& m)
|
|
||||||
: base_type(m){}
|
|
||||||
reg_match& operator=(const base_type& m)
|
|
||||||
{
|
|
||||||
// deep copy
|
|
||||||
base_type::operator=(m);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
//
|
|
||||||
// proc query_match
|
|
||||||
// returns true if the specified regular expression matches
|
|
||||||
// at position first. Fills in what matched in m.
|
|
||||||
//
|
|
||||||
template <class iterator, class Allocator, class charT, class traits, class Allocator2>
|
|
||||||
bool query_match(iterator first, iterator last, boost::match_results<iterator, Allocator>& m, const reg_expression<charT, traits, Allocator2>& e, unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return regex_search(first, last, m, e, flags | match_continuous);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// query_match convenience interfaces:
|
|
||||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
|
||||||
//
|
|
||||||
// this isn't really a partial specialisation, but template function
|
|
||||||
// overloading - if the compiler doesn't support partial specialisation
|
|
||||||
// then it really won't support this either:
|
|
||||||
template <class charT, class Allocator, class traits, class Allocator2>
|
|
||||||
inline bool query_match(const charT* str,
|
|
||||||
boost::match_results<const charT*, Allocator>& m,
|
|
||||||
const reg_expression<charT, traits, Allocator2>& e,
|
|
||||||
unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return query_match(str, str + traits::length(str), m, e, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class ST, class SA, class Allocator, class charT, class traits, class Allocator2>
|
|
||||||
inline bool query_match(const std::basic_string<charT, ST, SA>& s,
|
|
||||||
boost::match_results<typename std::basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
|
|
||||||
const reg_expression<charT, traits, Allocator2>& e,
|
|
||||||
unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return query_match(s.begin(), s.end(), m, e, flags);
|
|
||||||
}
|
|
||||||
#else // partial ordering
|
|
||||||
inline bool query_match(const char* str,
|
|
||||||
cmatch& m,
|
|
||||||
const regex& e,
|
|
||||||
unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return query_match(str, str + regex::traits_type::length(str), m, e, flags);
|
|
||||||
}
|
|
||||||
#ifndef BOOST_NO_WREGEX
|
|
||||||
inline bool query_match(const wchar_t* str,
|
|
||||||
wcmatch& m,
|
|
||||||
const wregex& e,
|
|
||||||
unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return query_match(str, str + wregex::traits_type::length(str), m, e, flags);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
inline bool query_match(const std::string& s,
|
|
||||||
boost::match_results<std::string::const_iterator, regex::allocator_type>& m,
|
|
||||||
const regex& e,
|
|
||||||
unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return query_match(s.begin(), s.end(), m, e, flags);
|
|
||||||
}
|
|
||||||
#if !defined(BOOST_NO_WREGEX)
|
|
||||||
inline bool query_match(const std::basic_string<wchar_t>& s,
|
|
||||||
boost::match_results<std::basic_string<wchar_t>::const_iterator, wregex::allocator_type>& m,
|
|
||||||
const wregex& e,
|
|
||||||
unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return query_match(s.begin(), s.end(), m, e, flags);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
template <class iterator, class Allocator, class charT, class traits, class Allocator2>
|
|
||||||
bool reg_search(iterator first, iterator last, boost::match_results<iterator, Allocator>& m, const reg_expression<charT, traits, Allocator2>& e, unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return boost::regex_search(first, last, m, e, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// reg_search convenience interfaces:
|
|
||||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
|
||||||
//
|
|
||||||
// this isn't really a partial specialisation, but template function
|
|
||||||
// overloading - if the compiler doesn't support partial specialisation
|
|
||||||
// then it really won't support this either:
|
|
||||||
template <class charT, class Allocator, class traits, class Allocator2>
|
|
||||||
inline bool reg_search(const charT* str,
|
|
||||||
boost::match_results<const charT*, Allocator>& m,
|
|
||||||
const reg_expression<charT, traits, Allocator2>& e,
|
|
||||||
unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return reg_search(str, str + traits::length(str), m, e, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef BOOST_RE_NO_STRING_H
|
|
||||||
template <class ST, class SA, class Allocator, class charT, class traits, class Allocator2>
|
|
||||||
inline bool reg_search(const std::basic_string<charT, ST, SA>& s,
|
|
||||||
boost::match_results<typename std::basic_string<charT, ST, SA>::const_iterator, Allocator>& m,
|
|
||||||
const reg_expression<charT, traits, Allocator2>& e,
|
|
||||||
unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return reg_search(s.begin(), s.end(), m, e, flags);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#else // partial specialisation
|
|
||||||
inline bool reg_search(const char* str,
|
|
||||||
cmatch& m,
|
|
||||||
const regex& e,
|
|
||||||
unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return reg_search(str, str + regex::traits_type::length(str), m, e, flags);
|
|
||||||
}
|
|
||||||
#ifndef BOOST_NO_WREGEX
|
|
||||||
inline bool reg_search(const wchar_t* str,
|
|
||||||
wcmatch& m,
|
|
||||||
const wregex& e,
|
|
||||||
unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return reg_search(str, str + wregex::traits_type::length(str), m, e, flags);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifndef BOOST_RE_NO_STRING_H
|
|
||||||
inline bool reg_search(const std::string& s,
|
|
||||||
boost::match_results<std::string::const_iterator, regex::allocator_type>& m,
|
|
||||||
const regex& e,
|
|
||||||
unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return reg_search(s.begin(), s.end(), m, e, flags);
|
|
||||||
}
|
|
||||||
#if !defined(BOOST_NO_WREGEX)
|
|
||||||
inline bool reg_search(const std::basic_string<wchar_t>& s,
|
|
||||||
boost::match_results<std::basic_string<wchar_t>::const_iterator, wregex::allocator_type>& m,
|
|
||||||
const wregex& e,
|
|
||||||
unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return reg_search(s.begin(), s.end(), m, e, flags);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// reg_grep:
|
|
||||||
// find all non-overlapping matches within the sequence first last:
|
|
||||||
//
|
|
||||||
template <class Predicate, class iterator, class charT, class traits, class Allocator>
|
|
||||||
inline unsigned int reg_grep(Predicate foo, iterator first, iterator last, const reg_expression<charT, traits, Allocator>& e, unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return boost::regex_grep(foo, first, last, e, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// reg_grep convenience interfaces:
|
|
||||||
#ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
|
||||||
//
|
|
||||||
// this isn't really a partial specialisation, but template function
|
|
||||||
// overloading - if the compiler doesn't support partial specialisation
|
|
||||||
// then it really won't support this either:
|
|
||||||
template <class Predicate, class charT, class Allocator, class traits>
|
|
||||||
inline unsigned int reg_grep(Predicate foo, const charT* str,
|
|
||||||
const reg_expression<charT, traits, Allocator>& e,
|
|
||||||
unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return reg_grep(foo, str, str + traits::length(str), e, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef BOOST_RE_NO_STRING_H
|
|
||||||
template <class Predicate, class ST, class SA, class Allocator, class charT, class traits>
|
|
||||||
inline unsigned int reg_grep(Predicate foo, const std::basic_string<charT, ST, SA>& s,
|
|
||||||
const reg_expression<charT, traits, Allocator>& e,
|
|
||||||
unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return reg_grep(foo, s.begin(), s.end(), e, flags);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#else // partial specialisation
|
|
||||||
inline unsigned int reg_grep(bool (*foo)(const cmatch&), const char* str,
|
|
||||||
const regex& e,
|
|
||||||
unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return reg_grep(foo, str, str + regex::traits_type::length(str), e, flags);
|
|
||||||
}
|
|
||||||
#ifndef BOOST_NO_WREGEX
|
|
||||||
inline unsigned int reg_grep(bool (*foo)(const wcmatch&), const wchar_t* str,
|
|
||||||
const wregex& e,
|
|
||||||
unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return reg_grep(foo, str, str + wregex::traits_type::length(str), e, flags);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifndef BOOST_RE_NO_STRING_H
|
|
||||||
inline unsigned int reg_grep(bool (*foo)(const boost::match_results<std::string::const_iterator, regex::allocator_type>&), const std::string& s,
|
|
||||||
const regex& e,
|
|
||||||
unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return reg_grep(foo, s.begin(), s.end(), e, flags);
|
|
||||||
}
|
|
||||||
#if !defined(BOOST_NO_WREGEX)
|
|
||||||
inline unsigned int reg_grep(bool (*foo)(const boost::match_results<std::basic_string<wchar_t>::const_iterator, wregex::allocator_type>&),
|
|
||||||
const std::basic_string<wchar_t>& s,
|
|
||||||
const wregex& e,
|
|
||||||
unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return reg_grep(foo, s.begin(), s.end(), e, flags);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//
|
|
||||||
// finally for compatablity with version 1.x of the library
|
|
||||||
// we need a form of reg_grep that takes an output iterator
|
|
||||||
// as its first argument:
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// struct grep_match:
|
|
||||||
// stores what matched during a reg_grep,
|
|
||||||
// the output iterator type passed to reg_grep must have an
|
|
||||||
// operator*() that returns a type with an
|
|
||||||
// operator=(const grep_match<iterator, Allocator>&);
|
|
||||||
//
|
|
||||||
template <class iterator, class Allocator>
|
|
||||||
struct grep_match
|
|
||||||
{
|
|
||||||
unsigned int line;
|
|
||||||
iterator line_start;
|
|
||||||
reg_match<iterator, Allocator> what;
|
|
||||||
|
|
||||||
grep_match(Allocator a = Allocator()) : what(a) {}
|
|
||||||
|
|
||||||
grep_match(unsigned int l, iterator p1, const boost::match_results<iterator, Allocator>& m)
|
|
||||||
: what(m) { line = l; line_start = p1; }
|
|
||||||
|
|
||||||
bool operator == (const grep_match& )
|
|
||||||
{ return false; }
|
|
||||||
|
|
||||||
bool operator < (const grep_match&)
|
|
||||||
{ return false; }
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace re_detail{
|
|
||||||
|
|
||||||
template <class O, class I, class A>
|
|
||||||
struct grep_adaptor
|
|
||||||
{
|
|
||||||
O oi;
|
|
||||||
reg_match<I, A> m;
|
|
||||||
grep_adaptor(O i, A a) : m(a), oi(i) {}
|
|
||||||
bool operator()(const boost::re_detail::match_results_base<I, A>& w)
|
|
||||||
{
|
|
||||||
m.what = w;
|
|
||||||
m.line = w.line();
|
|
||||||
m.line_start = w.line_start();
|
|
||||||
*oi = m;
|
|
||||||
++oi;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace re_detail
|
|
||||||
|
|
||||||
template <class Out, class iterator, class charT, class traits, class Allocator>
|
|
||||||
inline unsigned int reg_grep_old(Out oi, iterator first, iterator last, const reg_expression<charT, traits, Allocator>& e, unsigned flags = match_default)
|
|
||||||
{
|
|
||||||
return boost::regex_grep(re_detail::grep_adaptor<Out, iterator, Allocator>(oi, e.allocator()), first, last, e, flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class OutputIterator, class iterator, class Allocator, class charT>
|
|
||||||
OutputIterator BOOST_REGEX_CALL reg_format(OutputIterator out,
|
|
||||||
const boost::match_results<iterator, Allocator>& m,
|
|
||||||
const charT* fmt)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// start by updating the locale:
|
|
||||||
//
|
|
||||||
return boost::re_detail::_reg_format_aux(out, m, fmt, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class iterator, class Allocator, class charT>
|
|
||||||
std::basic_string<charT> BOOST_REGEX_CALL reg_format(const boost::match_results<iterator, Allocator>& m, const charT* fmt)
|
|
||||||
{
|
|
||||||
std::basic_string<charT> result;
|
|
||||||
boost::re_detail::string_out_iterator<std::basic_string<charT> > i(result);
|
|
||||||
reg_format(i, m, fmt);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class OutputIterator, class iterator, class traits, class Allocator, class charT>
|
|
||||||
OutputIterator BOOST_REGEX_CALL reg_merge(OutputIterator out,
|
|
||||||
iterator first,
|
|
||||||
iterator last,
|
|
||||||
const reg_expression<charT, traits, Allocator>& e,
|
|
||||||
const charT* fmt,
|
|
||||||
bool copy = true,
|
|
||||||
unsigned int flags = match_default)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// start by updating the locale:
|
|
||||||
//
|
|
||||||
iterator l = first;
|
|
||||||
if(!copy) flags |= format_no_copy;
|
|
||||||
boost::re_detail::merge_out_predicate<OutputIterator, iterator, charT, Allocator, traits> oi(out, l, fmt, flags, e.get_traits());
|
|
||||||
regex_grep(oi, first, last, e, flags);
|
|
||||||
return copy ? boost::re_detail::re_copy_out(out, l, last) : out;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class traits, class Allocator, class charT>
|
|
||||||
std::basic_string<charT> BOOST_REGEX_CALL reg_merge(const std::basic_string<charT>& s,
|
|
||||||
const reg_expression<charT, traits, Allocator>& e,
|
|
||||||
const charT* fmt,
|
|
||||||
bool copy = true,
|
|
||||||
unsigned int flags = match_default)
|
|
||||||
{
|
|
||||||
std::basic_string<charT> result;
|
|
||||||
boost::re_detail::string_out_iterator<std::basic_string<charT> > i(result);
|
|
||||||
reg_merge(i, s.begin(), s.end(), e, fmt, copy, flags);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace deprecated
|
|
||||||
|
|
||||||
using deprecated::query_match;
|
|
||||||
using deprecated::reg_search;
|
|
||||||
using deprecated::reg_grep;
|
|
||||||
using deprecated::reg_format;
|
|
||||||
using deprecated::reg_merge;
|
|
||||||
//using re_detail::jm_def_alloc;
|
|
||||||
using deprecated::char_regex_traits_i;
|
|
||||||
//using re_detail::re_alloc_binder;
|
|
||||||
using re_detail::padding_size;
|
|
||||||
|
|
||||||
|
|
||||||
} // namspace boost
|
|
||||||
|
|
||||||
namespace jm = boost;
|
|
||||||
|
|
||||||
#if !defined(BOOST_RE_NO_NAMESPACES) && !defined(BOOST_RE_NO_USING)
|
|
||||||
|
|
||||||
using boost::bad_expression;
|
|
||||||
template<class charT>
|
|
||||||
struct char_regex_traits : boost::regex_traits<charT>{};
|
|
||||||
using boost::deprecated::char_regex_traits_i;
|
|
||||||
using boost::regbase;
|
|
||||||
using boost::reg_expression;
|
|
||||||
using boost::deprecated::reg_match;
|
|
||||||
//using boost::reg_match_base;
|
|
||||||
using boost::sub_match;
|
|
||||||
using boost::regex;
|
|
||||||
using boost::cmatch;
|
|
||||||
#ifndef BOOST_NO_WREGEX
|
|
||||||
using boost::wregex;
|
|
||||||
using boost::wcmatch;
|
|
||||||
#endif
|
|
||||||
using boost::deprecated::reg_match;
|
|
||||||
using boost::deprecated::query_match;
|
|
||||||
using boost::deprecated::reg_search;
|
|
||||||
using boost::deprecated::reg_grep;
|
|
||||||
using boost::deprecated::reg_format;
|
|
||||||
using boost::deprecated::reg_merge;
|
|
||||||
//using boost::re_detail::jm_def_alloc;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BOOST_RE_USING_HACK
|
|
||||||
using namespace boost;
|
|
||||||
using namespace boost::deprecated;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 1998-2000
|
|
||||||
* John Maddock
|
|
||||||
*
|
|
||||||
* Use, modification and distribution are 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)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string>
|
|
||||||
#include <iostream>
|
|
||||||
#include <regex>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
regex expression("^([0-9]+)(\\-| |$)(.*)$");
|
|
||||||
|
|
||||||
// process_ftp:
|
|
||||||
// on success returns the ftp response code, and fills
|
|
||||||
// msg with the ftp response message.
|
|
||||||
int process_ftp(const char* response, std::string* msg)
|
|
||||||
{
|
|
||||||
cmatch what;
|
|
||||||
if(query_match(response, response + strlen(response), what, expression))
|
|
||||||
{
|
|
||||||
// what[0] contains the whole string
|
|
||||||
// what[1] contains the response code
|
|
||||||
// what[2] contains the separator character
|
|
||||||
// what[3] contains the text message.
|
|
||||||
if(msg)
|
|
||||||
msg->assign(what[3].first, what[3].second);
|
|
||||||
return atoi(what[1].first);
|
|
||||||
}
|
|
||||||
// failure did not match
|
|
||||||
if(msg)
|
|
||||||
msg->erase();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
std::string in, out;
|
|
||||||
while(true)
|
|
||||||
{
|
|
||||||
cout << "enter test string" << endl;
|
|
||||||
std::getline(cin, in);
|
|
||||||
if(in == "quit")
|
|
||||||
break;
|
|
||||||
int result;
|
|
||||||
result = process_ftp(in.c_str(), &out);
|
|
||||||
if(result != -1)
|
|
||||||
{
|
|
||||||
cout << "Match found:" << endl;
|
|
||||||
cout << "Response code: " << result << endl;
|
|
||||||
cout << "Message text: " << out << endl;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cout << "Match not found" << endl;
|
|
||||||
}
|
|
||||||
cout << endl;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,81 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 1998-2000
|
|
||||||
* John Maddock
|
|
||||||
*
|
|
||||||
* Use, modification and distribution are 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)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <map>
|
|
||||||
#include <regex>
|
|
||||||
|
|
||||||
// purpose:
|
|
||||||
// takes the contents of a file in the form of a string
|
|
||||||
// and searches for all the C++ class definitions, storing
|
|
||||||
// their locations in a map of strings/int's
|
|
||||||
|
|
||||||
typedef std::map<std::string, int, std::less<std::string> > map_type;
|
|
||||||
|
|
||||||
regex expression("^(template[[:space:]]*<[^;:{]+>[[:space:]]*)?(class|struct)[[:space:]]*(\\<\\w+\\>([[:blank:]]*\\([^)]*\\))?[[:space:]]*)*(\\<\\w*\\>)[[:space:]]*(<[^;:{]+>[[:space:]]*)?(\\{|:[^;\\{()]*\\{)");
|
|
||||||
|
|
||||||
void IndexClasses(map_type& m, const std::string& file)
|
|
||||||
{
|
|
||||||
std::string::const_iterator start, end;
|
|
||||||
start = file.begin();
|
|
||||||
end = file.end();
|
|
||||||
reg_match<std::string::const_iterator> what;
|
|
||||||
unsigned int flags = match_default;
|
|
||||||
while(reg_search(start, end, what, expression, flags))
|
|
||||||
{
|
|
||||||
// what[0] contains the whole string
|
|
||||||
// what[5] contains the class name.
|
|
||||||
// what[6] contains the template specialisation if any.
|
|
||||||
// add class name and position to map:
|
|
||||||
m[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =
|
|
||||||
what[5].first - file.begin();
|
|
||||||
// update search position:
|
|
||||||
start = what[0].second;
|
|
||||||
// update flags:
|
|
||||||
flags |= match_prev_avail;
|
|
||||||
flags |= ~match_not_bob;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#include <fileiter.h>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
int main(int argc, const char** argv)
|
|
||||||
{
|
|
||||||
for(int i = 1; i < argc; ++i)
|
|
||||||
{
|
|
||||||
cout << "Processing file " << argv[i] << endl;
|
|
||||||
map_type m;
|
|
||||||
mapfile f(argv[i]);
|
|
||||||
std::string text(f.begin(), f.end());
|
|
||||||
IndexClasses(m, text);
|
|
||||||
cout << m.size() << " matches found" << endl;
|
|
||||||
map_type::iterator c, d;
|
|
||||||
c = m.begin();
|
|
||||||
d = m.end();
|
|
||||||
while(c != d)
|
|
||||||
{
|
|
||||||
cout << "class \"" << (*c).first << "\" found at index: " << (*c).second << endl;
|
|
||||||
++c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,82 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 1998-2000
|
|
||||||
* John Maddock
|
|
||||||
*
|
|
||||||
* Use, modification and distribution are 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)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <map>
|
|
||||||
#include <regex>
|
|
||||||
|
|
||||||
// purpose:
|
|
||||||
// takes the contents of a file in the form of a string
|
|
||||||
// and searches for all the C++ class definitions, storing
|
|
||||||
// their locations in a map of strings/int's
|
|
||||||
|
|
||||||
typedef std::map<std::string, int, std::less<std::string> > map_type;
|
|
||||||
|
|
||||||
regex expression("^(template[[:space:]]*<[^;:{]+>[[:space:]]*)?(class|struct)[[:space:]]*(\\<\\w+\\>([[:blank:]]*\\([^)]*\\))?[[:space:]]*)*(\\<\\w*\\>)[[:space:]]*(<[^;:{]+>[[:space:]]*)?(\\{|:[^;\\{()]*\\{)");
|
|
||||||
|
|
||||||
class IndexClassesPred
|
|
||||||
{
|
|
||||||
map_type& m;
|
|
||||||
std::string::const_iterator base;
|
|
||||||
public:
|
|
||||||
IndexClassesPred(map_type& a, std::string::const_iterator b) : m(a), base(b) {}
|
|
||||||
bool operator()(const reg_match<std::string::const_iterator, regex::alloc_type>& what)
|
|
||||||
{
|
|
||||||
// what[0] contains the whole string
|
|
||||||
// what[5] contains the class name.
|
|
||||||
// what[6] contains the template specialisation if any.
|
|
||||||
// add class name and position to map:
|
|
||||||
m[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =
|
|
||||||
what[5].first - base;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void IndexClasses(map_type& m, const std::string& file)
|
|
||||||
{
|
|
||||||
std::string::const_iterator start, end;
|
|
||||||
start = file.begin();
|
|
||||||
end = file.end();
|
|
||||||
reg_grep(IndexClassesPred(m, start), start, end, expression, match_default);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#include <fileiter.h>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
int main(int argc, const char** argv)
|
|
||||||
{
|
|
||||||
for(int i = 1; i < argc; ++i)
|
|
||||||
{
|
|
||||||
cout << "Processing file " << argv[i] << endl;
|
|
||||||
map_type m;
|
|
||||||
mapfile f(argv[i]);
|
|
||||||
std::string text(f.begin(), f.end());
|
|
||||||
IndexClasses(m, text);
|
|
||||||
cout << m.size() << " matches found" << endl;
|
|
||||||
map_type::iterator c, d;
|
|
||||||
c = m.begin();
|
|
||||||
d = m.end();
|
|
||||||
while(c != d)
|
|
||||||
{
|
|
||||||
cout << "class \"" << (*c).first << "\" found at index: " << (*c).second << endl;
|
|
||||||
++c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,102 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 1998-2000
|
|
||||||
* John Maddock
|
|
||||||
*
|
|
||||||
* Use, modification and distribution are 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)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <string>
|
|
||||||
#include <iterator>
|
|
||||||
#include <regex>
|
|
||||||
#include <fileiter.h>
|
|
||||||
|
|
||||||
// purpose:
|
|
||||||
// takes the contents of a file and transform to
|
|
||||||
// syntax highlighted code in html format
|
|
||||||
|
|
||||||
regex e1, e2;
|
|
||||||
extern const char* expression_text;
|
|
||||||
extern const char* format_string;
|
|
||||||
extern const char* pre_expression;
|
|
||||||
extern const char* pre_format;
|
|
||||||
extern const char* header_text;
|
|
||||||
extern const char* footer_text;
|
|
||||||
|
|
||||||
int main(int argc, const char** argv)
|
|
||||||
{
|
|
||||||
e1.set_expression(expression_text);
|
|
||||||
e2.set_expression(pre_expression);
|
|
||||||
for(int i = 1; i < argc; ++i)
|
|
||||||
{
|
|
||||||
std::cout << "Processing file " << argv[i] << std::endl;
|
|
||||||
mapfile in(argv[i]);
|
|
||||||
std::string out_name(std::string(argv[i]) + std::string(".htm"));
|
|
||||||
std::ofstream os(out_name.c_str());
|
|
||||||
os << header_text;
|
|
||||||
// strip '<' and '>' first by outputting to a
|
|
||||||
// temporary string stream
|
|
||||||
std::ostringstream t(std::ios::out | std::ios::binary);
|
|
||||||
std::ostream_iterator<char, char> oi(t);
|
|
||||||
reg_merge(oi, in.begin(), in.end(), e2, pre_format, true);
|
|
||||||
// then output to final output stream
|
|
||||||
// adding syntax highlighting:
|
|
||||||
std::string s(t.str());
|
|
||||||
std::ostream_iterator<char, char> out(os);
|
|
||||||
reg_merge(out, s.begin(), s.end(), e1, format_string, true);
|
|
||||||
os << footer_text;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern const char* pre_expression = "(<)|(>)|\\r";
|
|
||||||
extern const char* pre_format = "(?1<)(?2>)";
|
|
||||||
|
|
||||||
|
|
||||||
const char* expression_text = // preprocessor directives: index 1
|
|
||||||
"(^[[:blank:]]*#([^\\n]*\\\\[[:space:]]+)*[^\\n]*)|"
|
|
||||||
// comment: index 3
|
|
||||||
"(//[^\\n]*|/\\*([^*]|\\*+[^*/])*\\*+/)|"
|
|
||||||
// literals: index 5
|
|
||||||
"\\<([+-]?((0x[[:xdigit:]]+)|(([[:digit:]]*\\.)?[[:digit:]]+([eE][+-]?[[:digit:]]+)?))u?((int(8|16|32|64))|L)?)\\>|"
|
|
||||||
// string literals: index 14
|
|
||||||
"('([^\\\\']|\\\\.)*'|\"([^\\\\\"]|\\\\.)*\")|"
|
|
||||||
// keywords: index 17
|
|
||||||
"\\<(__asm|__cdecl|__declspec|__export|__far16|__fastcall|__fortran|__import"
|
|
||||||
"|__pascal|__rtti|__stdcall|_asm|_cdecl|__except|_export|_far16|_fastcall"
|
|
||||||
"|__finally|_fortran|_import|_pascal|_stdcall|__thread|__try|asm|auto|bool"
|
|
||||||
"|break|case|catch|cdecl|char|class|const|const_cast|continue|default|delete"
|
|
||||||
"|do|double|dynamic_cast|else|enum|explicit|extern|false|float|for|friend|goto"
|
|
||||||
"|if|inline|int|long|mutable|namespace|new|operator|pascal|private|protected"
|
|
||||||
"|public|register|reinterpret_cast|return|short|signed|sizeof|static|static_cast"
|
|
||||||
"|struct|switch|template|this|throw|true|try|typedef|typeid|typename|union|unsigned"
|
|
||||||
"|using|virtual|void|volatile|wchar_t|while)\\>"
|
|
||||||
;
|
|
||||||
|
|
||||||
const char* format_string = "(?1<font color=\"#008040\">$&</font>)"
|
|
||||||
"(?3<I><font color=\"#000080\">$&</font></I>)"
|
|
||||||
"(?5<font color=\"#0000A0\">$&</font>)"
|
|
||||||
"(?14<font color=\"#0000FF\">$&</font>)"
|
|
||||||
"(?17<B>$&</B>)";
|
|
||||||
|
|
||||||
const char* header_text = "<HTML>\n<HEAD>\n"
|
|
||||||
"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=windows-1252\">\n"
|
|
||||||
"</HEAD>\n"
|
|
||||||
"<BODY LINK=\"#0000ff\" VLINK=\"#800080\" BGCOLOR=\"#ffff99\">\n"
|
|
||||||
"<PARA> </PARA>\n<PRE>";
|
|
||||||
|
|
||||||
const char* footer_text = "</PRE>\n</BODY>\n\n";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 1998-2000
|
|
||||||
* John Maddock
|
|
||||||
*
|
|
||||||
* Use, modification and distribution are 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)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <map>
|
|
||||||
#include <regex>
|
|
||||||
|
|
||||||
// purpose:
|
|
||||||
// takes the contents of a file in the form of a string
|
|
||||||
// and searches for all the C++ class definitions, storing
|
|
||||||
// their locations in a map of strings/int's
|
|
||||||
|
|
||||||
typedef std::map<std::string, int, std::less<std::string> > map_type;
|
|
||||||
|
|
||||||
regex expression("^(template[[:space:]]*<[^;:{]+>[[:space:]]*)?(class|struct)[[:space:]]*(\\<\\w+\\>([[:blank:]]*\\([^)]*\\))?[[:space:]]*)*(\\<\\w*\\>)[[:space:]]*(<[^;:{]+>[[:space:]]*)?(\\{|:[^;\\{()]*\\{)");
|
|
||||||
map_type class_index;
|
|
||||||
std::string::const_iterator base;
|
|
||||||
|
|
||||||
bool grep_callback(const reg_match<std::string::const_iterator, regex::alloc_type>& what)
|
|
||||||
{
|
|
||||||
// what[0] contains the whole string
|
|
||||||
// what[5] contains the class name.
|
|
||||||
// what[6] contains the template specialisation if any.
|
|
||||||
// add class name and position to map:
|
|
||||||
class_index[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =
|
|
||||||
what[5].first - base;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void IndexClasses(const std::string& file)
|
|
||||||
{
|
|
||||||
std::string::const_iterator start, end;
|
|
||||||
start = file.begin();
|
|
||||||
end = file.end();
|
|
||||||
base = start;
|
|
||||||
reg_grep(grep_callback, start, end, expression, match_default);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,97 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 1998-2000
|
|
||||||
* John Maddock
|
|
||||||
*
|
|
||||||
* Use, modification and distribution are 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)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <map>
|
|
||||||
#include <regex>
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
// purpose:
|
|
||||||
// takes the contents of a file in the form of a string
|
|
||||||
// and searches for all the C++ class definitions, storing
|
|
||||||
// their locations in a map of strings/int's
|
|
||||||
|
|
||||||
typedef std::map<std::string, int, std::less<std::string> > map_type;
|
|
||||||
|
|
||||||
class class_index
|
|
||||||
{
|
|
||||||
jm::regex expression;
|
|
||||||
map_type index;
|
|
||||||
std::string::const_iterator base;
|
|
||||||
|
|
||||||
bool grep_callback(reg_match<std::string::const_iterator, regex::alloc_type> what);
|
|
||||||
public:
|
|
||||||
map_type& get_map() { return index; }
|
|
||||||
void IndexClasses(const std::string& file);
|
|
||||||
class_index()
|
|
||||||
: index(),
|
|
||||||
expression("^(template[[:space:]]*<[^;:{]+>[[:space:]]*)?"
|
|
||||||
"(class|struct)[[:space:]]*(\\<\\w+\\>([[:blank:]]*\\([^)]*\\))?"
|
|
||||||
"[[:space:]]*)*(\\<\\w*\\>)[[:space:]]*(<[^;:{]+>[[:space:]]*)?"
|
|
||||||
"(\\{|:[^;\\{()]*\\{)"
|
|
||||||
){}
|
|
||||||
};
|
|
||||||
|
|
||||||
bool class_index::grep_callback(reg_match<std::string::const_iterator, regex::alloc_type> what)
|
|
||||||
{
|
|
||||||
// what[0] contains the whole string
|
|
||||||
// what[5] contains the class name.
|
|
||||||
// what[6] contains the template specialisation if any.
|
|
||||||
// add class name and position to map:
|
|
||||||
index[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =
|
|
||||||
what[5].first - base;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void class_index::IndexClasses(const std::string& file)
|
|
||||||
{
|
|
||||||
std::string::const_iterator start, end;
|
|
||||||
start = file.begin();
|
|
||||||
end = file.end();
|
|
||||||
base = start;
|
|
||||||
reg_grep(std::bind1st(std::mem_fun(&class_index::grep_callback), this),
|
|
||||||
start,
|
|
||||||
end,
|
|
||||||
expression,
|
|
||||||
match_default);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include <fileiter.h>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
int main(int argc, const char** argv)
|
|
||||||
{
|
|
||||||
for(int i = 1; i < argc; ++i)
|
|
||||||
{
|
|
||||||
cout << "Processing file " << argv[i] << endl;
|
|
||||||
mapfile f(argv[i]);
|
|
||||||
std::string text(f.begin(), f.end());
|
|
||||||
class_index i;
|
|
||||||
i.IndexClasses(text);
|
|
||||||
cout << i.get_map().size() << " matches found" << endl;
|
|
||||||
map_type::iterator c, d;
|
|
||||||
c = i.get_map().begin();
|
|
||||||
d = i.get_map().end();
|
|
||||||
while(c != d)
|
|
||||||
{
|
|
||||||
cout << "class \"" << (*c).first << "\" found at index: " << (*c).second << endl;
|
|
||||||
++c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,99 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright (c) 1998-2000
|
|
||||||
* John Maddock
|
|
||||||
*
|
|
||||||
* Use, modification and distribution are 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)
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <map>
|
|
||||||
#include <regex>
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
// purpose:
|
|
||||||
// takes the contents of a file in the form of a string
|
|
||||||
// and searches for all the C++ class definitions, storing
|
|
||||||
// their locations in a map of strings/int's
|
|
||||||
|
|
||||||
typedef std::map<std::string, int, std::less<std::string> > map_type;
|
|
||||||
|
|
||||||
class class_index
|
|
||||||
{
|
|
||||||
jm::regex expression;
|
|
||||||
map_type index;
|
|
||||||
std::string::const_iterator base;
|
|
||||||
typedef reg_match<std::string::const_iterator, regex::alloc_type> arg_type;
|
|
||||||
|
|
||||||
bool grep_callback(const reg_match<std::string::const_iterator, regex::alloc_type>& what);
|
|
||||||
public:
|
|
||||||
map_type& get_map() { return index; }
|
|
||||||
typedef bool (__closure* grep_callback_type)(const arg_type&);
|
|
||||||
void IndexClasses(const std::string& file);
|
|
||||||
class_index()
|
|
||||||
: index(),
|
|
||||||
expression("^(template[[:space:]]*<[^;:{]+>[[:space:]]*)?"
|
|
||||||
"(class|struct)[[:space:]]*(\\<\\w+\\>([[:blank:]]*\\([^)]*\\))?"
|
|
||||||
"[[:space:]]*)*(\\<\\w*\\>)[[:space:]]*(<[^;:{]+>[[:space:]]*)?"
|
|
||||||
"(\\{|:[^;\\{()]*\\{)"
|
|
||||||
){}
|
|
||||||
};
|
|
||||||
|
|
||||||
bool class_index::grep_callback(const reg_match<std::string::const_iterator, regex::alloc_type>& what)
|
|
||||||
{
|
|
||||||
// what[0] contains the whole string
|
|
||||||
// what[5] contains the class name.
|
|
||||||
// what[6] contains the template specialisation if any.
|
|
||||||
// add class name and position to map:
|
|
||||||
index[std::string(what[5].first, what[5].second) + std::string(what[6].first, what[6].second)] =
|
|
||||||
what[5].first - base;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void class_index::IndexClasses(const std::string& file)
|
|
||||||
{
|
|
||||||
std::string::const_iterator start, end;
|
|
||||||
start = file.begin();
|
|
||||||
end = file.end();
|
|
||||||
base = start;
|
|
||||||
class_index::grep_callback_type cl = &(this->grep_callback);
|
|
||||||
reg_grep(cl,
|
|
||||||
start,
|
|
||||||
end,
|
|
||||||
expression,
|
|
||||||
match_default);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include <fileiter.h>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
int main(int argc, const char** argv)
|
|
||||||
{
|
|
||||||
for(int i = 1; i < argc; ++i)
|
|
||||||
{
|
|
||||||
cout << "Processing file " << argv[i] << endl;
|
|
||||||
mapfile f(argv[i]);
|
|
||||||
std::string text(f.begin(), f.end());
|
|
||||||
class_index i;
|
|
||||||
i.IndexClasses(text);
|
|
||||||
cout << i.get_map().size() << " matches found" << endl;
|
|
||||||
map_type::iterator c, d;
|
|
||||||
c = i.get_map().begin();
|
|
||||||
d = i.get_map().end();
|
|
||||||
while(c != d)
|
|
||||||
{
|
|
||||||
cout << "class \"" << (*c).first << "\" found at index: " << (*c).second << endl;
|
|
||||||
++c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -26,20 +26,20 @@
|
|||||||
#ifdef _DLL_CPPLIB
|
#ifdef _DLL_CPPLIB
|
||||||
namespace std{
|
namespace std{
|
||||||
template _CRTIMP2 bool __cdecl operator==(
|
template _CRTIMP2 bool __cdecl operator==(
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
||||||
template _CRTIMP2 bool __cdecl operator==(
|
template _CRTIMP2 bool __cdecl operator==(
|
||||||
const unsigned short *,
|
const unsigned short *,
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
||||||
template _CRTIMP2 bool __cdecl operator==(
|
template _CRTIMP2 bool __cdecl operator==(
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
||||||
const unsigned short *);
|
const unsigned short *);
|
||||||
template _CRTIMP2 bool __cdecl operator<(
|
template _CRTIMP2 bool __cdecl operator<(
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
||||||
template _CRTIMP2 bool __cdecl operator>(
|
template _CRTIMP2 bool __cdecl operator>(
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&,
|
||||||
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
const basic_string<unsigned short, char_traits<unsigned short>, allocator<unsigned short> >&);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::l
|
|||||||
std::string name;
|
std::string name;
|
||||||
const wchar_t* p0 = p1;
|
const wchar_t* p0 = p1;
|
||||||
while(p0 != p2)
|
while(p0 != p2)
|
||||||
name.append(1, char(*p0++));
|
name.append(1, char(*p0++));
|
||||||
#endif
|
#endif
|
||||||
name = ::boost::re_detail::lookup_default_collate_name(name);
|
name = ::boost::re_detail::lookup_default_collate_name(name);
|
||||||
#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\
|
#if !defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS)\
|
||||||
@ -193,13 +193,13 @@ c_regex_traits<wchar_t>::string_type BOOST_REGEX_CALL c_regex_traits<wchar_t>::l
|
|||||||
#else
|
#else
|
||||||
if(name.size())
|
if(name.size())
|
||||||
{
|
{
|
||||||
string_type result;
|
string_type result;
|
||||||
typedef std::string::const_iterator iter;
|
typedef std::string::const_iterator iter;
|
||||||
iter b = name.begin();
|
iter b = name.begin();
|
||||||
iter e = name.end();
|
iter e = name.end();
|
||||||
while(b != e)
|
while(b != e)
|
||||||
result.append(1, wchar_t(*b++));
|
result.append(1, wchar_t(*b++));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(p2 - p1 == 1)
|
if(p2 - p1 == 1)
|
||||||
|
@ -153,7 +153,7 @@ void test_options()
|
|||||||
TEST_REGEX_SEARCH("#rhubarb\r\n abcd", perl|mod_x, "abcd", match_default, make_array(0, 4, -2, -2));
|
TEST_REGEX_SEARCH("#rhubarb\r\n abcd", perl|mod_x, "abcd", match_default, make_array(0, 4, -2, -2));
|
||||||
TEST_REGEX_SEARCH("^abcd#rhubarb", perl|mod_x, "abcd", match_default, make_array(0, 4, -2, -2));
|
TEST_REGEX_SEARCH("^abcd#rhubarb", perl|mod_x, "abcd", match_default, make_array(0, 4, -2, -2));
|
||||||
TEST_REGEX_SEARCH("^abcd#rhubarb", perl, "abcd#rhubarb", match_default, make_array(0, 12, -2, -2));
|
TEST_REGEX_SEARCH("^abcd#rhubarb", perl, "abcd#rhubarb", match_default, make_array(0, 12, -2, -2));
|
||||||
TEST_REGEX_SEARCH("^a b\n\n c", perl|mod_x, "abc", match_default, make_array(0, 3, -2, -2));
|
TEST_REGEX_SEARCH("^a b\n\n c", perl|mod_x, "abc", match_default, make_array(0, 3, -2, -2));
|
||||||
|
|
||||||
TEST_REGEX_SEARCH("(?(?=[^a-z]+[a-z]) \\d{2}-[a-z]{3}-\\d{2} | \\d{2}-\\d{2}-\\d{2} ) ", perl|mod_x, "12-sep-98", match_default, make_array(0, 9, -2, -2));
|
TEST_REGEX_SEARCH("(?(?=[^a-z]+[a-z]) \\d{2}-[a-z]{3}-\\d{2} | \\d{2}-\\d{2}-\\d{2} ) ", perl|mod_x, "12-sep-98", match_default, make_array(0, 9, -2, -2));
|
||||||
TEST_REGEX_SEARCH("(?(?=[^a-z]+[a-z]) \\d{2}-[a-z]{3}-\\d{2} | \\d{2}-\\d{2}-\\d{2} ) ", perl|mod_x, "12-09-98", match_default, make_array(0, 8, -2, -2));
|
TEST_REGEX_SEARCH("(?(?=[^a-z]+[a-z]) \\d{2}-[a-z]{3}-\\d{2} | \\d{2}-\\d{2}-\\d{2} ) ", perl|mod_x, "12-09-98", match_default, make_array(0, 8, -2, -2));
|
||||||
|
@ -240,11 +240,11 @@ void test_tricky_cases2()
|
|||||||
void test_tricky_cases3()
|
void test_tricky_cases3()
|
||||||
{
|
{
|
||||||
using namespace boost::regex_constants;
|
using namespace boost::regex_constants;
|
||||||
TEST_REGEX_SEARCH("((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)?", perl, "0xFF", match_default, make_array(0, 4, 0, 4, 0, 4, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2));
|
TEST_REGEX_SEARCH("((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)?", perl, "0xFF", match_default, make_array(0, 4, 0, 4, 0, 4, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2));
|
||||||
TEST_REGEX_SEARCH("((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)?", perl, "35", match_default, make_array(0, 2, 0, 2, -1, -1, 0, 2, -1, -1, -1, -1, -1, -1, -2, -2));
|
TEST_REGEX_SEARCH("((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)?", perl, "35", match_default, make_array(0, 2, 0, 2, -1, -1, 0, 2, -1, -1, -1, -1, -1, -1, -2, -2));
|
||||||
TEST_REGEX_SEARCH("((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)?", perl, "0xFFu", match_default, make_array(0, 5, 0, 4, 0, 4, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2));
|
TEST_REGEX_SEARCH("((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)?", perl, "0xFFu", match_default, make_array(0, 5, 0, 4, 0, 4, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2));
|
||||||
TEST_REGEX_SEARCH("((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)?", perl, "0xFFL", match_default, make_array(0, 5, 0, 4, 0, 4, -1, -1, 4, 5, -1, -1, -1, -1, -2, -2));
|
TEST_REGEX_SEARCH("((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)?", perl, "0xFFL", match_default, make_array(0, 5, 0, 4, 0, 4, -1, -1, 4, 5, -1, -1, -1, -1, -2, -2));
|
||||||
TEST_REGEX_SEARCH("((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)?", perl, "0xFFFFFFFFFFFFFFFFuint64", match_default, make_array(0, 24, 0, 18, 0, 18, -1, -1, 19, 24, 19, 24, 22, 24, -2, -2));
|
TEST_REGEX_SEARCH("((0x[[:xdigit:]]+)|([[:digit:]]+))u?((int(8|16|32|64))|L)?", perl, "0xFFFFFFFFFFFFFFFFuint64", match_default, make_array(0, 24, 0, 18, 0, 18, -1, -1, 19, 24, 19, 24, 22, 24, -2, -2));
|
||||||
// strings:
|
// strings:
|
||||||
TEST_REGEX_SEARCH("'([^\\\\']|\\\\.)*'", perl, "'\\x3A'", match_default, make_array(0, 6, 4, 5, -2, -2));
|
TEST_REGEX_SEARCH("'([^\\\\']|\\\\.)*'", perl, "'\\x3A'", match_default, make_array(0, 6, 4, 5, -2, -2));
|
||||||
TEST_REGEX_SEARCH("'([^\\\\']|\\\\.)*'", perl, "'\\''", match_default, make_array(0, 4, 1, 3, -2, -2));
|
TEST_REGEX_SEARCH("'([^\\\\']|\\\\.)*'", perl, "'\\''", match_default, make_array(0, 4, 1, 3, -2, -2));
|
||||||
|
Reference in New Issue
Block a user