blob: 5d295d70c31832dd8a4b96959bef7851bb5bab8c [file] [log] [blame]
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07001// (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
15#ifndef BOOST_RT_CLA_VALIDATION_IPP_070604GER
16#define BOOST_RT_CLA_VALIDATION_IPP_070604GER
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>
23#include <ndnboost/test/utils/runtime/validation.hpp> // BOOST_RT_PARAM_NAMESPACE::logic_error
24
25// Boost
26#include <ndnboost/test/utils/basic_cstring/io.hpp>
27
28// STL
29
30namespace ndnboost {
31
32namespace BOOST_RT_PARAM_NAMESPACE {
33
34namespace cla {
35
36// ************************************************************************** //
37// ************** runtime::cla::validation ************** //
38// ************************************************************************** //
39
40BOOST_RT_PARAM_INLINE void
41report_input_error( argv_traverser const& tr, format_stream& msg )
42{
43 if( tr.eoi() )
44 msg << BOOST_RT_PARAM_LITERAL( " at the end of input" );
45 else {
46 msg << BOOST_RT_PARAM_LITERAL( " in the following position: " );
47
48 if( tr.input().size() > 5 )
49 msg << tr.input().substr( 0, 5 ) << BOOST_RT_PARAM_LITERAL( "..." );
50 else
51 msg << tr.input();
52 }
53
54 throw BOOST_RT_PARAM_NAMESPACE::logic_error( msg.str() );
55}
56
57//____________________________________________________________________________//
58
59} // namespace cla
60
61} // namespace BOOST_RT_PARAM_NAMESPACE
62
63} // namespace ndnboost
64
65#endif // BOOST_RT_CLA_VALIDATION_IPP_070604GER