gstream-set_input_approver(3)
| set_input_approver(3) | gstream manual | set_input_approver(3) |
NAME
set_input_approver
SYNOPSIS
#include <gstream.h>
void set_input_approver(bool (*input_approver)(int));
DESCRIPTION
The function handed over will be called with every new character inputted and determines whether the character will be accepted by the inputter. If it returns true, the character is accepted and inserted in the input string, if false, the character is thrown away.
A short example:
If you want to declare any variables of the type of the function, the typedef 'input_approver' in 'gbuf' makes it easy, e.g.
bool ia_abc_is_what_we_want(int chr)
{
if (chr == 'a' || chr == 'b' || chr == 'c')
return true;
else
return false;
}
//...
gs.set_input_approver(ia_abc_is_what_we_want);
gs >> my_string; // the user is only able to input a, b or c
Note that a default input string as entered by set_input_string is not checked by this function. The default approver is
gbuf::input_approver tmp_ap;
//...
tmp_ap = gs1.get_input_approver();
gs1.set_input_approver(gs2.get_input_approver());
gs2.set_input_approver(tmp_ap);
SEE ALSO
gstream-save_input_approver(3), gstream-restore_input_approver(3), gstream-get_input_approver(3), gstream-set_input_string(3), gstream-ia_allow_everything(3)
| version 1.6 | gstream |
