macro_value.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // boost/filesystem/detail/macro_value.hpp -------------------------------------------//
  2. // (C) Copyright John Maddock 2001 - 2003
  3. // (C) Copyright Jens Maurer 2001
  4. // (C) Copyright Peter Dimov 2001
  5. // (C) Copyright Darin Adler 2001
  6. // (C) Copyright Beman Dawes 2002
  7. // Distributed under the Boost Software License, Version 1.0.
  8. // See http://www.boost.org/LICENSE_1_0.txt
  9. // Library home page: http://www.boost.org/libs/filesystem
  10. //--------------------------------------------------------------------------------------//
  11. #ifndef BOOST_FILESYSTEM_MACRO_VALUE_HPP
  12. #define BOOST_FILESYSTEM_MACRO_VALUE_HPP
  13. #include <boost/config.hpp>
  14. #include <boost/assert.hpp>
  15. #include <cstdlib>
  16. namespace boost
  17. {
  18. namespace detail
  19. {
  20. inline const char* macro_value(const char* name, const char* value)
  21. {
  22. static const char* no_value = "[no value]";
  23. static const char* not_defined = "[not defined]";
  24. BOOST_ASSERT_MSG(name, "name argument must not be a null pointer");
  25. BOOST_ASSERT_MSG(value, "value argument must not be a null pointer");
  26. return strcmp(name, value + 1)
  27. ? ((*value && *(value+1)) ? (value+1) : no_value)
  28. : not_defined; // name == value+1 so the macro is not defined
  29. }
  30. } // detail
  31. } // boost
  32. #define BOOST_MACRO_VALUE(X) boost::detail::macro_value(#X, BOOST_STRINGIZE(=X))
  33. #endif // BOOST_FILESYSTEM_MACRO_VALUE_HPP