summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/spirit/classic/test/impl
diff options
context:
space:
mode:
Diffstat (limited to 'src/boost/libs/spirit/classic/test/impl')
-rw-r--r--src/boost/libs/spirit/classic/test/impl/sstream.hpp46
-rw-r--r--src/boost/libs/spirit/classic/test/impl/string_length.hpp30
-rw-r--r--src/boost/libs/spirit/classic/test/impl/var.hpp34
3 files changed, 110 insertions, 0 deletions
diff --git a/src/boost/libs/spirit/classic/test/impl/sstream.hpp b/src/boost/libs/spirit/classic/test/impl/sstream.hpp
new file mode 100644
index 00000000..bb94cb9c
--- /dev/null
+++ b/src/boost/libs/spirit/classic/test/impl/sstream.hpp
@@ -0,0 +1,46 @@
+/*=============================================================================
+ Copyright (c) 2003 Martin Wille
+ http://spirit.sourceforge.net/
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+#include <boost/config.hpp>
+
+///////////////////////////////////////////////////////////////////////////
+// workaround for prestandard support of stringstreams
+//
+// * defines sstream_t for the string stream type
+// * defines std::string getstring(sstream_t &);
+//
+
+#ifdef BOOST_NO_STRINGSTREAM
+# include <strstream>
+ typedef strstream sstream_t;
+ std::string
+ getstring(std::strstream& ss)
+ {
+ ss << ends;
+ std::string rval = ss.str();
+ ss.freeze(false);
+ return rval;
+ }
+#else
+# include <sstream>
+ typedef std::stringstream sstream_t;
+ std::string
+ getstring(std::stringstream &ss)
+ {
+ return ss.str();
+ }
+#endif
+
+void use_getstring_to_avoid_compiler_warnings_about_unused_functions()
+{
+ sstream_t ss;
+ getstring(ss);
+ if(!ss) { // to be not recursive on all control paths
+ use_getstring_to_avoid_compiler_warnings_about_unused_functions();
+ }
+}
diff --git a/src/boost/libs/spirit/classic/test/impl/string_length.hpp b/src/boost/libs/spirit/classic/test/impl/string_length.hpp
new file mode 100644
index 00000000..f55c4bbf
--- /dev/null
+++ b/src/boost/libs/spirit/classic/test/impl/string_length.hpp
@@ -0,0 +1,30 @@
+/*=============================================================================
+ Copyright (c) 2004 Joel de Guzman
+ http://spirit.sourceforge.net/
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+#if !defined(SPIRIT_TEST_IMPL_STRING_LEN_HPP)
+#define SPIRIT_TEST_IMPL_STRING_LEN_HPP
+
+// We use our own string_len function instead of std::strlen
+// to avoid the namespace confusion on different compilers. Some
+// have it in namespace std. Some have it in global namespace.
+// Some have it in both.
+namespace test_impl
+{
+ template <typename Char>
+ inline unsigned int
+ string_length(Char const* str)
+ {
+ unsigned int len = 0;
+ while (*str++)
+ ++len;
+ return len;
+ }
+}
+
+#endif
+
diff --git a/src/boost/libs/spirit/classic/test/impl/var.hpp b/src/boost/libs/spirit/classic/test/impl/var.hpp
new file mode 100644
index 00000000..d2019452
--- /dev/null
+++ b/src/boost/libs/spirit/classic/test/impl/var.hpp
@@ -0,0 +1,34 @@
+/*=============================================================================
+ Copyright (c) 2003 Martin Wille
+ http://spirit.sourceforge.net/
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+#ifndef BOOST_SPIRIT_TEST_IMPL_VAR_HPP
+#define BOOST_SPIRIT_TEST_IMPL_VAR_HPP
+
+#include <boost/ref.hpp>
+
+namespace test
+{
+ template <typename T>
+ struct var_wrapper
+ : public ::boost::reference_wrapper<T>
+ {
+ typedef ::boost::reference_wrapper<T> parent;
+
+ explicit inline var_wrapper(T& t) : parent(t) {}
+
+ inline T& operator()() const { return parent::get(); }
+ };
+
+ template <typename T>
+ inline var_wrapper<T>
+ var(T& t)
+ {
+ return var_wrapper<T>(t);
+ }
+}
+#endif // BOOST_SPIRIT_TEST_IMPL_VAR_HPP