set_input_approver(3)
set_input_approver π
ok so bestie, welcome to set_input_approver(3) from the gstream manual β¨ this one lives in section 3 and it's genuinely such a cute little function, let's get into it π
πΈ NAME πΈ
set_input_approver β the gatekeeper of your input, fr fr π
β¨ SYNOPSIS β¨
#include <gstream.h>
void set_input_approver(bool (*input_approver)(int));
π DESCRIPTION π
okay so here's the tea π the function you hand over gets called with every single new character that gets inputted, and it decides whether the inputter is gonna accept that character or not. The way it works:
- if it returns
trueβ the character is accepted and inserted into the input string π - if it returns
falseβ the character is thrown away ποΈ gone. deleted. not invited to the party.
A short example, since seeing it hits different:
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
so iconic honestly, the user literally cannot type anything except a, b or c π slay.
Now β if you wanna declare any variables of the type of the function, there's a typedef called input_approver in gbuf that makes it super easy, like:
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);
look at them swapping approvers, that's main character energy right there π₯
heads up bestie β note that a default input string as entered by set_input_string is not checked by this function. no vibe check for the default string, it just walks right in π
The default approver is
π not meβ¦ the page literally just stops there, no cap. that's all she wrote.
π¦ 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)
go read those next, iykyk πβ¨
and that's the whole page, bestie π«Ά this was gstream, version 1.6 β the source and version on the original footer, mwah π consider yourself blessed, periodt ππ
π¦ where this page comes from
- fedora 43: gstream-devel 1.6-35.fc43 Β· Giftware
- fedora 43: gstream-devel 1.6-35.fc43 Β· Giftware
- fedora 44: gstream-devel 1.6-36.fc44 Β· Giftware
- fedora 44: gstream-devel 1.6-36.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms