Gui Addition efficiency question
by Nathan Huffman · in Torque Game Engine · 05/28/2006 (1:01 am) · 1 replies
I'm rather new to C++, so I was wondering if what I did was 'sane' without 'going overboard' or creating security flaws... somehow...
I wanted to make sure all input into one of my GuiTextEditCtrl was only Alphanumeric A-Z 0-9
So I opened up the C++ code for this control and added a new persistance field which is boolean and toggles an mAlnumShield
Later down the code in the onkeydown function where it typically adds what you typed, or executes the correct command if you did a CTRL C or whatever, I found a good location and pasted
Then in the GuiTextEditCtrl's includes I added ctype.h to have functionality with isalnum()
And it works just fine.
However, I'm happy that it works but is this inefficent? Is my executable now compiling with loads of extra code it doesn't need because of that new include? Am I permitted to use that new include in my project? Was there an easier way to do this?
Any input from someone who knows this stuff is appreciated :)
thanks.
I wanted to make sure all input into one of my GuiTextEditCtrl was only Alphanumeric A-Z 0-9
So I opened up the C++ code for this control and added a new persistance field which is boolean and toggles an mAlnumShield
Later down the code in the onkeydown function where it typically adds what you typed, or executes the correct command if you did a CTRL C or whatever, I found a good location and pasted
if ( mAlnumShield )
{
if ( !isalnum(event.ascii) )
{
return true;
}
}Then in the GuiTextEditCtrl's includes I added ctype.h to have functionality with isalnum()
And it works just fine.
However, I'm happy that it works but is this inefficent? Is my executable now compiling with loads of extra code it doesn't need because of that new include? Am I permitted to use that new include in my project? Was there an easier way to do this?
Any input from someone who knows this stuff is appreciated :)
thanks.
Torque Owner Dan -
Most likely not. Did your exe get too big? My guess is that you can't even tell the difference.
Of course!
I don't know. Your solution seems pretty straight forward for your need.