blob: 4af93709509815f874abdb6db00d12c172c0498c [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
Jeff Thompson3d613fd2013-10-15 15:39:04 -070015#ifndef NDNBOOST_RT_CLA_VALIDATION_IPP_070604GER
16#define NDNBOOST_RT_CLA_VALIDATION_IPP_070604GER
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070017
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 Thompson3d613fd2013-10-15 15:39:04 -070023#include <ndnboost/test/utils/runtime/validation.hpp> // NDNBOOST_RT_PARAM_NAMESPACE::logic_error
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070024
25// Boost
26#include <ndnboost/test/utils/basic_cstring/io.hpp>
27
28// STL
29
30namespace ndnboost {
31
Jeff Thompson3d613fd2013-10-15 15:39:04 -070032namespace NDNBOOST_RT_PARAM_NAMESPACE {
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070033
34namespace cla {
35
36// ************************************************************************** //
37// ************** runtime::cla::validation ************** //
38// ************************************************************************** //
39
Jeff Thompson3d613fd2013-10-15 15:39:04 -070040NDNBOOST_RT_PARAM_INLINE void
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070041report_input_error( argv_traverser const& tr, format_stream& msg )
42{
43 if( tr.eoi() )
Jeff Thompson3d613fd2013-10-15 15:39:04 -070044 msg << NDNBOOST_RT_PARAM_LITERAL( " at the end of input" );
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070045 else {
Jeff Thompson3d613fd2013-10-15 15:39:04 -070046 msg << NDNBOOST_RT_PARAM_LITERAL( " in the following position: " );
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070047
48 if( tr.input().size() > 5 )
Jeff Thompson3d613fd2013-10-15 15:39:04 -070049 msg << tr.input().substr( 0, 5 ) << NDNBOOST_RT_PARAM_LITERAL( "..." );
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070050 else
51 msg << tr.input();
52 }
53
Jeff Thompson3d613fd2013-10-15 15:39:04 -070054 throw NDNBOOST_RT_PARAM_NAMESPACE::logic_error( msg.str() );
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070055}
56
57//____________________________________________________________________________//
58
59} // namespace cla
60
Jeff Thompson3d613fd2013-10-15 15:39:04 -070061} // namespace NDNBOOST_RT_PARAM_NAMESPACE
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070062
63} // namespace ndnboost
64
Jeff Thompson3d613fd2013-10-15 15:39:04 -070065#endif // NDNBOOST_RT_CLA_VALIDATION_IPP_070604GER