home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 52
/
Amiga_Dream_52.iso
/
Linux
/
Divers
/
lyx-0.13.2.tar.gz
/
lyx-0.13.2.tar
/
lyx-0.13.2
/
src
/
lstrings.C
< prev
next >
Wrap
Text File
|
1998-04-23
|
880b
|
43 lines
bool isStrInt(LString const & str)
{
if (str.empty()) return false;
int len, idx = 0;
LString tmpstr = str;
// Remove leading and trailing white space chars.
tmpstr.strip(' ');
tmpstr.frontStrip(' ');
len = tmpstr.length();
if (len == 0) return false;
while (idx < len) {
if ((idx == 0) &&(tmpstr[0] == '-'))
++idx;
else if (isdigit(tmpstr[idx]))
++idx;
else
return false;
}
return true;
}
int LStr2Int(LString const & str)
{
LString tmpstr;
if (isStrInt(str)) {
tmpstr = str;
// Remove leading and trailing white space chars.
tmpstr.strip(' ');
tmpstr.frontStrip(' ');
// Do the conversion proper.
return atoi(tmpstr.c_str());
} else
return 0;
}