gstream-set_input_approver - Man Page
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:
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
If you want to declare any variables of the type of the function, the typedef 'input_approver' in 'gbuf' makes it easy, e.g.
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);
Note that a default input string as entered by set_input_string is not checked by this function. The default approver is
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)
Referenced By
gstream-get_input_approver(3), gstream-restore_input_approver(3), gstream-save_input_approver(3), gstream-set_input_error_handler(3).