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