00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #pragma once
00019
00020 #include <boost/program_options.hpp>
00021 #include <string>
00022
00023 namespace mongo {
00024
00025 struct PasswordValue : public boost::program_options::typed_value<std::string> {
00026
00027 PasswordValue( std::string* val )
00028 : boost::program_options::typed_value<std::string>( val ) { }
00029
00030 unsigned min_tokens() const {
00031 return 0;
00032 }
00033
00034 unsigned max_tokens() const {
00035 return 1;
00036 }
00037
00038 bool is_required() const {
00039 return false;
00040 }
00041
00042 void xparse( boost::any& value_store,
00043 const std::vector<std::string>& new_tokens ) const {
00044 if ( !value_store.empty() )
00045 #if BOOST_VERSION >= 104200
00046 boost::throw_exception( boost::program_options::validation_error( boost::program_options::validation_error::multiple_values_not_allowed ) );
00047 #else
00048 boost::throw_exception( boost::program_options::validation_error( "multiple values not allowed" ) );
00049 #endif
00050 else if ( !new_tokens.empty() )
00051 boost::program_options::typed_value<std::string>::xparse
00052 (value_store, new_tokens);
00053 else
00054 value_store = std::string();
00055 }
00056
00057 };
00058
00059 std::string askPassword();
00060
00061 }