validation.ipp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // (C) Copyright Gennadiy Rozental 2005-2008.
  2. // Use, modification, and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/test for the library home page.
  6. //
  7. // File : $RCSfile$
  8. //
  9. // Version : $Revision: 49312 $
  10. //
  11. // Description : input validation helpers implementation
  12. // ***************************************************************************
  13. #ifndef BOOST_RT_CLA_VALIDATION_IPP_070604GER
  14. #define BOOST_RT_CLA_VALIDATION_IPP_070604GER
  15. // Boost.Runtime.Parameter
  16. #include <boost/test/utils/runtime/config.hpp>
  17. #include <boost/test/utils/runtime/cla/argv_traverser.hpp>
  18. #include <boost/test/utils/runtime/cla/validation.hpp>
  19. #include <boost/test/utils/runtime/validation.hpp> // BOOST_RT_PARAM_NAMESPACE::logic_error
  20. // Boost
  21. #include <boost/test/utils/basic_cstring/io.hpp>
  22. // STL
  23. namespace boost {
  24. namespace BOOST_RT_PARAM_NAMESPACE {
  25. namespace cla {
  26. // ************************************************************************** //
  27. // ************** runtime::cla::validation ************** //
  28. // ************************************************************************** //
  29. BOOST_RT_PARAM_INLINE void
  30. report_input_error( argv_traverser const& tr, format_stream& msg )
  31. {
  32. if( tr.eoi() )
  33. msg << BOOST_RT_PARAM_LITERAL( " at the end of input" );
  34. else {
  35. msg << BOOST_RT_PARAM_LITERAL( " in the following position: " );
  36. if( tr.input().size() > 5 )
  37. msg << tr.input().substr( 0, 5 ) << BOOST_RT_PARAM_LITERAL( "..." );
  38. else
  39. msg << tr.input();
  40. }
  41. throw BOOST_RT_PARAM_NAMESPACE::logic_error( msg.str() );
  42. }
  43. //____________________________________________________________________________//
  44. } // namespace cla
  45. } // namespace BOOST_RT_PARAM_NAMESPACE
  46. } // namespace boost
  47. #endif // BOOST_RT_CLA_VALIDATION_IPP_070604GER