Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 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 | |
| 6 | // See http://www.boost.org/libs/test for the library home page. |
| 7 | // |
| 8 | // File : $RCSfile$ |
| 9 | // |
| 10 | // Version : $Revision: 49312 $ |
| 11 | // |
| 12 | // Description : input validation helpers implementation |
| 13 | // *************************************************************************** |
| 14 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 15 | #ifndef NDNBOOST_RT_CLA_VALIDATION_IPP_070604GER |
| 16 | #define NDNBOOST_RT_CLA_VALIDATION_IPP_070604GER |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 17 | |
| 18 | // Boost.Runtime.Parameter |
| 19 | #include <ndnboost/test/utils/runtime/config.hpp> |
| 20 | |
| 21 | #include <ndnboost/test/utils/runtime/cla/argv_traverser.hpp> |
| 22 | #include <ndnboost/test/utils/runtime/cla/validation.hpp> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 23 | #include <ndnboost/test/utils/runtime/validation.hpp> // NDNBOOST_RT_PARAM_NAMESPACE::logic_error |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 24 | |
| 25 | // Boost |
| 26 | #include <ndnboost/test/utils/basic_cstring/io.hpp> |
| 27 | |
| 28 | // STL |
| 29 | |
| 30 | namespace ndnboost { |
| 31 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 32 | namespace NDNBOOST_RT_PARAM_NAMESPACE { |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 33 | |
| 34 | namespace cla { |
| 35 | |
| 36 | // ************************************************************************** // |
| 37 | // ************** runtime::cla::validation ************** // |
| 38 | // ************************************************************************** // |
| 39 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 40 | NDNBOOST_RT_PARAM_INLINE void |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 41 | report_input_error( argv_traverser const& tr, format_stream& msg ) |
| 42 | { |
| 43 | if( tr.eoi() ) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 44 | msg << NDNBOOST_RT_PARAM_LITERAL( " at the end of input" ); |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 45 | else { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 46 | msg << NDNBOOST_RT_PARAM_LITERAL( " in the following position: " ); |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 47 | |
| 48 | if( tr.input().size() > 5 ) |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 49 | msg << tr.input().substr( 0, 5 ) << NDNBOOST_RT_PARAM_LITERAL( "..." ); |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 50 | else |
| 51 | msg << tr.input(); |
| 52 | } |
| 53 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 54 | throw NDNBOOST_RT_PARAM_NAMESPACE::logic_error( msg.str() ); |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | //____________________________________________________________________________// |
| 58 | |
| 59 | } // namespace cla |
| 60 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 61 | } // namespace NDNBOOST_RT_PARAM_NAMESPACE |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 62 | |
| 63 | } // namespace ndnboost |
| 64 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 65 | #endif // NDNBOOST_RT_CLA_VALIDATION_IPP_070604GER |