Added boost header

This commit is contained in:
Christophe Riccio
2012-01-08 01:26:07 +00:00
parent 9c3faaca40
commit c7d752cdf8
8946 changed files with 1732316 additions and 0 deletions

View File

@@ -0,0 +1,161 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2011 Hartmut Kaiser. 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(CPP_IFBLOCK_HPP_D4676B36_00C5_41F4_BC9F_9CBBAE3B8006_INCLUDED)
#define CPP_IFBLOCK_HPP_D4676B36_00C5_41F4_BC9F_9CBBAE3B8006_INCLUDED
#include <stack>
#include <boost/wave/wave_config.hpp>
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace util {
///////////////////////////////////////////////////////////////////////////////
// the class if_blocks handles recursive conditional compilation contexts
class if_block
{
public:
if_block() :
status(true), some_part_status(true),
enclosing_status(true), is_in_else(false)
{
}
if_block(bool status_, bool enclosing_status_) :
status(status_),
some_part_status(status_),
enclosing_status(enclosing_status_),
is_in_else(false)
{
}
void set_status(bool status_)
{
status = status_;
if (status_)
some_part_status = true;
}
bool get_status() const { return status; }
bool get_some_part_status() const { return some_part_status; }
bool get_enclosing_status() const { return enclosing_status; }
bool get_in_else() const { return is_in_else; }
void set_in_else() { is_in_else = true; }
private:
bool status; // Current block is true
bool some_part_status; // One of the preceding or current #if/#elif was true
bool enclosing_status; // Enclosing #if block is true
bool is_in_else; // Inside the #else part
};
///////////////////////////////////////////////////////////////////////////////
// stack of conditional compilation contexts
class if_block_stack
: private std::stack<if_block>
{
public:
typedef std::stack<if_block>::size_type size_type;
void enter_if_block(bool new_status)
{
// If enclosing block is false, then this block is also false
bool enclosing_status = get_status();
this->push (value_type (new_status && enclosing_status, enclosing_status));
}
bool enter_elif_block(bool new_status)
{
if (!is_inside_ifpart())
return false; // #elif without matching #if
if (get_enclosing_status()) {
if (get_status()) {
// entered a (false) #elif block from a true block
this->top().set_status(false);
}
else if (new_status && !this->top().get_some_part_status()) {
// Entered true #elif block and no previous block was true
this->top().set_status(new_status);
}
}
return true;
}
bool enter_else_block()
{
if (!is_inside_ifpart())
return false; // #else without matching #if
if (get_enclosing_status()) {
if (!this->top().get_some_part_status()) {
// Entered (true) #else block and no previous block was true
this->top().set_status(true);
}
else if (get_status()) {
// Entered (false) #else block from true block
this->top().set_status(false);
}
// Set else flag
this->top().set_in_else();
}
return true;
}
bool exit_if_block()
{
if (0 == this->size())
return false; // #endif without matching #if
this->pop();
return true;
}
// return, whether the top (innermost) condition is true or false
bool get_status() const
{
return 0 == this->size() || this->top().get_status();
}
bool get_some_part_status() const
{
return 0 == this->size() || this->top().get_some_part_status();
}
bool get_enclosing_status() const
{
return 0 == this->size() || this->top().get_enclosing_status();
}
size_type get_if_block_depth() const { return this->size(); }
protected:
bool is_inside_ifpart() const
{
return 0 != this->size() && !this->top().get_in_else();
}
bool is_inside_elsepart() const
{
return 0 != this->size() && this->top().get_in_else();
}
};
///////////////////////////////////////////////////////////////////////////////
} // namespace util
} // namespace wave
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(CPP_IFBLOCK_HPP_D4676B36_00C5_41F4_BC9F_9CBBAE3B8006_INCLUDED)

View File

@@ -0,0 +1,553 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2011 Hartmut Kaiser. 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(CPP_INCLUDE_PATHS_HPP_AF620DA4_B3D2_4221_AD91_8A1ABFFB6944_INCLUDED)
#define CPP_INCLUDE_PATHS_HPP_AF620DA4_B3D2_4221_AD91_8A1ABFFB6944_INCLUDED
#include <string>
#include <list>
#include <utility>
#include <boost/wave/wave_config.hpp>
#include <boost/wave/util/filesystem_compatibility.hpp>
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>
#endif
#if BOOST_WAVE_SERIALIZATION != 0
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/utility.hpp>
#include <boost/serialization/collections_save_imp.hpp>
#include <boost/serialization/collections_load_imp.hpp>
#include <boost/serialization/split_free.hpp>
#endif
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace wave { namespace util {
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
///////////////////////////////////////////////////////////////////////////////
// Tags for accessing both sides of a bidirectional map
struct from {};
struct to {};
///////////////////////////////////////////////////////////////////////////////
// The class template bidirectional_map wraps the specification
// of a bidirectional map based on multi_index_container.
template<typename FromType, typename ToType>
struct bidirectional_map
{
typedef std::pair<FromType, ToType> value_type;
#if defined(BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS) || \
(defined(BOOST_MSVC) && \
( (BOOST_MSVC < 1300) || (BOOST_MSVC == 1600) )) || \
(defined(BOOST_INTEL_CXX_VERSION) && \
(defined(_MSC_VER) && (BOOST_INTEL_CXX_VERSION <= 700)))
BOOST_STATIC_CONSTANT(unsigned, from_offset = offsetof(value_type, first));
BOOST_STATIC_CONSTANT(unsigned, to_offset = offsetof(value_type, second));
typedef boost::multi_index::multi_index_container<
value_type,
boost::multi_index::indexed_by<
boost::multi_index::ordered_unique<
boost::multi_index::tag<from>,
boost::multi_index::member_offset<value_type, FromType, from_offset>
>,
boost::multi_index::ordered_non_unique<
boost::multi_index::tag<to>,
boost::multi_index::member_offset<value_type, ToType, to_offset>
>
>
> type;
#else
typedef boost::multi_index::multi_index_container<
value_type,
boost::multi_index::indexed_by<
boost::multi_index::ordered_unique<
boost::multi_index::tag<from>,
boost::multi_index::member<value_type, FromType, &value_type::first>
>,
boost::multi_index::ordered_non_unique<
boost::multi_index::tag<to>,
boost::multi_index::member<value_type, ToType, &value_type::second>
>
>
> type;
#endif
};
#endif // BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
#if BOOST_WAVE_SERIALIZATION != 0
struct load_filepos
{
static unsigned int get_line() { return 0; }
static unsigned int get_column() { return 0; }
static std::string get_file() { return "<loading-state>"; }
};
#endif
///////////////////////////////////////////////////////////////////////////////
//
// include_paths - controlling the include path search order
//
// General notes:
//
// Any directories specified with the 'add_include_path()' function before
// the function 'set_sys_include_delimiter()' is called are searched only
// for the case of '#include "file"' directives, they are not searched for
// '#include <file>' directives. If additional directories are specified
// with the 'add_include_path()' function after a call to the function
// 'set_sys_include_delimiter()', these directories are searched for all
// '#include' directives.
//
// In addition, a call to the function 'set_sys_include_delimiter()'
// inhibits the use of the current directory as the first search directory
// for '#include "file"' directives. Therefore, the current directory is
// searched only if it is requested explicitly with a call to the function
// 'add_include_path(".")'.
//
// Calling both functions, the 'set_sys_include_delimiter()' and
// 'add_include_path(".")' allows you to control precisely which
// directories are searched before the current one and which are searched
// after.
//
///////////////////////////////////////////////////////////////////////////////
class include_paths
{
private:
typedef std::list<std::pair<boost::filesystem::path, std::string> >
include_list_type;
typedef include_list_type::value_type include_value_type;
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
typedef bidirectional_map<std::string, std::string>::type
pragma_once_set_type;
#endif
public:
include_paths()
: was_sys_include_path(false),
current_dir(initial_path()),
current_rel_dir(initial_path())
{}
bool add_include_path(char const *path_, bool is_system = false)
{
return add_include_path(path_, (is_system || was_sys_include_path) ?
system_include_paths : user_include_paths);
}
void set_sys_include_delimiter() { was_sys_include_path = true; }
bool find_include_file (std::string &s, std::string &dir, bool is_system,
char const *current_file) const;
void set_current_directory(char const *path_);
boost::filesystem::path get_current_directory() const
{ return current_dir; }
protected:
bool find_include_file (std::string &s, std::string &dir,
include_list_type const &pathes, char const *) const;
bool add_include_path(char const *path_, include_list_type &pathes_);
private:
include_list_type user_include_paths;
include_list_type system_include_paths;
bool was_sys_include_path; // saw a set_sys_include_delimiter()
boost::filesystem::path current_dir;
boost::filesystem::path current_rel_dir;
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
public:
bool has_pragma_once(std::string const &filename)
{
using boost::multi_index::get;
return get<from>(pragma_once_files).find(filename) != pragma_once_files.end();
}
bool add_pragma_once_header(std::string const &filename,
std::string const& guard_name)
{
typedef pragma_once_set_type::value_type value_type;
return pragma_once_files.insert(value_type(filename, guard_name)).second;
}
bool remove_pragma_once_header(std::string const& guard_name)
{
typedef pragma_once_set_type::index_iterator<to>::type to_iterator;
typedef std::pair<to_iterator, to_iterator> range_type;
range_type r = pragma_once_files.get<to>().equal_range(guard_name);
if (r.first != r.second) {
using boost::multi_index::get;
get<to>(pragma_once_files).erase(r.first, r.second);
return true;
}
return false;
}
private:
pragma_once_set_type pragma_once_files;
#endif
#if BOOST_WAVE_SERIALIZATION != 0
public:
BOOST_STATIC_CONSTANT(unsigned int, version = 0x10);
BOOST_STATIC_CONSTANT(unsigned int, version_mask = 0x0f);
private:
friend class boost::serialization::access;
template<typename Archive>
void save(Archive & ar, const unsigned int version) const
{
using namespace boost::serialization;
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
ar & make_nvp("pragma_once_files", pragma_once_files);
#endif
ar & make_nvp("user_include_paths", user_include_paths);
ar & make_nvp("system_include_paths", system_include_paths);
ar & make_nvp("was_sys_include_path", was_sys_include_path);
}
template<typename Archive>
void load(Archive & ar, const unsigned int loaded_version)
{
using namespace boost::serialization;
if (version != (loaded_version & ~version_mask)) {
BOOST_WAVE_THROW(preprocess_exception, incompatible_config,
"cpp_include_path state version", load_filepos());
return;
}
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
ar & make_nvp("pragma_once_files", pragma_once_files);
#endif
// verify that the old include paths match the current ones
include_list_type user_paths, system_paths;
ar & make_nvp("user_include_paths", user_paths);
ar & make_nvp("system_include_paths", system_paths);
if (user_paths != user_include_paths)
{
BOOST_WAVE_THROW(preprocess_exception, incompatible_config,
"user include paths", load_filepos());
return;
}
if (system_paths != system_include_paths)
{
BOOST_WAVE_THROW(preprocess_exception, incompatible_config,
"system include paths", load_filepos());
return;
}
ar & make_nvp("was_sys_include_path", was_sys_include_path);
}
BOOST_SERIALIZATION_SPLIT_MEMBER()
#endif
};
///////////////////////////////////////////////////////////////////////////////
// Add an include path to one of the search lists (user include path or system
// include path).
inline
bool include_paths::add_include_path (
char const *path_, include_list_type &pathes_)
{
namespace fs = boost::filesystem;
if (path_) {
fs::path newpath = util::complete_path(create_path(path_), current_dir);
if (!fs::exists(newpath) || !fs::is_directory(newpath)) {
// the given path does not form a name of a valid file system directory
// item
return false;
}
pathes_.push_back (include_value_type(newpath, path_));
return true;
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
// Find an include file by traversing the list of include directories
inline
bool include_paths::find_include_file (std::string &s, std::string &dir,
include_list_type const &pathes, char const *current_file) const
{
namespace fs = boost::filesystem;
typedef include_list_type::const_iterator const_include_list_iter_t;
const_include_list_iter_t it = pathes.begin();
const_include_list_iter_t include_paths_end = pathes.end();
#if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
if (0 != current_file) {
// re-locate the directory of the current file (#include_next handling)
// #include_next does not distinguish between <file> and "file"
// inclusion, nor does it check that the file you specify has the same
// name as the current file. It simply looks for the file named, starting
// with the directory in the search path after the one where the current
// file was found.
fs::path file_path (create_path(current_file));
for (/**/; it != include_paths_end; ++it) {
fs::path currpath (create_path((*it).first.string()));
if (std::equal(currpath.begin(), currpath.end(), file_path.begin()))
{
++it; // start searching with the next directory
break;
}
}
}
#endif
for (/**/; it != include_paths_end; ++it) {
fs::path currpath (create_path(s));
if (!currpath.has_root_directory()) {
currpath = create_path((*it).first.string());
currpath /= create_path(s); // append filename
}
if (fs::exists(currpath)) {
fs::path dirpath (create_path(s));
if (!dirpath.has_root_directory()) {
dirpath = create_path((*it).second);
dirpath /= create_path(s);
}
dir = dirpath.string();
s = normalize(currpath).string(); // found the required file
return true;
}
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
// Find an include file by searching the user and system includes in the
// correct sequence (as it was configured by the user of the driver program)
inline bool
include_paths::find_include_file (std::string &s, std::string &dir,
bool is_system, char const *current_file) const
{
namespace fs = boost::filesystem;
// if not system include (<...>), then search current directory first
if (!is_system) {
if (!was_sys_include_path) { // set_sys_include_delimiter() not called
// first have a look at the current directory
fs::path currpath (create_path(s));
if (!currpath.has_root_directory()) {
currpath = create_path(current_dir.string());
currpath /= create_path(s);
}
if (fs::exists(currpath) && 0 == current_file) {
// if 0 != current_path (#include_next handling) it can't be
// the file in the current directory
fs::path dirpath (create_path(s));
if (!dirpath.has_root_directory()) {
dirpath = create_path(current_rel_dir.string());
dirpath /= create_path(s);
}
dir = dirpath.string();
s = normalize(currpath).string(); // found in local directory
return true;
}
// iterate all user include file directories to find the file
if (find_include_file(s, dir, user_include_paths, current_file))
return true;
// ... fall through
}
else {
// if set_sys_include_delimiter() was called, then user include files
// are searched in the user search path only
return find_include_file(s, dir, user_include_paths, current_file);
}
// if nothing found, fall through
// ...
}
// iterate all system include file directories to find the file
return find_include_file (s, dir, system_include_paths, current_file);
}
///////////////////////////////////////////////////////////////////////////////
// Set current directory from a given file name
inline bool
as_relative_to(boost::filesystem::path const& path,
boost::filesystem::path const& base, boost::filesystem::path& result)
{
if (path.has_root_path()) {
if (path.root_path() == base.root_path())
return as_relative_to(path.relative_path(), base.relative_path(), result);
result = path; // that's our result
}
else {
if (base.has_root_path()) {
// cannot find relative path from a relative path and a rooted base
return false;
}
else {
typedef boost::filesystem::path::const_iterator path_iterator;
path_iterator path_it = path.begin();
path_iterator base_it = base.begin();
while (path_it != path.end() && base_it != base.end() ) {
if (*path_it != *base_it)
break;
++path_it; ++base_it;
}
for (/**/; base_it != base.end(); ++base_it)
result /= "..";
for (/**/; path_it != path.end(); ++path_it)
result /= *path_it;
}
}
return true;
}
///////////////////////////////////////////////////////////////////////////////
inline
void include_paths::set_current_directory(char const *path_)
{
namespace fs = boost::filesystem;
fs::path filepath (create_path(path_));
fs::path filename = util::complete_path(filepath, current_dir);
if (fs::exists(filename) && fs::is_directory(filename)) {
current_rel_dir.clear();
if (!as_relative_to(filepath, current_dir, current_rel_dir))
current_rel_dir = filepath;
current_dir = filename;
}
else {
current_rel_dir.clear();
if (!as_relative_to(branch_path(filepath), current_dir, current_rel_dir))
current_rel_dir = branch_path(filepath);
current_dir = branch_path(filename);
}
}
///////////////////////////////////////////////////////////////////////////////
}}} // namespace boost::wave::util
#if BOOST_WAVE_SERIALIZATION != 0
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace serialization {
///////////////////////////////////////////////////////////////////////////////
// Serialization support for boost::filesystem::path
template<class Archive>
inline void save (Archive & ar, boost::filesystem::path const& p,
const unsigned int /* file_version */)
{
using namespace boost::serialization;
std::string path_str(p.native_file_string());
ar & make_nvp("filepath", path_str);
}
template<class Archive>
inline void load (Archive & ar, boost::filesystem::path &p,
const unsigned int /* file_version */)
{
using namespace boost::serialization;
std::string path_str;
ar & make_nvp("filepath", path_str);
p = wave::util::create_path(path_str);
}
// split non-intrusive serialization function member into separate
// non intrusive save/load member functions
template<class Archive>
inline void serialize (Archive & ar, boost::filesystem::path &p,
const unsigned int file_version)
{
boost::serialization::split_free(ar, p, file_version);
}
///////////////////////////////////////////////////////////////////////////////
// Serialization support for the used multi_index
template<class Archive>
inline void save (Archive & ar,
const typename boost::wave::util::bidirectional_map<
std::string, std::string
>::type &t,
const unsigned int /* file_version */)
{
boost::serialization::stl::save_collection<
Archive,
typename boost::wave::util::bidirectional_map<
std::string, std::string
>::type
>(ar, t);
}
template<class Archive>
inline void load (Archive & ar,
typename boost::wave::util::bidirectional_map<std::string, std::string>::type &t,
const unsigned int /* file_version */)
{
typedef typename boost::wave::util::bidirectional_map<
std::string, std::string
>::type map_type;
boost::serialization::stl::load_collection<
Archive, map_type,
boost::serialization::stl::archive_input_unique<Archive, map_type>,
boost::serialization::stl::no_reserve_imp<map_type>
>(ar, t);
}
// split non-intrusive serialization function member into separate
// non intrusive save/load member functions
template<class Archive>
inline void serialize (Archive & ar,
typename boost::wave::util::bidirectional_map<
std::string, std::string
>::type &t,
const unsigned int file_version)
{
boost::serialization::split_free(ar, t, file_version);
}
///////////////////////////////////////////////////////////////////////////////
}} // namespace boost::serialization
BOOST_CLASS_VERSION(boost::wave::util::include_paths,
boost::wave::util::include_paths::version);
#endif // BOOST_WAVE_SERIALIZATION != 0
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(CPP_INCLUDE_PATHS_HPP_AF620DA4_B3D2_4221_AD91_8A1ABFFB6944_INCLUDED)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,288 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Definition of the predefined macros
http://www.boost.org/
Copyright (c) 2001-2011 Hartmut Kaiser. 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(CPP_MACROMAP_PREDEF_HPP_HK041119)
#define CPP_MACROMAP_PREDEF_HPP_HK041119
#include <cstdio>
#include <boost/assert.hpp>
#include <boost/wave/wave_config.hpp>
#include <boost/wave/wave_config_constant.hpp>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/util/time_conversion_helper.hpp> // time_conversion_helper
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
//
// This file contains the definition of functions needed for the management
// of static and dynamic predefined macros, such as __DATE__, __TIME__ etc.
//
// Note: __FILE__, __LINE__ and __INCLUDE_LEVEL__ are handled in the file
// cpp_macromap.hpp.
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace util {
///////////////////////////////////////////////////////////////////////////
class predefined_macros
{
typedef BOOST_WAVE_STRINGTYPE string_type;
public:
// list of static predefined macros
struct static_macros {
char const *name;
boost::wave::token_id token_id;
char const *value;
};
// list of dynamic predefined macros
struct dynamic_macros {
char const *name;
boost::wave::token_id token_id;
string_type (predefined_macros:: *generator)() const;
};
private:
boost::wave::util::time_conversion_helper compilation_time_;
string_type datestr_; // __DATE__
string_type timestr_; // __TIME__
string_type version_; // __SPIRIT_PP_VERSION__/__WAVE_VERSION__
string_type versionstr_; // __SPIRIT_PP_VERSION_STR__/__WAVE_VERSION_STR__
protected:
void reset_datestr()
{
static const char *const monthnames[] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
// for some systems sprintf, time_t etc. is in namespace std
using namespace std;
time_t tt = time(0);
struct tm *tb = 0;
if (tt != (time_t)-1) {
char buffer[sizeof("\"Oct 11 1347\"")+1];
tb = localtime (&tt);
sprintf (buffer, "\"%s %2d %4d\"",
monthnames[tb->tm_mon], tb->tm_mday, tb->tm_year + 1900);
datestr_ = buffer;
}
else {
datestr_ = "\"??? ?? ????\"";
}
}
void reset_timestr()
{
// for some systems sprintf, time_t etc. is in namespace std
using namespace std;
time_t tt = time(0);
struct tm *tb = 0;
if (tt != (time_t)-1) {
char buffer[sizeof("\"12:34:56\"")+1];
tb = localtime (&tt);
sprintf (buffer, "\"%02d:%02d:%02d\"", tb->tm_hour,
tb->tm_min, tb->tm_sec);
timestr_ = buffer;
}
else {
timestr_ = "\"??:??:??\"";
}
}
void reset_version()
{
char buffer[sizeof("0x00000000")+1];
// for some systems sprintf, time_t etc. is in namespace std
using namespace std;
// calculate the number of days since Dec 13 2001
// (the day the Wave project was started)
tm first_day;
using namespace std; // for some systems memset is in namespace std
memset (&first_day, 0, sizeof(tm));
first_day.tm_mon = 11; // Dec
first_day.tm_mday = 13; // 13
first_day.tm_year = 101; // 2001
long seconds = long(difftime(compilation_time_.get_time(), mktime(&first_day)));
sprintf(buffer, "0x%02d%1d%1d%04ld", BOOST_WAVE_VERSION_MAJOR,
BOOST_WAVE_VERSION_MINOR, BOOST_WAVE_VERSION_SUBMINOR,
seconds/(3600*24));
version_ = buffer;
}
void reset_versionstr()
{
char buffer[sizeof("\"00.00.00.0000 \"")+sizeof(BOOST_PLATFORM)+sizeof(BOOST_COMPILER)+4];
// for some systems sprintf, time_t etc. is in namespace std
using namespace std;
// calculate the number of days since Dec 13 2001
// (the day the Wave project was started)
tm first_day;
memset (&first_day, 0, sizeof(tm));
first_day.tm_mon = 11; // Dec
first_day.tm_mday = 13; // 13
first_day.tm_year = 101; // 2001
long seconds = long(difftime(compilation_time_.get_time(), mktime(&first_day)));
sprintf(buffer, "\"%d.%d.%d.%ld [%s/%s]\"", BOOST_WAVE_VERSION_MAJOR,
BOOST_WAVE_VERSION_MINOR, BOOST_WAVE_VERSION_SUBMINOR,
seconds/(3600*24), BOOST_PLATFORM, BOOST_COMPILER);
versionstr_ = buffer;
}
// dynamic predefined macros
string_type get_date() const { return datestr_; } // __DATE__
string_type get_time() const { return timestr_; } // __TIME__
// __SPIRIT_PP__/__WAVE__
string_type get_version() const
{
char buffer[sizeof("0x0000")+1];
using namespace std; // for some systems sprintf is in namespace std
sprintf(buffer, "0x%02d%1d%1d", BOOST_WAVE_VERSION_MAJOR,
BOOST_WAVE_VERSION_MINOR, BOOST_WAVE_VERSION_SUBMINOR);
return buffer;
}
// __WAVE_CONFIG__
string_type get_config() const
{
char buffer[sizeof("0x00000000")+1];
using namespace std; // for some systems sprintf is in namespace std
sprintf(buffer, "0x%08x", BOOST_WAVE_CONFIG);
return buffer;
}
public:
predefined_macros()
: compilation_time_(__DATE__ " " __TIME__)
{
reset();
reset_version();
reset_versionstr();
}
void reset()
{
reset_datestr();
reset_timestr();
}
// __SPIRIT_PP_VERSION__/__WAVE_VERSION__
string_type get_fullversion() const { return version_; }
// __SPIRIT_PP_VERSION_STR__/__WAVE_VERSION_STR__
string_type get_versionstr() const { return versionstr_; }
// C++ mode
static_macros const& static_data_cpp(std::size_t i) const
{
static static_macros data[] = {
{ "__STDC__", T_INTLIT, "1" },
{ "__cplusplus", T_INTLIT, "199711L" },
{ 0, T_EOF, 0 }
};
BOOST_ASSERT(i < sizeof(data)/sizeof(data[0]));
return data[i];
}
#if BOOST_WAVE_SUPPORT_CPP0X != 0
// C++0x mode
static_macros const& static_data_cpp0x(std::size_t i) const
{
static static_macros data[] = {
{ "__STDC__", T_INTLIT, "1" },
{ "__cplusplus", T_INTLIT, "201103L" },
{ "__STDC_VERSION__", T_INTLIT, "199901L" },
{ "__STDC_HOSTED__", T_INTLIT, "0" },
{ "__WAVE_HAS_VARIADICS__", T_INTLIT, "1" },
{ 0, T_EOF, 0 }
};
BOOST_ASSERT(i < sizeof(data)/sizeof(data[0]));
return data[i];
}
#endif
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
// C99 mode
static_macros const& static_data_c99(std::size_t i) const
{
static static_macros data[] = {
{ "__STDC__", T_INTLIT, "1" },
{ "__STDC_VERSION__", T_INTLIT, "199901L" },
{ "__STDC_HOSTED__", T_INTLIT, "0" },
{ "__WAVE_HAS_VARIADICS__", T_INTLIT, "1" },
{ 0, T_EOF, 0 }
};
BOOST_ASSERT(i < sizeof(data)/sizeof(data[0]));
return data[i];
}
#endif
dynamic_macros const& dynamic_data(std::size_t i) const
{
static dynamic_macros data[] = {
{ "__DATE__", T_STRINGLIT, &predefined_macros::get_date },
{ "__TIME__", T_STRINGLIT, &predefined_macros::get_time },
{ "__SPIRIT_PP__", T_INTLIT, &predefined_macros::get_version },
{ "__SPIRIT_PP_VERSION__", T_INTLIT, &predefined_macros::get_fullversion },
{ "__SPIRIT_PP_VERSION_STR__", T_STRINGLIT, &predefined_macros::get_versionstr },
{ "__WAVE__", T_INTLIT, &predefined_macros::get_version },
{ "__WAVE_VERSION__", T_INTLIT, &predefined_macros::get_fullversion },
{ "__WAVE_VERSION_STR__", T_STRINGLIT, &predefined_macros::get_versionstr },
{ "__WAVE_CONFIG__", T_INTLIT, &predefined_macros::get_config },
{ 0, T_EOF, 0 }
};
BOOST_ASSERT(i < sizeof(data)/sizeof(data[0]));
return data[i];
}
}; // predefined_macros
///////////////////////////////////////////////////////////////////////////////
} // namespace util
} // namespace wave
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(CPP_MACROMAP_PREDEF_HPP_HK041119)

View File

@@ -0,0 +1,575 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Token sequence analysis and transformation helper functions
http://www.boost.org/
Copyright (c) 2001-2011 Hartmut Kaiser. 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(CPP_MACROMAP_UTIL_HPP_HK041119)
#define CPP_MACROMAP_UTIL_HPP_HK041119
#include <boost/assert.hpp>
#include <boost/wave/wave_config.hpp>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/util/unput_queue_iterator.hpp>
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
//
// This file contains the definition of several token sequence analyze
// and transformation utility functions needed during macro handling.
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace util {
///////////////////////////////////////////////////////////////////////////////
namespace on_exit {
///////////////////////////////////////////////////////////////////////////
//
// On destruction pop the first element of the list given as the argument
//
///////////////////////////////////////////////////////////////////////////
template <typename ContainerT>
class pop_front {
public:
pop_front(ContainerT &list_) : list(list_) {}
~pop_front() { list.pop_front(); }
private:
ContainerT &list;
};
///////////////////////////////////////////////////////////////////////////
//
// Append a given list to the list given as argument
// On destruction pop the first element of the list given as argument
//
///////////////////////////////////////////////////////////////////////////
template <typename ContainerT>
class splice_pop_front {
public:
splice_pop_front(ContainerT &list_, ContainerT &queue)
: list(list_)
{
list.splice(list.end(), queue);
}
~splice_pop_front() { list.pop_front(); }
private:
ContainerT &list;
};
///////////////////////////////////////////////////////////////////////////
//
// On destruction reset a referenced value to its initial state
//
///////////////////////////////////////////////////////////////////////////
template <typename TypeT>
class reset {
public:
reset(TypeT &target_value_, TypeT new_value)
: target_value(target_value_), old_value(target_value_)
{
target_value_ = new_value;
}
~reset() { target_value = old_value; }
private:
TypeT &target_value;
TypeT old_value;
};
///////////////////////////////////////////////////////////////////////////
//
// On destruction assign the given iterator back
//
///////////////////////////////////////////////////////////////////////////
template <typename IteratorT, typename UnputIteratorT>
class assign
{
public:
assign(IteratorT &it_, UnputIteratorT const &uit_)
: it(it_), uit(uit_) {}
~assign() { it = uit.base(); }
private:
IteratorT &it;
UnputIteratorT const &uit;
};
template <typename IteratorT>
class assign<IteratorT, IteratorT> {
public:
assign(IteratorT &it_, IteratorT const &uit_)
: it(it_), uit(uit_) {}
~assign() { it = uit; }
private:
IteratorT &it;
IteratorT const &uit;
};
///////////////////////////////////////////////////////////////////////////////
} // namespace on_exit
///////////////////////////////////////////////////////////////////////////////
namespace impl {
///////////////////////////////////////////////////////////////////////////////
//
// Test, whether a given identifier resolves to a predefined name
//
///////////////////////////////////////////////////////////////////////////////
template <typename StringT>
inline bool
is_special_macroname (StringT const &name)
{
if (name.size() < 7)
return false;
if ("defined" == name)
return true;
if ('_' == name[0] && '_' == name[1]) {
StringT str = name.substr(2);
if (str == "cplusplus" || str == "STDC__" ||
str == "TIME__" || str == "DATE__" ||
str == "LINE__" || str == "FILE__" ||
str == "INCLUDE_LEVEL__")
{
return true;
}
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
//
// Test, whether two tokens are to be considered equal (different sequences
// of whitespace are considered to be equal)
//
///////////////////////////////////////////////////////////////////////////////
template <typename TokenT>
inline bool
token_equals(TokenT const &left, TokenT const &right)
{
using namespace boost::wave;
if (IS_CATEGORY(left, ParameterTokenType)) {
// if the existing token is of type T_PARAMETERBASE, then the right token
// must be of type T_IDENTIFIER or a keyword
token_id id = token_id(right);
return (T_IDENTIFIER == id ||
IS_CATEGORY(id, KeywordTokenType) ||
IS_EXTCATEGORY(id, OperatorTokenType|AltExtTokenType) ||
IS_CATEGORY(id, BoolLiteralTokenType)) &&
left.get_value() == right.get_value();
}
// if the left token has whitespace, the value is irrelevant
return token_id(left) == token_id(right) && (
IS_CATEGORY(left, WhiteSpaceTokenType) ||
left.get_value() == right.get_value()
);
}
///////////////////////////////////////////////////////////////////////////////
//
// Tests, whether two macro definitions are equal
//
///////////////////////////////////////////////////////////////////////////////
template <typename ContainerT>
inline bool
definition_equals(ContainerT const &definition,
ContainerT const &new_definition)
{
typedef typename ContainerT::const_iterator const_iterator_type;
const_iterator_type first1 = definition.begin();
const_iterator_type last1 = definition.end();
const_iterator_type first2 = new_definition.begin();
const_iterator_type last2 = new_definition.end();
while (first1 != last1 && first2 != last2 && token_equals(*first1, *first2))
{
// skip whitespace, if both sequences have a whitespace next
token_id id1 = next_token<const_iterator_type>::peek(first1, last1, false);
token_id id2 = next_token<const_iterator_type>::peek(first2, last2, false);
if (IS_CATEGORY(id1, WhiteSpaceTokenType) &&
IS_CATEGORY(id2, WhiteSpaceTokenType))
{
// all consecutive whitespace tokens count as one whitespace
// adjust first1 and first2 accordingly
skip_whitespace(first1, last1);
skip_whitespace(first2, last2);
}
else if (!IS_CATEGORY(id1, WhiteSpaceTokenType) &&
!IS_CATEGORY(id2, WhiteSpaceTokenType))
{
++first1;
++first2;
}
else {
// the sequences differ
break;
}
}
return (first1 == last1 && first2 == last2) ? true : false;
}
///////////////////////////////////////////////////////////////////////////////
//
// Tests, whether two given sets of macro parameters are equal
//
///////////////////////////////////////////////////////////////////////////////
template <typename ContainerT>
inline bool
parameters_equal(ContainerT const &parameters, ContainerT const &new_parameters)
{
if (parameters.size() != new_parameters.size())
return false; // different parameter count
typedef typename ContainerT::const_iterator const_iterator_type;
const_iterator_type first1 = parameters.begin();
const_iterator_type last1 = parameters.end();
const_iterator_type first2 = new_parameters.begin();
const_iterator_type last2 = new_parameters.end();
while (first1 != last1 && first2 != last2) {
// parameters are different, if the corresponding tokens are different
using namespace boost::wave;
if (token_id(*first1) != token_id(*first2) ||
(*first1).get_value() != (*first2).get_value())
{
break;
}
++first1;
++first2;
}
return (first1 == last1 && first2 == last2) ? true : false;
}
///////////////////////////////////////////////////////////////////////////////
//
// Strip leading and trailing whitespace from the given token sequence
//
///////////////////////////////////////////////////////////////////////////////
template <typename ContainerT>
inline void
trim_replacement_list (ContainerT &replacement_list)
{
using namespace boost::wave;
// strip leading whitespace
if (replacement_list.size() > 0) {
typename ContainerT::iterator end = replacement_list.end();
typename ContainerT::iterator it = replacement_list.begin();
while (it != end && IS_CATEGORY(*it, WhiteSpaceTokenType)) {
token_id id(*it);
if (T_PLACEHOLDER != id && T_PLACEMARKER != id) {
typename ContainerT::iterator next = it;
++next;
replacement_list.erase(it);
it = next;
}
else {
++it;
}
}
}
// strip trailing whitespace
if (replacement_list.size() > 0) {
typename ContainerT::reverse_iterator rend = replacement_list.rend();
typename ContainerT::reverse_iterator rit = replacement_list.rbegin();
while (rit != rend && IS_CATEGORY(*rit, WhiteSpaceTokenType))
++rit;
typename ContainerT::iterator end = replacement_list.end();
typename ContainerT::iterator it = rit.base();
while (it != end && IS_CATEGORY(*it, WhiteSpaceTokenType)) {
token_id id(*it);
if (T_PLACEHOLDER != id && T_PLACEMARKER != id) {
typename ContainerT::iterator next = it;
++next;
replacement_list.erase(it);
it = next;
}
else {
++it;
}
}
}
}
///////////////////////////////////////////////////////////////////////////////
//
// Tests, whether the given token sequence consists out of whitespace only
//
///////////////////////////////////////////////////////////////////////////////
template <typename ContainerT>
inline bool
is_whitespace_only (ContainerT const &argument)
{
typename ContainerT::const_iterator end = argument.end();
for (typename ContainerT::const_iterator it = argument.begin();
it != end; ++it)
{
if (!IS_CATEGORY(*it, WhiteSpaceTokenType))
return false;
}
return true;
}
///////////////////////////////////////////////////////////////////////////////
//
// Remove all placeholder tokens from the given token sequence
//
///////////////////////////////////////////////////////////////////////////////
template <typename ContainerT>
inline void
remove_placeholders (ContainerT &replacement_list)
{
using namespace boost::wave;
// strip leading whitespace
if (replacement_list.size() > 0) {
typename ContainerT::iterator end = replacement_list.end();
typename ContainerT::iterator it = replacement_list.begin();
while (it != end) {
token_id id(*it);
if (T_PLACEHOLDER == id || T_PLACEMARKER == id) {
typename ContainerT::iterator next = it;
++next;
replacement_list.erase(it);
it = next;
}
else {
++it;
}
}
// remove all 'new' leading and trailing whitespace
if (is_whitespace_only(replacement_list))
trim_replacement_list(replacement_list);
}
}
///////////////////////////////////////////////////////////////////////////////
//
// Remove all whitespace tokens on the left side of the given token sequence
//
///////////////////////////////////////////////////////////////////////////////
template <typename ContainerT>
inline void
trim_sequence_left (ContainerT &argument)
{
using namespace boost::wave;
// strip leading whitespace (should be only one token)
if (argument.size() > 0 &&
IS_CATEGORY(argument.front(), WhiteSpaceTokenType))
{
argument.pop_front();
}
}
///////////////////////////////////////////////////////////////////////////////
//
// Remove all whitespace tokens on the right side of the given token sequence
//
///////////////////////////////////////////////////////////////////////////////
template <typename ContainerT>
inline void
trim_sequence_right (ContainerT &argument)
{
using namespace boost::wave;
// strip trailing whitespace (should be only one token)
if (argument.size() > 0 &&
IS_CATEGORY(argument.back(), WhiteSpaceTokenType))
{
argument.pop_back();
}
}
///////////////////////////////////////////////////////////////////////////////
//
// Remove all whitespace tokens on the left and right sides of the given token
// sequence
//
///////////////////////////////////////////////////////////////////////////////
template <typename ContainerT>
inline void
trim_sequence (ContainerT &argument)
{
trim_sequence_left(argument);
trim_sequence_right(argument);
}
///////////////////////////////////////////////////////////////////////////////
// call 'skipped_token' preprocessing hook
template <typename ContextT>
void call_skipped_token_hook(ContextT& ctx,
typename ContextT::token_type const& skipped)
{
#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0
ctx.get_hooks().skipped_token(skipped);
#else
ctx.get_hooks().skipped_token(ctx.derived(), skipped);
#endif
}
///////////////////////////////////////////////////////////////////////////////
//
// Skip forward to a given token
//
///////////////////////////////////////////////////////////////////////////////
template <typename ContextT, typename IteratorT>
inline bool
skip_to_token(ContextT& ctx, IteratorT &it, IteratorT const &end,
token_id id, bool& seen_newline)
{
using namespace boost::wave;
if (token_id(*it) == id)
return true;
// call_skipped_token_hook(ctx, *it);
if (++it == end)
return false;
while (IS_CATEGORY(*it, WhiteSpaceTokenType) ||
T_NEWLINE == token_id(*it))
{
if (T_NEWLINE == token_id(*it))
seen_newline = true;
// call_skipped_token_hook(ctx, *it);
if (++it == end)
return false;
}
return token_id(*it) == id;
}
///////////////////////////////////////////////////////////////////////////////
//
// Get the full name of a given macro name (concatenate the string
// representations of the single tokens).
//
///////////////////////////////////////////////////////////////////////////////
template <typename IteratorT>
inline std::string
get_full_name(IteratorT const &begin, IteratorT const &end)
{
std::string full_name;
for (IteratorT err_it = begin; err_it != end; ++err_it)
full_name += (*err_it).get_value().c_str();
return full_name;
}
///////////////////////////////////////////////////////////////////////////////
//
// The following predicate is used in conjunction with the remove_copy_if
// algorithm to allow the detection of an eventually copied operator ##.
// No removal is performed in any case.
//
///////////////////////////////////////////////////////////////////////////////
class find_concat_operator {
public:
find_concat_operator(bool &found_) : found_concat(found_) {}
template <typename TokenT>
bool operator()(TokenT const &tok)
{
using namespace boost::wave;
if (T_POUND_POUND == BASE_TOKEN(token_id(tok)))
found_concat = true;
return false;
}
private:
bool &found_concat;
};
///////////////////////////////////////////////////////////////////////////////
// Convert a string of an arbitrary string compatible type to a internal
// string (BOOST_WAVE_STRING)
template <typename Target, typename Src>
struct to_string_helper
{
typedef Target type;
static Target call(Src const& str)
{
return Target(str.c_str());
}
};
// do nothing if types are equal
template <typename Src>
struct to_string_helper<Src, Src>
{
typedef Src const& type;
static Src const& call(Src const& str)
{
return str;
}
};
template <typename Target>
struct to_string_helper<Target, char const*>
{
typedef Target type;
static Target call(char const* str)
{
return Target(str);
}
};
///////////////////////////////////////////////////////////////////////////////
} // namespace impl
template <typename Target, typename Src>
inline typename impl::to_string_helper<Target, Src>::type
to_string(Src const& src)
{
return impl::to_string_helper<Target, Src>::call(src);
}
///////////////////////////////////////////////////////////////////////////////
} // namespace util
} // namespace wave
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(CPP_MACROMAP_UTIL_HPP_HK041119)

View File

@@ -0,0 +1,195 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Definition of the position_iterator and file_position templates
http://www.boost.org/
Copyright (c) 2001-2011 Hartmut Kaiser. 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(FILE_POSITION_H_52BDEDF7_DAD3_4F24_802F_E66BB8098F68_INCLUDED)
#define FILE_POSITION_H_52BDEDF7_DAD3_4F24_802F_E66BB8098F68_INCLUDED
#include <string>
#include <ostream>
#include <boost/assert.hpp>
#include <boost/spirit/include/classic_version.hpp>
#include <boost/spirit/include/classic_position_iterator.hpp>
#include <boost/wave/wave_config.hpp>
#if BOOST_WAVE_SERIALIZATION != 0
#include <boost/serialization/serialization.hpp>
#endif
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace util {
///////////////////////////////////////////////////////////////////////////////
//
// file_position
//
// A structure to hold positional information. This includes the filename,
// line number and column number of a current token position.
//
///////////////////////////////////////////////////////////////////////////////
template <typename StringT>
struct file_position {
public:
typedef StringT string_type;
file_position()
: file(), line(1), column(1)
{}
explicit file_position(string_type const& file_, std::size_t line_ = 1,
std::size_t column_ = 1)
: file(file_), line(line_), column(column_)
{}
// accessors
string_type const &get_file() const { return file; }
std::size_t get_line() const { return line; }
std::size_t get_column() const { return column; }
void set_file(string_type const &file_)
{
file = file_;
}
void set_line(std::size_t line_) { line = line_; }
void set_column(std::size_t column_) { column = column_; }
private:
#if BOOST_WAVE_SERIALIZATION != 0
friend class boost::serialization::access;
template<typename Archive>
void serialize(Archive &ar, const unsigned int version)
{
using namespace boost::serialization;
ar & make_nvp("filename", file);
ar & make_nvp("line", line);
ar & make_nvp("column", column);
}
#endif
string_type file;
std::size_t line;
std::size_t column;
};
template <typename StringT>
bool operator== (file_position<StringT> const &lhs,
file_position<StringT> const &rhs)
{
return lhs.get_column() == rhs.get_column() &&
lhs.get_line() == rhs.get_line() && lhs.get_file() == rhs.get_file();
}
template <typename StringT>
inline std::ostream &
operator<< (std::ostream &o, file_position<StringT> const &pos)
{
o << pos.get_file() << ":" << pos.get_line() << ":" << pos.get_column();
return o;
}
typedef file_position<BOOST_WAVE_STRINGTYPE> file_position_type;
///////////////////////////////////////////////////////////////////////////////
//
// position_iterator
//
// The position_iterator used by Wave is now based on the corresponding Spirit
// type. This type is used with our own file_position though. The needed
// specialization of the boost::spirit::classic::position_policy class is
// provided below.
//
///////////////////////////////////////////////////////////////////////////////
template <typename IteratorT, typename PositionT>
struct position_iterator
: boost::spirit::classic::position_iterator<IteratorT, PositionT>
{
typedef boost::spirit::classic::position_iterator<IteratorT, PositionT> base_type;
position_iterator()
{
}
position_iterator(IteratorT const &begin, IteratorT const &end,
PositionT const &pos)
: base_type(begin, end, pos)
{
}
};
///////////////////////////////////////////////////////////////////////////////
} // namespace util
} // namespace wave
///////////////////////////////////////////////////////////////////////////////
namespace spirit { namespace classic {
///////////////////////////////////////////////////////////////////////////////
//
// The boost::spirit::classic::position_policy has to be specialized for our
// file_position class
//
///////////////////////////////////////////////////////////////////////////////
template <>
class position_policy<boost::wave::util::file_position_type> {
public:
position_policy()
: m_CharsPerTab(4)
{}
void next_line(boost::wave::util::file_position_type &pos)
{
pos.set_line(pos.get_line() + 1);
pos.set_column(1);
}
void set_tab_chars(unsigned int chars)
{
m_CharsPerTab = chars;
}
void next_char(boost::wave::util::file_position_type &pos)
{
pos.set_column(pos.get_column() + 1);
}
void tabulation(boost::wave::util::file_position_type &pos)
{
pos.set_column(pos.get_column() + m_CharsPerTab -
(pos.get_column() - 1) % m_CharsPerTab);
}
private:
unsigned int m_CharsPerTab;
};
///////////////////////////////////////////////////////////////////////////////
}} // namespace spirit::classic
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(FILE_POSITION_H_52BDEDF7_DAD3_4F24_802F_E66BB8098F68_INCLUDED)

View File

@@ -0,0 +1,172 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2011 Hartmut Kaiser. 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_WAVE_FILESYSTEM_COMPATIBILITY_MAR_09_2009_0142PM)
#define BOOST_WAVE_FILESYSTEM_COMPATIBILITY_MAR_09_2009_0142PM
#include <string>
#include <boost/version.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
namespace boost { namespace wave { namespace util
{
///////////////////////////////////////////////////////////////////////////////
// filesystem wrappers allowing to handle different Boost versions
#if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
// interface wrappers for older Boost versions
inline boost::filesystem::path initial_path()
{
return boost::filesystem::initial_path();
}
inline boost::filesystem::path current_path()
{
return boost::filesystem::current_path();
}
template <typename String>
inline boost::filesystem::path create_path(String const& p)
{
#if BOOST_FILESYSTEM_VERSION >= 3
return boost::filesystem::path(p);
#else
return boost::filesystem::path(p, boost::filesystem::native);
#endif
}
inline std::string leaf(boost::filesystem::path const& p)
{
#if BOOST_FILESYSTEM_VERSION >= 3
return p.leaf().string();
#else
return p.leaf();
#endif
}
inline boost::filesystem::path branch_path(boost::filesystem::path const& p)
{
return p.branch_path();
}
inline boost::filesystem::path normalize(boost::filesystem::path& p)
{
return p.normalize();
}
inline std::string native_file_string(boost::filesystem::path const& p)
{
#if BOOST_FILESYSTEM_VERSION >= 3
return p.string();
#else
return p.native_file_string();
#endif
}
inline boost::filesystem::path complete_path(
boost::filesystem::path const& p)
{
#if BOOST_FILESYSTEM_VERSION >= 3
return boost::filesystem3::complete(p, initial_path());
#else
return boost::filesystem::complete(p, initial_path());
#endif
}
inline boost::filesystem::path complete_path(
boost::filesystem::path const& p, boost::filesystem::path const& base)
{
#if BOOST_FILESYSTEM_VERSION >= 3
return boost::filesystem3::complete(p, base);
#else
return boost::filesystem::complete(p, base);
#endif
}
#else
// interface wrappers if deprecated functions do not exist
inline boost::filesystem::path initial_path()
{
#if BOOST_FILESYSTEM_VERSION >= 3
return boost::filesystem3::detail::initial_path();
#else
return boost::filesystem::initial_path<boost::filesystem::path>();
#endif
}
inline boost::filesystem::path current_path()
{
#if BOOST_FILESYSTEM_VERSION >= 3
return boost::filesystem3::current_path();
#else
return boost::filesystem::current_path<boost::filesystem::path>();
#endif
}
template <typename String>
inline boost::filesystem::path create_path(String const& p)
{
return boost::filesystem::path(p);
}
inline std::string leaf(boost::filesystem::path const& p)
{
#if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION >= 3
return p.filename().string();
#else
return p.filename();
#endif
}
inline boost::filesystem::path branch_path(boost::filesystem::path const& p)
{
return p.parent_path();
}
inline boost::filesystem::path normalize(boost::filesystem::path& p)
{
return p; // function doesn't exist anymore
}
inline std::string native_file_string(boost::filesystem::path const& p)
{
#if BOOST_VERSION >= 104600
return p.string();
#else
return p.file_string();
#endif
}
inline boost::filesystem::path complete_path(
boost::filesystem::path const& p)
{
#if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION >= 3
return boost::filesystem::absolute(p, initial_path());
#else
return boost::filesystem::complete(p, initial_path());
#endif
}
inline boost::filesystem::path complete_path(
boost::filesystem::path const& p, boost::filesystem::path const& base)
{
#if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION >= 3
return boost::filesystem::absolute(p, base);
#else
return boost::filesystem::complete(p, base);
#endif
}
#endif
}}}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,155 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2011 Hartmut Kaiser. 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(FUNCTOR_INPUT_HPP_ED3A4C21_8F8A_453F_B438_08214FAC106A_INCLUDED)
#define FUNCTOR_INPUT_HPP_ED3A4C21_8F8A_453F_B438_08214FAC106A_INCLUDED
#include <boost/assert.hpp>
#include <boost/spirit/include/classic_multi_pass.hpp>
#include <boost/wave/wave_config.hpp>
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace util {
///////////////////////////////////////////////////////////////////////////////
//
// class functor_input
//
// Implementation of the InputPolicy used by multi_pass
// functor_input gets tokens from a functor
// Note: the functor must have a typedef for result_type
// It also must have a static variable of type result_type defined
// to represent eof that is called eof.
//
// This functor input policy template is essentially the same as the
// predefined multi_pass functor_input policy. The difference is,
// that the first token is not read at initialization time, but only
// just before returning the first token. Additionally it does not
// call operator new() twice but only once.
//
///////////////////////////////////////////////////////////////////////////////
struct functor_input {
template <typename FunctorT>
class inner {
private:
typedef typename FunctorT::result_type result_type;
public:
typedef result_type value_type;
private:
struct Data {
Data(FunctorT const &ftor_)
: ftor(ftor_), was_initialized(false)
{}
FunctorT ftor;
value_type curtok;
bool was_initialized;
};
// Needed by compilers not implementing the resolution to DR45. For
// reference, see
// http://www.open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#45.
friend struct Data;
public:
typedef std::ptrdiff_t difference_type;
typedef result_type *pointer;
typedef result_type &reference;
protected:
inner()
: data(0)
{}
inner(FunctorT const &x)
: data(new Data(x))
{}
inner(inner const &x)
: data(x.data)
{}
void destroy()
{
delete data;
data = 0;
}
bool same_input(inner const &x) const
{
return data == x.data;
}
void swap(inner &x)
{
boost::spirit::classic::impl::mp_swap(data, x.data);
}
void ensure_initialized() const
{
if (data && !data->was_initialized) {
data->curtok = (data->ftor)(); // get the first token
data->was_initialized = true;
}
}
public:
reference get_input() const
{
ensure_initialized();
return data->curtok;
}
void advance_input()
{
BOOST_ASSERT(0 != data);
data->curtok = (data->ftor)();
data->was_initialized = true;
}
bool input_at_eof() const
{
ensure_initialized();
return !data || data->curtok == data->ftor.eof;
}
FunctorT& get_functor() const
{
BOOST_ASSERT(0 != data);
return data->ftor;
}
private:
mutable Data *data;
};
};
///////////////////////////////////////////////////////////////////////////////
} // namespace util
} // namespace wave
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(FUNCTOR_INPUT_HPP_ED3A4C21_8F8A_453F_B438_08214FAC106A_INCLUDED)

View File

@@ -0,0 +1,518 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Detect the need to insert a whitespace token into the output stream
http://www.boost.org/
Copyright (c) 2001-2011 Hartmut Kaiser. 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(INSERT_WHITESPACE_DETECTION_HPP_765EF77B_0513_4967_BDD6_6A38148C4C96_INCLUDED)
#define INSERT_WHITESPACE_DETECTION_HPP_765EF77B_0513_4967_BDD6_6A38148C4C96_INCLUDED
#include <boost/wave/wave_config.hpp>
#include <boost/wave/token_ids.hpp>
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace util {
namespace impl {
// T_IDENTIFIER
template <typename StringT>
inline bool
would_form_universal_char (StringT const &value)
{
if ('u' != value[0] && 'U' != value[0])
return false;
if ('u' == value[0] && value.size() < 5)
return false;
if ('U' == value[0] && value.size() < 9)
return false;
typename StringT::size_type pos =
value.find_first_not_of("0123456789abcdefABCDEF", 1);
if (StringT::npos == pos ||
('u' == value[0] && pos > 5) ||
('U' == value[0] && pos > 9))
{
return true; // would form an universal char
}
return false;
}
template <typename StringT>
inline bool
handle_identifier(boost::wave::token_id prev,
boost::wave::token_id before, StringT const &value)
{
using namespace boost::wave;
switch (static_cast<unsigned int>(prev)) {
case T_IDENTIFIER:
case T_NONREPLACABLE_IDENTIFIER:
case T_COMPL_ALT:
case T_OR_ALT:
case T_AND_ALT:
case T_NOT_ALT:
case T_XOR_ALT:
case T_ANDASSIGN_ALT:
case T_ORASSIGN_ALT:
case T_XORASSIGN_ALT:
case T_NOTEQUAL_ALT:
case T_FIXEDPOINTLIT:
return true;
case T_FLOATLIT:
case T_INTLIT:
case T_PP_NUMBER:
return (value.size() > 1 || (value[0] != 'e' && value[0] != 'E'));
// avoid constructing universal characters (\u1234)
case TOKEN_FROM_ID('\\', UnknownTokenType):
return would_form_universal_char(value);
}
return false;
}
// T_INTLIT
inline bool
handle_intlit(boost::wave::token_id prev, boost::wave::token_id /*before*/)
{
using namespace boost::wave;
switch (static_cast<unsigned int>(prev)) {
case T_IDENTIFIER:
case T_NONREPLACABLE_IDENTIFIER:
case T_INTLIT:
case T_FLOATLIT:
case T_FIXEDPOINTLIT:
case T_PP_NUMBER:
return true;
}
return false;
}
// T_FLOATLIT
inline bool
handle_floatlit(boost::wave::token_id prev,
boost::wave::token_id /*before*/)
{
using namespace boost::wave;
switch (static_cast<unsigned int>(prev)) {
case T_IDENTIFIER:
case T_NONREPLACABLE_IDENTIFIER:
case T_INTLIT:
case T_FLOATLIT:
case T_FIXEDPOINTLIT:
case T_PP_NUMBER:
return true;
}
return false;
}
// <% T_LEFTBRACE
inline bool
handle_alt_leftbrace(boost::wave::token_id prev,
boost::wave::token_id /*before*/)
{
using namespace boost::wave;
switch (static_cast<unsigned int>(prev)) {
case T_LESS: // <<%
case T_SHIFTLEFT: // <<<%
return true;
}
return false;
}
// <: T_LEFTBRACKET
inline bool
handle_alt_leftbracket(boost::wave::token_id prev,
boost::wave::token_id /*before*/)
{
using namespace boost::wave;
switch (static_cast<unsigned int>(prev)) {
case T_LESS: // <<:
case T_SHIFTLEFT: // <<<:
return true;
}
return false;
}
// T_FIXEDPOINTLIT
inline bool
handle_fixedpointlit(boost::wave::token_id prev,
boost::wave::token_id /*before*/)
{
using namespace boost::wave;
switch (static_cast<unsigned int>(prev)) {
case T_IDENTIFIER:
case T_NONREPLACABLE_IDENTIFIER:
case T_INTLIT:
case T_FLOATLIT:
case T_FIXEDPOINTLIT:
case T_PP_NUMBER:
return true;
}
return false;
}
// T_DOT
inline bool
handle_dot(boost::wave::token_id prev, boost::wave::token_id before)
{
using namespace boost::wave;
switch (static_cast<unsigned int>(prev)) {
case T_DOT:
if (T_DOT == before)
return true; // ...
break;
}
return false;
}
// T_QUESTION_MARK
inline bool
handle_questionmark(boost::wave::token_id prev,
boost::wave::token_id /*before*/)
{
using namespace boost::wave;
switch(static_cast<unsigned int>(prev)) {
case TOKEN_FROM_ID('\\', UnknownTokenType): // \?
case T_QUESTION_MARK: // ??
return true;
}
return false;
}
// T_NEWLINE
inline bool
handle_newline(boost::wave::token_id prev,
boost::wave::token_id before)
{
using namespace boost::wave;
switch(static_cast<unsigned int>(prev)) {
case TOKEN_FROM_ID('\\', UnknownTokenType): // \ \n
case T_DIVIDE:
if (T_QUESTION_MARK == before)
return true; // ?/\n // may be \\n
break;
}
return false;
}
inline bool
handle_parens(boost::wave::token_id prev)
{
switch (static_cast<unsigned int>(prev)) {
case T_LEFTPAREN:
case T_RIGHTPAREN:
case T_LEFTBRACKET:
case T_RIGHTBRACKET:
case T_LEFTBRACE:
case T_RIGHTBRACE:
case T_SEMICOLON:
case T_COMMA:
case T_COLON:
// no insertion between parens/brackets/braces and operators
return false;
default:
break;
}
return true;
}
} // namespace impl
class insert_whitespace_detection
{
public:
insert_whitespace_detection(bool insert_whitespace_ = true)
: insert_whitespace(insert_whitespace_),
prev(boost::wave::T_EOF), beforeprev(boost::wave::T_EOF)
{}
template <typename StringT>
bool must_insert(boost::wave::token_id current, StringT const &value)
{
if (!insert_whitespace)
return false; // skip whitespace insertion alltogether
using namespace boost::wave;
switch (static_cast<unsigned int>(current)) {
case T_NONREPLACABLE_IDENTIFIER:
case T_IDENTIFIER:
return impl::handle_identifier(prev, beforeprev, value);
case T_PP_NUMBER:
case T_INTLIT:
return impl::handle_intlit(prev, beforeprev);
case T_FLOATLIT:
return impl::handle_floatlit(prev, beforeprev);
case T_STRINGLIT:
if (TOKEN_FROM_ID('L', IdentifierTokenType) == prev) // 'L'
return true;
break;
case T_LEFTBRACE_ALT:
return impl::handle_alt_leftbrace(prev, beforeprev);
case T_LEFTBRACKET_ALT:
return impl::handle_alt_leftbracket(prev, beforeprev);
case T_FIXEDPOINTLIT:
return impl::handle_fixedpointlit(prev, beforeprev);
case T_DOT:
return impl::handle_dot(prev, beforeprev);
case T_QUESTION_MARK:
return impl::handle_questionmark(prev, beforeprev);
case T_NEWLINE:
return impl::handle_newline(prev, beforeprev);
case T_LEFTPAREN:
case T_RIGHTPAREN:
case T_LEFTBRACKET:
case T_RIGHTBRACKET:
case T_SEMICOLON:
case T_COMMA:
case T_COLON:
switch (static_cast<unsigned int>(prev)) {
case T_LEFTPAREN:
case T_RIGHTPAREN:
case T_LEFTBRACKET:
case T_RIGHTBRACKET:
case T_LEFTBRACE:
case T_RIGHTBRACE:
return false; // no insertion between parens/brackets/braces
default:
if (IS_CATEGORY(prev, OperatorTokenType))
return false;
break;
}
break;
case T_LEFTBRACE:
case T_RIGHTBRACE:
switch (static_cast<unsigned int>(prev)) {
case T_LEFTPAREN:
case T_RIGHTPAREN:
case T_LEFTBRACKET:
case T_RIGHTBRACKET:
case T_LEFTBRACE:
case T_RIGHTBRACE:
case T_SEMICOLON:
case T_COMMA:
case T_COLON:
return false; // no insertion between parens/brackets/braces
case T_QUESTION_MARK:
if (T_QUESTION_MARK == beforeprev)
return true;
if (IS_CATEGORY(prev, OperatorTokenType))
return false;
break;
default:
break;
}
break;
case T_MINUS:
case T_MINUSMINUS:
case T_MINUSASSIGN:
if (T_MINUS == prev || T_MINUSMINUS == prev)
return true;
if (!impl::handle_parens(prev))
return false;
if (T_QUESTION_MARK == prev && T_QUESTION_MARK == beforeprev)
return true;
break;
case T_PLUS:
case T_PLUSPLUS:
case T_PLUSASSIGN:
if (T_PLUS == prev || T_PLUSPLUS == prev)
return true;
if (!impl::handle_parens(prev))
return false;
if (T_QUESTION_MARK == prev && T_QUESTION_MARK == beforeprev)
return true;
break;
case T_DIVIDE:
case T_DIVIDEASSIGN:
if (T_DIVIDE == prev)
return true;
if (!impl::handle_parens(prev))
return false;
if (T_QUESTION_MARK == prev && T_QUESTION_MARK == beforeprev)
return true;
break;
case T_EQUAL:
case T_ASSIGN:
switch (static_cast<unsigned int>(prev)) {
case T_PLUSASSIGN:
case T_MINUSASSIGN:
case T_DIVIDEASSIGN:
case T_STARASSIGN:
case T_SHIFTRIGHTASSIGN:
case T_SHIFTLEFTASSIGN:
case T_EQUAL:
case T_NOTEQUAL:
case T_LESSEQUAL:
case T_GREATEREQUAL:
case T_LESS:
case T_GREATER:
case T_PLUS:
case T_MINUS:
case T_STAR:
case T_DIVIDE:
case T_ORASSIGN:
case T_ANDASSIGN:
case T_XORASSIGN:
case T_OR:
case T_AND:
case T_XOR:
case T_OROR:
case T_ANDAND:
return true;
case T_QUESTION_MARK:
if (T_QUESTION_MARK == beforeprev)
return true;
break;
default:
if (!impl::handle_parens(prev))
return false;
break;
}
break;
case T_GREATER:
if (T_MINUS == prev || T_GREATER == prev)
return true; // prevent -> or >>
if (!impl::handle_parens(prev))
return false;
if (T_QUESTION_MARK == prev && T_QUESTION_MARK == beforeprev)
return true;
break;
case T_LESS:
if (T_LESS == prev)
return true; // prevent <<
// fall through
case T_CHARLIT:
case T_NOT:
case T_NOTEQUAL:
if (!impl::handle_parens(prev))
return false;
if (T_QUESTION_MARK == prev && T_QUESTION_MARK == beforeprev)
return true;
break;
case T_AND:
case T_ANDAND:
if (!impl::handle_parens(prev))
return false;
if (T_AND == prev || T_ANDAND == prev)
return true;
break;
case T_OR:
if (!impl::handle_parens(prev))
return false;
if (T_OR == prev)
return true;
break;
case T_XOR:
if (!impl::handle_parens(prev))
return false;
if (T_XOR == prev)
return true;
break;
case T_COMPL_ALT:
case T_OR_ALT:
case T_AND_ALT:
case T_NOT_ALT:
case T_XOR_ALT:
case T_ANDASSIGN_ALT:
case T_ORASSIGN_ALT:
case T_XORASSIGN_ALT:
case T_NOTEQUAL_ALT:
switch (static_cast<unsigned int>(prev)) {
case T_LEFTPAREN:
case T_RIGHTPAREN:
case T_LEFTBRACKET:
case T_RIGHTBRACKET:
case T_LEFTBRACE:
case T_RIGHTBRACE:
case T_SEMICOLON:
case T_COMMA:
case T_COLON:
// no insertion between parens/brackets/braces and operators
return false;
case T_IDENTIFIER:
if (T_NONREPLACABLE_IDENTIFIER == prev ||
IS_CATEGORY(prev, KeywordTokenType))
{
return true;
}
break;
default:
break;
}
break;
case T_STAR:
if (T_STAR == prev)
return false; // '*****' do not need to be separated
if (T_GREATER== prev &&
(T_MINUS == beforeprev || T_MINUSMINUS == beforeprev)
)
{
return true; // prevent ->*
}
break;
case T_POUND:
if (T_POUND == prev)
return true;
break;
}
// FIXME: else, handle operators separately (will catch to many cases)
// if (IS_CATEGORY(current, OperatorTokenType) &&
// IS_CATEGORY(prev, OperatorTokenType))
// {
// return true; // operators must be delimited always
// }
return false;
}
void shift_tokens (boost::wave::token_id next_id)
{
if (insert_whitespace) {
beforeprev = prev;
prev = next_id;
}
}
private:
bool insert_whitespace; // enable this component
boost::wave::token_id prev; // the previous analyzed token
boost::wave::token_id beforeprev; // the token before the previous
};
///////////////////////////////////////////////////////////////////////////////
} // namespace util
} // namespace wave
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(INSERT_WHITESPACE_DETECTION_HPP_765EF77B_0513_4967_BDD6_6A38148C4C96_INCLUDED)

View File

@@ -0,0 +1,210 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2011 Hartmut Kaiser. 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(INTERPRET_PRAGMA_HPP_B1F2315E_C5CE_4ED1_A343_0EF548B7942A_INCLUDED)
#define INTERPRET_PRAGMA_HPP_B1F2315E_C5CE_4ED1_A343_0EF548B7942A_INCLUDED
#include <string>
#include <list>
#include <boost/spirit/include/classic_core.hpp>
#include <boost/spirit/include/classic_assign_actor.hpp>
#include <boost/spirit/include/classic_push_back_actor.hpp>
#include <boost/spirit/include/classic_confix.hpp>
#include <boost/wave/wave_config.hpp>
#include <boost/wave/util/pattern_parser.hpp>
#include <boost/wave/util/macro_helpers.hpp>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/cpp_exceptions.hpp>
#include <boost/wave/cpp_iteration_context.hpp>
#include <boost/wave/language_support.hpp>
#if !defined(spirit_append_actor)
#define spirit_append_actor(actor) boost::spirit::classic::push_back_a(actor)
#define spirit_assign_actor(actor) boost::spirit::classic::assign_a(actor)
#endif // !defined(spirit_append_actor)
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace util {
///////////////////////////////////////////////////////////////////////////////
//
// The function interpret_pragma interprets the given token sequence as the
// body of a #pragma directive (or parameter to the _Pragma operator) and
// executes the actions associated with recognized Wave specific options.
//
///////////////////////////////////////////////////////////////////////////////
template <typename ContextT, typename IteratorT, typename ContainerT>
inline bool
interpret_pragma(ContextT &ctx, typename ContextT::token_type const &act_token,
IteratorT it, IteratorT const &end, ContainerT &pending)
{
typedef typename ContextT::token_type token_type;
typedef typename token_type::string_type string_type;
using namespace cpplexer;
if (T_IDENTIFIER == token_id(*it)) {
// check for pragma wave ...
if ((*it).get_value() == BOOST_WAVE_PRAGMA_KEYWORD)
{
// this is a wave specific option, it should have the form:
//
// #pragma command option(value)
//
// where
// 'command' is the value of the preprocessor constant
// BOOST_WAVE_PRAGMA_KEYWORD (defaults to "wave") and
// '(value)' is required only for some pragma directives (this is
// optional)
//
// All recognized #pragma operators are forwarded to the supplied
// preprocessing hook.
using namespace boost::spirit::classic;
token_type option;
ContainerT values;
if (!parse (++it, end,
( ch_p(T_IDENTIFIER)
[
spirit_assign_actor(option)
]
| pattern_p(KeywordTokenType,
TokenTypeMask|PPTokenFlag)
[
spirit_assign_actor(option)
]
| pattern_p(OperatorTokenType|AltExtTokenType,
ExtTokenTypeMask|PPTokenFlag) // and, bit_and etc.
[
spirit_assign_actor(option)
]
| pattern_p(BoolLiteralTokenType,
TokenTypeMask|PPTokenFlag)
[
spirit_assign_actor(option)
]
)
>> !comment_nest_p(
ch_p(T_LEFTPAREN),
ch_p(T_RIGHTPAREN)
)[spirit_assign_actor(values)],
pattern_p(WhiteSpaceTokenType, TokenTypeMask|PPTokenFlag)).hit)
{
typename ContextT::string_type msg(
impl::as_string<string_type>(it, end));
BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
ill_formed_pragma_option,
msg.c_str(), act_token.get_position());
return false;
}
// remove the falsely matched surrounding parenthesis's
if (values.size() >= 2) {
BOOST_ASSERT(T_LEFTPAREN == values.front() && T_RIGHTPAREN == values.back());
values.erase(values.begin());
typename ContainerT::reverse_iterator rit = values.rbegin();
values.erase((++rit).base());
}
// decode the option (call the context_policy hook)
if (!ctx.get_hooks().interpret_pragma(
ctx.derived(), pending, option, values, act_token))
{
// unknown #pragma option
string_type option_str ((*it).get_value());
option_str += option.get_value();
if (values.size() > 0) {
option_str += "(";
option_str += impl::as_string(values);
option_str += ")";
}
BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
ill_formed_pragma_option,
option_str.c_str(), act_token.get_position());
return false;
}
return true;
}
#if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
else if ((*it).get_value() == "once") {
// #pragma once
return ctx.add_pragma_once_header(act_token, ctx.get_current_filename());
}
#endif
#if BOOST_WAVE_SUPPORT_PRAGMA_MESSAGE != 0
else if ((*it).get_value() == "message") {
// #pragma message(...) or #pragma message ...
using namespace boost::spirit::classic;
ContainerT values;
if (!parse (++it, end,
( ( ch_p(T_LEFTPAREN)
>> lexeme_d[
*(anychar_p[spirit_append_actor(values)] - ch_p(T_RIGHTPAREN))
]
>> ch_p(T_RIGHTPAREN)
)
| lexeme_d[
*(anychar_p[spirit_append_actor(values)] - ch_p(T_NEWLINE))
]
),
pattern_p(WhiteSpaceTokenType, TokenTypeMask|PPTokenFlag)
).hit
)
{
typename ContextT::string_type msg(
impl::as_string<string_type>(it, end));
BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
ill_formed_pragma_message,
msg.c_str(), act_token.get_position());
return false;
}
// remove the falsely matched closing parenthesis/newline
if (values.size() > 0) {
BOOST_ASSERT(T_RIGHTPAREN == values.back() || T_NEWLINE == values.back());
typename ContainerT::reverse_iterator rit = values.rbegin();
values.erase((++rit).base());
}
// output the message itself
typename ContextT::string_type msg(impl::as_string(values));
BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
pragma_message_directive,
msg.c_str(), act_token.get_position());
return false;
}
#endif
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
} // namespace util
} // namespace wave
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(INTERPRET_PRAGMA_HPP_B1F2315E_C5CE_4ED1_A343_0EF548B7942A_INCLUDED)

View File

@@ -0,0 +1,83 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2011 Hartmut Kaiser. 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(ITERATION_CONTEXT_HPP_9556CD16_F11E_4ADC_AC8B_FB9A174BE664_INCLUDED)
#define ITERATION_CONTEXT_HPP_9556CD16_F11E_4ADC_AC8B_FB9A174BE664_INCLUDED
#include <cstdlib>
#include <cstdio>
#include <stack>
#include <boost/wave/wave_config.hpp>
#include <boost/wave/cpp_exceptions.hpp>
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace util {
///////////////////////////////////////////////////////////////////////////////
template <typename IterationContextT>
class iteration_context_stack
{
typedef std::stack<IterationContextT> base_type;
public:
typedef typename base_type::size_type size_type;
iteration_context_stack()
: max_include_nesting_depth(BOOST_WAVE_MAX_INCLUDE_LEVEL_DEPTH)
{}
void set_max_include_nesting_depth(size_type new_depth)
{ max_include_nesting_depth = new_depth; }
size_type get_max_include_nesting_depth() const
{ return max_include_nesting_depth; }
typename base_type::size_type size() const { return iter_ctx.size(); }
typename base_type::value_type &top() { return iter_ctx.top(); }
void pop() { iter_ctx.pop(); }
template <typename Context, typename PositionT>
void push(Context& ctx, PositionT const &pos,
typename base_type::value_type const &val)
{
if (iter_ctx.size() == max_include_nesting_depth) {
char buffer[22]; // 21 bytes holds all NUL-terminated unsigned 64-bit numbers
using namespace std; // for some systems sprintf is in namespace std
sprintf(buffer, "%d", (int)max_include_nesting_depth);
BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
include_nesting_too_deep, buffer, pos);
}
iter_ctx.push(val);
}
private:
size_type max_include_nesting_depth;
base_type iter_ctx;
};
///////////////////////////////////////////////////////////////////////////////
} // namespace util
} // namespace wave
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(ITERATION_CONTEXT_HPP_9556CD16_F11E_4ADC_AC8B_FB9A174BE664_INCLUDED)

View File

@@ -0,0 +1,200 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2011 Hartmut Kaiser. 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(MACRO_DEFINITION_HPP_D68A639E_2DA5_4E9C_8ACD_CFE6B903831E_INCLUDED)
#define MACRO_DEFINITION_HPP_D68A639E_2DA5_4E9C_8ACD_CFE6B903831E_INCLUDED
#include <vector>
#include <list>
#include <boost/detail/atomic_count.hpp>
#include <boost/intrusive_ptr.hpp>
#include <boost/wave/wave_config.hpp>
#if BOOST_WAVE_SERIALIZATION != 0
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/list.hpp>
#include <boost/serialization/vector.hpp>
#endif
#include <boost/wave/token_ids.hpp>
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace util {
///////////////////////////////////////////////////////////////////////////////
//
// macro_definition
//
// This class containes all infos for a defined macro.
//
///////////////////////////////////////////////////////////////////////////////
template <typename TokenT, typename ContainerT>
struct macro_definition {
typedef std::vector<TokenT> parameter_container_type;
typedef ContainerT definition_container_type;
typedef typename parameter_container_type::const_iterator
const_parameter_iterator_t;
typedef typename definition_container_type::const_iterator
const_definition_iterator_t;
macro_definition(TokenT const &token_, bool has_parameters,
bool is_predefined_, long uid_)
: macroname(token_), uid(uid_), is_functionlike(has_parameters),
replaced_parameters(false), is_available_for_replacement(true),
is_predefined(is_predefined_)
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
, has_ellipsis(false)
#endif
, use_count(0)
{
}
// generated copy constructor
// generated destructor
// generated assignment operator
// Replace all occurrences of the parameters throughout the macrodefinition
// with special parameter tokens to simplify later macro replacement.
// Additionally mark all occurrences of the macro name itself throughout
// the macro definition
void replace_parameters()
{
using namespace boost::wave;
if (!replaced_parameters) {
typename definition_container_type::iterator end = macrodefinition.end();
typename definition_container_type::iterator it = macrodefinition.begin();
for (/**/; it != end; ++it) {
token_id id = *it;
if (T_IDENTIFIER == id ||
IS_CATEGORY(id, KeywordTokenType) ||
IS_EXTCATEGORY(id, OperatorTokenType|AltExtTokenType) ||
IS_CATEGORY(id, OperatorTokenType))
{
// may be a parameter to replace
const_parameter_iterator_t cend = macroparameters.end();
const_parameter_iterator_t cit = macroparameters.begin();
for (typename parameter_container_type::size_type i = 0;
cit != cend; ++cit, ++i)
{
if ((*it).get_value() == (*cit).get_value()) {
(*it).set_token_id(token_id(T_PARAMETERBASE+i));
break;
}
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
else if (T_ELLIPSIS == token_id(*cit) &&
"__VA_ARGS__" == (*it).get_value())
{
// __VA_ARGS__ requires special handling
(*it).set_token_id(token_id(T_EXTPARAMETERBASE+i));
break;
}
#endif
}
}
}
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
// we need to know, if the last of the formal arguments is an ellipsis
if (macroparameters.size() > 0 &&
T_ELLIPSIS == token_id(macroparameters.back()))
{
has_ellipsis = true;
}
#endif
replaced_parameters = true; // do it only once
}
}
TokenT macroname; // macro name
parameter_container_type macroparameters; // formal parameters
definition_container_type macrodefinition; // macro definition token sequence
long uid; // unique id of this macro
bool is_functionlike;
bool replaced_parameters;
bool is_available_for_replacement;
bool is_predefined;
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
bool has_ellipsis;
#endif
boost::detail::atomic_count use_count;
#if BOOST_WAVE_SERIALIZATION != 0
// default constructor is needed for serialization only
macro_definition()
: uid(0), is_functionlike(false), replaced_parameters(false),
is_available_for_replacement(false), is_predefined(false)
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
, has_ellipsis(false)
#endif
, use_count(0)
{}
private:
friend class boost::serialization::access;
template<typename Archive>
void serialize(Archive &ar, const unsigned int version)
{
using namespace boost::serialization;
ar & make_nvp("name", macroname);
ar & make_nvp("parameters", macroparameters);
ar & make_nvp("definition", macrodefinition);
ar & make_nvp("uid", uid);
ar & make_nvp("is_functionlike", is_functionlike);
ar & make_nvp("has_replaced_parameters", replaced_parameters);
ar & make_nvp("is_available_for_replacement", is_available_for_replacement);
ar & make_nvp("is_predefined", is_predefined);
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
ar & make_nvp("has_ellipsis", has_ellipsis);
#endif
}
#endif
};
#if BOOST_WAVE_SERIALIZATION == 0
///////////////////////////////////////////////////////////////////////////////
template <typename TokenT, typename ContainerT>
inline void
intrusive_ptr_add_ref(macro_definition<TokenT, ContainerT>* p)
{
++p->use_count;
}
template <typename TokenT, typename ContainerT>
inline void
intrusive_ptr_release(macro_definition<TokenT, ContainerT>* p)
{
if (--p->use_count == 0)
delete p;
}
#endif
///////////////////////////////////////////////////////////////////////////////
} // namespace util
} // namespace wave
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(MACRO_DEFINITION_HPP_D68A639E_2DA5_4E9C_8ACD_CFE6B903831E_INCLUDED)

View File

@@ -0,0 +1,303 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2011 Hartmut Kaiser. 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(MACRO_HELPERS_HPP_931BBC99_EBFA_4692_8FBE_B555998C2C39_INCLUDED)
#define MACRO_HELPERS_HPP_931BBC99_EBFA_4692_8FBE_B555998C2C39_INCLUDED
#include <vector>
#include <boost/assert.hpp>
#include <boost/wave/wave_config.hpp>
#include <boost/wave/token_ids.hpp>
#include <boost/wave/cpplexer/validate_universal_char.hpp>
#include <boost/wave/util/unput_queue_iterator.hpp>
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace util {
namespace impl {
// escape a string literal (insert '\\' before every '\"', '?' and '\\')
template <typename StringT>
inline StringT
escape_lit(StringT const &value)
{
StringT result;
typename StringT::size_type pos = 0;
typename StringT::size_type pos1 = value.find_first_of ("\"\\?", 0);
if (StringT::npos != pos1) {
do {
result += value.substr(pos, pos1-pos)
+ StringT("\\")
+ StringT(1, value[pos1]);
pos1 = value.find_first_of ("\"\\?", pos = pos1+1);
} while (StringT::npos != pos1);
result += value.substr(pos);
}
else {
result = value;
}
return result;
}
// un-escape a string literal (remove '\\' just before '\\', '\"' or '?')
template <typename StringT>
inline StringT
unescape_lit(StringT const &value)
{
StringT result;
typename StringT::size_type pos = 0;
typename StringT::size_type pos1 = value.find_first_of ("\\", 0);
if (StringT::npos != pos1) {
do {
switch (value[pos1+1]) {
case '\\':
case '\"':
case '?':
result = result + value.substr(pos, pos1-pos);
pos1 = value.find_first_of ("\\", (pos = pos1+1)+1);
break;
case 'n':
result = result + value.substr(pos, pos1-pos) + "\n";
pos1 = value.find_first_of ("\\", pos = pos1+1);
++pos;
break;
default:
result = result + value.substr(pos, pos1-pos+1);
pos1 = value.find_first_of ("\\", pos = pos1+1);
}
} while (pos1 != StringT::npos);
result = result + value.substr(pos);
}
else {
// the string doesn't contain any escaped character sequences
result = value;
}
return result;
}
// return the string representation of a token sequence
template <typename ContainerT, typename PositionT>
inline typename ContainerT::value_type::string_type
as_stringlit (ContainerT const &token_sequence, PositionT const &pos)
{
using namespace boost::wave;
typedef typename ContainerT::value_type::string_type string_type;
string_type result("\"");
bool was_whitespace = false;
typename ContainerT::const_iterator end = token_sequence.end();
for (typename ContainerT::const_iterator it = token_sequence.begin();
it != end; ++it)
{
token_id id = token_id(*it);
if (IS_CATEGORY(*it, WhiteSpaceTokenType) || T_NEWLINE == id) {
if (!was_whitespace) {
// C++ standard 16.3.2.2 [cpp.stringize]
// Each occurrence of white space between the argument's
// preprocessing tokens becomes a single space character in the
// character string literal.
result += " ";
was_whitespace = true;
}
}
else if (T_STRINGLIT == id || T_CHARLIT == id) {
// string literals and character literals have to be escaped
result += impl::escape_lit((*it).get_value());
was_whitespace = false;
}
else
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
if (T_PLACEMARKER != id)
#endif
{
// now append this token to the string
result += (*it).get_value();
was_whitespace = false;
}
}
result += "\"";
// validate the resulting literal to contain no invalid universal character
// value (throws if invalid chars found)
boost::wave::cpplexer::impl::validate_literal(result, pos.get_line(),
pos.get_column(), pos.get_file());
return result;
}
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
// return the string representation of a token sequence
template <typename ContainerT, typename PositionT>
inline typename ContainerT::value_type::string_type
as_stringlit (std::vector<ContainerT> const &arguments,
typename std::vector<ContainerT>::size_type i, PositionT const &pos)
{
using namespace boost::wave;
typedef typename ContainerT::value_type::string_type string_type;
BOOST_ASSERT(i < arguments.size());
string_type result("\"");
bool was_whitespace = false;
for (/**/; i < arguments.size(); ++i) {
// stringize all remaining arguments
typename ContainerT::const_iterator end = arguments[i].end();
for (typename ContainerT::const_iterator it = arguments[i].begin();
it != end; ++it)
{
token_id id = token_id(*it);
if (IS_CATEGORY(*it, WhiteSpaceTokenType) || T_NEWLINE == id) {
if (!was_whitespace) {
// C++ standard 16.3.2.2 [cpp.stringize]
// Each occurrence of white space between the argument's
// preprocessing tokens becomes a single space character in the
// character string literal.
result += " ";
was_whitespace = true;
}
}
else if (T_STRINGLIT == id || T_CHARLIT == id) {
// string literals and character literals have to be escaped
result += impl::escape_lit((*it).get_value());
was_whitespace = false;
}
else if (T_PLACEMARKER != id) {
// now append this token to the string
result += (*it).get_value();
was_whitespace = false;
}
}
// append comma, if not last argument
if (i < arguments.size()-1) {
result += ",";
was_whitespace = false;
}
}
result += "\"";
// validate the resulting literal to contain no invalid universal character
// value (throws if invalid chars found)
boost::wave::cpplexer::impl::validate_literal(result, pos.get_line(),
pos.get_column(), pos.get_file());
return result;
}
#endif // BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
// return the string representation of a token sequence
template <typename StringT, typename IteratorT>
inline StringT
as_string(IteratorT it, IteratorT const& end)
{
StringT result;
for (/**/; it != end; ++it)
{
result += (*it).get_value();
}
return result;
}
// return the string representation of a token sequence
template <typename ContainerT>
inline typename ContainerT::value_type::string_type
as_string (ContainerT const &token_sequence)
{
typedef typename ContainerT::value_type::string_type string_type;
return as_string<string_type>(token_sequence.begin(),
token_sequence.end());
}
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
///////////////////////////////////////////////////////////////////////////
//
// Copies all arguments beginning with the given index to the output
// sequence. The arguments are separated by commas.
//
template <typename ContainerT, typename PositionT>
void replace_ellipsis (std::vector<ContainerT> const &arguments,
typename ContainerT::size_type index,
ContainerT &expanded, PositionT const &pos)
{
using namespace cpplexer;
typedef typename ContainerT::value_type token_type;
token_type comma(T_COMMA, ",", pos);
for (/**/; index < arguments.size(); ++index) {
ContainerT const &arg = arguments[index];
std::copy(arg.begin(), arg.end(),
std::inserter(expanded, expanded.end()));
if (index < arguments.size()-1)
expanded.push_back(comma);
}
}
#endif
// Skip all whitespace characters and queue the skipped characters into the
// given container
template <typename IteratorT>
inline boost::wave::token_id
skip_whitespace(IteratorT &first, IteratorT const &last)
{
token_id id = util::impl::next_token<IteratorT>::peek(first, last, false);
if (IS_CATEGORY(id, WhiteSpaceTokenType)) {
do {
++first;
id = util::impl::next_token<IteratorT>::peek(first, last, false);
} while (IS_CATEGORY(id, WhiteSpaceTokenType));
}
++first;
return id;
}
template <typename IteratorT, typename ContainerT>
inline boost::wave::token_id
skip_whitespace(IteratorT &first, IteratorT const &last, ContainerT &queue)
{
queue.push_back (*first); // queue up the current token
token_id id = util::impl::next_token<IteratorT>::peek(first, last, false);
if (IS_CATEGORY(id, WhiteSpaceTokenType)) {
do {
queue.push_back(*++first); // queue up the next whitespace
id = util::impl::next_token<IteratorT>::peek(first, last, false);
} while (IS_CATEGORY(id, WhiteSpaceTokenType));
}
++first;
return id;
}
} // namespace impl
///////////////////////////////////////////////////////////////////////////////
} // namespace util
} // namespace wave
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(MACRO_HELPERS_HPP_931BBC99_EBFA_4692_8FBE_B555998C2C39_INCLUDED)

View File

@@ -0,0 +1,67 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Global application configuration
http://www.boost.org/
Copyright (c) 2001-2011 Hartmut Kaiser. 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_PATTERN_PARSER_HPP)
#define BOOST_SPIRIT_PATTERN_PARSER_HPP
#include <boost/spirit/include/classic_primitives.hpp>
#include <boost/wave/wave_config.hpp>
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace util {
///////////////////////////////////////////////////////////////////////////
//
// pattern_and class
//
///////////////////////////////////////////////////////////////////////////
template <typename CharT = char>
struct pattern_and
: public boost::spirit::classic::char_parser<pattern_and<CharT> >
{
pattern_and(CharT pattern_, unsigned long pattern_mask_ = 0UL)
: pattern(pattern_),
pattern_mask((0UL != pattern_mask_) ?
pattern_mask_ : (unsigned long)pattern_)
{}
template <typename T>
bool test(T pattern_) const
{ return ((unsigned long)pattern_ & pattern_mask) == (unsigned long)pattern; }
CharT pattern;
unsigned long pattern_mask;
};
template <typename CharT>
inline pattern_and<CharT>
pattern_p(CharT pattern, unsigned long pattern_mask = 0UL)
{ return pattern_and<CharT>(pattern, pattern_mask); }
///////////////////////////////////////////////////////////////////////////////
} // namespace util
} // namespace wave
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // defined(BOOST_SPIRIT_PATTERN_PARSER_HPP)

View File

@@ -0,0 +1,120 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2011 Hartmut Kaiser. 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(SYMBOL_TABLE_HPP_32B0F7C6_3DD6_4113_95A5_E16516C6F45A_INCLUDED)
#define SYMBOL_TABLE_HPP_32B0F7C6_3DD6_4113_95A5_E16516C6F45A_INCLUDED
#include <map>
#include <boost/wave/wave_config.hpp>
#include <boost/intrusive_ptr.hpp>
#if BOOST_WAVE_SERIALIZATION != 0
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/map.hpp>
#include <boost/shared_ptr.hpp>
#else
#include <boost/intrusive_ptr.hpp>
#endif
#include <boost/iterator/transform_iterator.hpp>
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace util {
///////////////////////////////////////////////////////////////////////////////
//
// The symbol_table class is used for the storage of defined macros.
//
///////////////////////////////////////////////////////////////////////////////
template <typename StringT, typename MacroDefT>
struct symbol_table
#if BOOST_WAVE_SERIALIZATION != 0
: public std::map<StringT, boost::shared_ptr<MacroDefT> >
#else
: public std::map<StringT, boost::intrusive_ptr<MacroDefT> >
#endif
{
#if BOOST_WAVE_SERIALIZATION != 0
typedef std::map<StringT, boost::shared_ptr<MacroDefT> > base_type;
#else
typedef std::map<StringT, boost::intrusive_ptr<MacroDefT> > base_type;
#endif
typedef typename base_type::iterator iterator_type;
typedef typename base_type::const_iterator const_iterator_type;
symbol_table(long uid_ = 0)
{}
#if BOOST_WAVE_SERIALIZATION != 0
private:
friend class boost::serialization::access;
template<typename Archive>
void serialize(Archive &ar, const unsigned int version)
{
using namespace boost::serialization;
ar & make_nvp("symbol_table",
boost::serialization::base_object<base_type>(*this));
}
#endif
private:
///////////////////////////////////////////////////////////////////////////
//
// This is a special iterator allowing to iterate the names of all defined
// macros.
//
///////////////////////////////////////////////////////////////////////////
template <typename StringT1>
struct get_first
{
typedef StringT1 const& result_type;
template <typename First, typename Second>
StringT1 const& operator() (std::pair<First, Second> const& p) const
{
return p.first;
}
};
typedef get_first<StringT> unary_functor;
public:
typedef transform_iterator<unary_functor, iterator_type>
name_iterator;
typedef transform_iterator<unary_functor, const_iterator_type>
const_name_iterator;
template <typename Iterator>
static
transform_iterator<unary_functor, Iterator> make_iterator(Iterator it)
{
return boost::make_transform_iterator<unary_functor>(it);
}
};
///////////////////////////////////////////////////////////////////////////////
} // namespace util
} // namespace wave
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(SYMBOL_TABLE_HPP_32B0F7C6_3DD6_4113_95A5_E16516C6F45A_INCLUDED)

View File

@@ -0,0 +1,153 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2011 Hartmut Kaiser. 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(TIME_CONVERSION_HELPER_HPP_DA97E389_1797_43BA_82AE_B071064B3EF4_INCLUDED)
#define TIME_CONVERSION_HELPER_HPP_DA97E389_1797_43BA_82AE_B071064B3EF4_INCLUDED
#include <ctime>
#include <cstring>
#include <boost/config.hpp>
#include <boost/spirit/include/classic_core.hpp>
#include <boost/spirit/include/classic_symbols.hpp>
#include <boost/spirit/include/classic_assign_actor.hpp>
#include <boost/spirit/include/classic_push_back_actor.hpp>
#if !defined(spirit_append_actor)
#define spirit_append_actor(actor) boost::spirit::classic::push_back_a(actor)
#define spirit_assign_actor(actor) boost::spirit::classic::assign_a(actor)
#endif // !defined(spirit_append_actor)
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace util {
namespace time_conversion {
using namespace std; // some systems have std::tm etc. in namespace std
///////////////////////////////////////////////////////////////////////////////
// define, whether the rule's should generate some debug output
#define TRACE_CPP_TIME_CONVERSION \
(BOOST_SPIRIT_DEBUG_FLAGS_CPP & BOOST_SPIRIT_DEBUG_FLAGS_TIME_CONVERSION) \
/**/
///////////////////////////////////////////////////////////////////////////////
// Grammar for parsing a date/time string generated by the C++ compiler from
// __DATE__ and __TIME__
class time_conversion_grammar :
public boost::spirit::classic::grammar<time_conversion_grammar>
{
public:
time_conversion_grammar() : fYearIsCorrected(false)
{
using namespace std; // some systems have memset in std
memset (&time_stamp, 0, sizeof(tm));
BOOST_SPIRIT_DEBUG_TRACE_RULE_NAME(*this, "time_conversion_grammar",
TRACE_CPP_TIME_CONVERSION);
}
template <typename ScannerT>
struct definition {
definition(time_conversion_grammar const &self)
{
using boost::spirit::classic::int_p;
using boost::spirit::classic::add;
char const *m[] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
for (int i = 0; i < 12; ++i)
add (month, m[i], i);
time_rule // expected format is 'Dec 29 2001 11:23:59'
= month[spirit_assign_actor(self.time_stamp.tm_mon)]
>> int_p[spirit_assign_actor(self.time_stamp.tm_mday)]
>> int_p[spirit_assign_actor(self.time_stamp.tm_year)]
>> int_p[spirit_assign_actor(self.time_stamp.tm_hour)] >> ':'
>> int_p[spirit_assign_actor(self.time_stamp.tm_min)] >> ':'
>> int_p[spirit_assign_actor(self.time_stamp.tm_sec)]
;
BOOST_SPIRIT_DEBUG_TRACE_RULE(time_rule, TRACE_CPP_TIME_CONVERSION);
}
boost::spirit::classic::rule<ScannerT> time_rule;
boost::spirit::classic::symbols<> month;
boost::spirit::classic::rule<ScannerT> const&
start() const { return time_rule; }
};
void correct_year()
{
if (!fYearIsCorrected) {
time_stamp.tm_year -= 1900;
fYearIsCorrected = true;
}
}
mutable tm time_stamp;
bool fYearIsCorrected;
};
///////////////////////////////////////////////////////////////////////////////
// calculate the time of the compilation as a std::time_t to ensure correctness
// of the saved dfa table
class time_conversion_helper
{
public:
time_conversion_helper(char const *act_time) : compile_time(0)
{
using namespace boost::spirit::classic;
time_conversion_grammar g;
parse_info<> pi = parse (act_time, g, space_p);
if (pi.hit) {
g.correct_year();
compile_time = mktime(&g.time_stamp);
}
BOOST_ASSERT(0 != compile_time);
}
time_t get_time() const { return compile_time; }
private:
time_t compile_time;
};
///////////////////////////////////////////////////////////////////////////////
#undef TRACE_CPP_TIME_CONVERSION
} // namespace time_conversion
// import time_conversion into the boost::wave::util namespace
using namespace time_conversion;
///////////////////////////////////////////////////////////////////////////////
} // namespace util
} // namespace wave
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(TIME_CONVERSION_HELPER_HPP_DA97E389_1797_43BA_82AE_B071064B3EF4_INCLUDED)

View File

@@ -0,0 +1,89 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2011 Hartmut Kaiser. 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(TRANSFORM_ITERATOR_HPP_D492C659_88C7_4258_8C42_192F9AE80EC0_INCLUDED)
#define TRANSFORM_ITERATOR_HPP_D492C659_88C7_4258_8C42_192F9AE80EC0_INCLUDED
#include <boost/config.hpp>
#include <boost/iterator_adaptors.hpp>
#include <boost/iterator/transform_iterator.hpp>
#include <boost/assert.hpp>
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace impl {
///////////////////////////////////////////////////////////////////////////////
//
// The new Boost.Iterator library already conatins a transform_iterator usable
// for our needs. The code below wraps this up.
//
///////////////////////////////////////////////////////////////////////////////
template <class AdaptableUnaryFunctionT, class IteratorT>
class ref_transform_iterator_generator
{
typedef typename AdaptableUnaryFunctionT::result_type return_type;
typedef typename AdaptableUnaryFunctionT::argument_type argument_type;
public:
typedef boost::transform_iterator<
return_type (*)(argument_type), IteratorT, return_type>
type;
};
template <class AdaptableUnaryFunctionT, class IteratorT>
inline
typename ref_transform_iterator_generator<
AdaptableUnaryFunctionT, IteratorT>::type
make_ref_transform_iterator(
IteratorT base, AdaptableUnaryFunctionT const &f)
{
typedef typename ref_transform_iterator_generator<
AdaptableUnaryFunctionT, IteratorT>::type
iterator_type;
return iterator_type(base, f.transform);
}
// Retrieve the token value given a parse node
// This is used in conjunction with the ref_transform_iterator above, to
// get the token values while iterating directly over the parse tree.
template <typename TokenT, typename ParseTreeNodeT>
struct get_token_value {
typedef TokenT const &result_type;
typedef ParseTreeNodeT const &argument_type;
static result_type
transform (argument_type node)
{
BOOST_ASSERT(1 == std::distance(node.value.begin(),
node.value.end()));
return *node.value.begin();
}
};
///////////////////////////////////////////////////////////////////////////////
} // namespace impl
} // namespace wave
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(TRANSFORM_ITERATOR_HPP_D492C659_88C7_4258_8C42_192F9AE80EC0_INCLUDED)

View File

@@ -0,0 +1,295 @@
/*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
Definition of the unput queue iterator
http://www.boost.org/
Copyright (c) 2001-2011 Hartmut Kaiser. 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(UNPUT_QUEUE_ITERATOR_HPP_76DA23D0_4893_4AD5_ABCC_6CED7CFB89BC_INCLUDED)
#define UNPUT_QUEUE_ITERATOR_HPP_76DA23D0_4893_4AD5_ABCC_6CED7CFB89BC_INCLUDED
#include <list>
#include <boost/assert.hpp>
#include <boost/iterator_adaptors.hpp>
#include <boost/wave/wave_config.hpp>
#include <boost/wave/token_ids.hpp> // token_id
// this must occur after all of the includes and before any code appears
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_PREFIX
#endif
///////////////////////////////////////////////////////////////////////////////
namespace boost {
namespace wave {
namespace util {
///////////////////////////////////////////////////////////////////////////////
//
// unput_queue_iterator
//
// The unput_queue_iterator templates encapsulates an unput_queue together
// with the direct input to be read after the unput queue is emptied
//
// This version is for the new iterator_adaptors (was released with
// Boost V1.31.0)
//
///////////////////////////////////////////////////////////////////////////////
template <typename IteratorT, typename TokenT, typename ContainerT>
class unput_queue_iterator
: public boost::iterator_adaptor<
unput_queue_iterator<IteratorT, TokenT, ContainerT>,
IteratorT, TokenT const, std::forward_iterator_tag>
{
typedef boost::iterator_adaptor<
unput_queue_iterator<IteratorT, TokenT, ContainerT>,
IteratorT, TokenT const, std::forward_iterator_tag>
base_type;
public:
typedef ContainerT container_type;
typedef IteratorT iterator_type;
unput_queue_iterator(IteratorT const &it, ContainerT &queue)
: base_type(it), unput_queue(queue)
{}
ContainerT &get_unput_queue()
{ return unput_queue; }
ContainerT const &get_unput_queue() const
{ return unput_queue; }
IteratorT &get_base_iterator()
{ return base_type::base_reference(); }
IteratorT const &get_base_iterator() const
{ return base_type::base_reference(); }
unput_queue_iterator &operator= (unput_queue_iterator const &rhs)
{
if (this != &rhs) {
unput_queue = rhs.unput_queue;
base_type::operator=(rhs);
}
return *this;
}
typename base_type::reference dereference() const
{
if (!unput_queue.empty())
return unput_queue.front();
return *base_type::base_reference();
}
void increment()
{
if (!unput_queue.empty()) {
// there exist pending tokens in the unput queue
unput_queue.pop_front();
}
else {
// the unput_queue is empty, so advance the base iterator
++base_type::base_reference();
}
}
template <
typename OtherDerivedT, typename OtherIteratorT,
typename V, typename C, typename R, typename D
>
bool equal(
boost::iterator_adaptor<OtherDerivedT, OtherIteratorT, V, C, R, D>
const &x) const
{
// two iterators are equal, if both begin() iterators of the queue
// objects are equal and the base iterators are equal as well
OtherDerivedT const &rhs = static_cast<OtherDerivedT const &>(x);
return
((unput_queue.empty() && rhs.unput_queue.empty()) ||
(&unput_queue == &rhs.unput_queue &&
unput_queue.begin() == rhs.unput_queue.begin()
)
) &&
(get_base_iterator() == rhs.get_base_iterator());
}
private:
ContainerT &unput_queue;
};
namespace impl {
///////////////////////////////////////////////////////////////////////////
template <typename IteratorT, typename TokenT, typename ContainerT>
struct gen_unput_queue_iterator
{
typedef ContainerT container_type;
typedef IteratorT iterator_type;
typedef unput_queue_iterator<IteratorT, TokenT, ContainerT>
return_type;
static container_type last;
static return_type
generate(iterator_type const &it)
{
return return_type(it, last);
}
static return_type
generate(ContainerT &queue, iterator_type const &it)
{
return return_type(it, queue);
}
};
template <typename IteratorT, typename TokenT, typename ContainerT>
typename gen_unput_queue_iterator<IteratorT, TokenT, ContainerT>::
container_type
gen_unput_queue_iterator<IteratorT, TokenT, ContainerT>::last =
typename gen_unput_queue_iterator<IteratorT, TokenT, ContainerT>::
container_type();
///////////////////////////////////////////////////////////////////////////
template <typename IteratorT, typename TokenT, typename ContainerT>
struct gen_unput_queue_iterator<
unput_queue_iterator<IteratorT, TokenT, ContainerT>,
TokenT, ContainerT>
{
typedef ContainerT container_type;
typedef unput_queue_iterator<IteratorT, TokenT, ContainerT>
iterator_type;
typedef unput_queue_iterator<IteratorT, TokenT, ContainerT>
return_type;
static container_type last;
static return_type
generate(iterator_type &it)
{
return return_type(it.base(), last);
}
static return_type
generate(ContainerT &queue, iterator_type &it)
{
return return_type(it.base(), queue);
}
};
///////////////////////////////////////////////////////////////////////////
template <typename IteratorT>
struct assign_iterator
{
static void
do_ (IteratorT &dest, IteratorT const &src)
{
dest = src;
}
};
///////////////////////////////////////////////////////////////////////////
//
// Look for the first non-whitespace token and return this token id.
// Note though, that the embedded unput_queues are not touched in any way!
//
template <typename IteratorT>
struct next_token
{
static boost::wave::token_id
peek(IteratorT it, IteratorT end, bool skip_whitespace = true)
{
using namespace boost::wave;
if (skip_whitespace) {
for (++it; it != end; ++it) {
if (!IS_CATEGORY(*it, WhiteSpaceTokenType) &&
T_NEWLINE != token_id(*it))
{
break; // stop at the first non-whitespace token
}
}
}
else {
++it; // we have at least to look ahead
}
if (it != end)
return token_id(*it);
return T_EOI;
}
};
template <typename IteratorT, typename TokenT, typename ContainerT>
struct next_token<
unput_queue_iterator<IteratorT, TokenT, ContainerT> > {
typedef unput_queue_iterator<IteratorT, TokenT, ContainerT> iterator_type;
static boost::wave::token_id
peek(iterator_type it, iterator_type end, bool skip_whitespace = true)
{
using namespace boost::wave;
typename iterator_type::container_type &queue = it.get_unput_queue();
// first try to find it in the unput_queue
if (0 != queue.size()) {
typename iterator_type::container_type::iterator cit = queue.begin();
typename iterator_type::container_type::iterator cend = queue.end();
if (skip_whitespace) {
for (++cit; cit != cend; ++cit) {
if (!IS_CATEGORY(*cit, WhiteSpaceTokenType) &&
T_NEWLINE != token_id(*cit))
{
break; // stop at the first non-whitespace token
}
}
}
else {
++cit; // we have at least to look ahead
}
if (cit != cend)
return token_id(*cit);
}
// second try to move on into the base iterator stream
typename iterator_type::iterator_type base_it = it.get_base_iterator();
typename iterator_type::iterator_type base_end = end.get_base_iterator();
if (0 == queue.size())
++base_it; // advance, if the unput queue is empty
if (skip_whitespace) {
for (/**/; base_it != base_end; ++base_it) {
if (!IS_CATEGORY(*base_it, WhiteSpaceTokenType) &&
T_NEWLINE != token_id(*base_it))
{
break; // stop at the first non-whitespace token
}
}
}
if (base_it == base_end)
return T_EOI;
return token_id(*base_it);
}
};
///////////////////////////////////////////////////////////////////////////////
} // namespace impl
///////////////////////////////////////////////////////////////////////////////
} // namespace util
} // namespace wave
} // namespace boost
// the suffix header occurs after all of the code
#ifdef BOOST_HAS_ABI_HEADERS
#include BOOST_ABI_SUFFIX
#endif
#endif // !defined(UNPUT_QUEUE_ITERATOR_HPP_76DA23D0_4893_4AD5_ABCC_6CED7CFB89BC_INCLUDED)