Data update
This commit is contained in:
parent
0df55f9f24
commit
aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions
|
|
@ -1,28 +1,11 @@
|
|||
#include <sstream> // for istringstream
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool isNumeric( const char* pszInput, int nNumberBase )
|
||||
{
|
||||
istringstream iss( pszInput );
|
||||
|
||||
if ( nNumberBase == 10 )
|
||||
{
|
||||
double dTestSink;
|
||||
iss >> dTestSink;
|
||||
}
|
||||
else if ( nNumberBase == 8 || nNumberBase == 16 )
|
||||
{
|
||||
int nTestSink;
|
||||
iss >> ( ( nNumberBase == 8 ) ? oct : hex ) >> nTestSink;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
// was any input successfully consumed/converted?
|
||||
if ( ! iss )
|
||||
return false;
|
||||
|
||||
// was all the input successfully consumed/converted?
|
||||
return ( iss.rdbuf()->in_avail() == 0 );
|
||||
bool isNumeric(const char *s) {
|
||||
if (s == nullptr || *s == '\0' || std::isspace(*s)) {
|
||||
return false;
|
||||
}
|
||||
char *p;
|
||||
std::strtod(s, &p);
|
||||
return *p == '\0';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,28 @@
|
|||
#include <sstream> // for istringstream
|
||||
|
||||
using namespace std;
|
||||
|
||||
bool isNumeric( const char* pszInput, int nNumberBase )
|
||||
{
|
||||
string base = "0123456789ABCDEF";
|
||||
string input = pszInput;
|
||||
istringstream iss( pszInput );
|
||||
|
||||
return (input.find_first_not_of(base.substr(0, nNumberBase)) == string::npos);
|
||||
if ( nNumberBase == 10 )
|
||||
{
|
||||
double dTestSink;
|
||||
iss >> dTestSink;
|
||||
}
|
||||
else if ( nNumberBase == 8 || nNumberBase == 16 )
|
||||
{
|
||||
int nTestSink;
|
||||
iss >> ( ( nNumberBase == 8 ) ? oct : hex ) >> nTestSink;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
// was any input successfully consumed/converted?
|
||||
if ( ! iss )
|
||||
return false;
|
||||
|
||||
// was all the input successfully consumed/converted?
|
||||
return ( iss.rdbuf()->in_avail() == 0 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
bool isNumeric(const std::string& input) {
|
||||
return std::all_of(input.begin(), input.end(), ::isdigit);
|
||||
bool isNumeric( const char* pszInput, int nNumberBase )
|
||||
{
|
||||
string base = "0123456789ABCDEF";
|
||||
string input = pszInput;
|
||||
|
||||
return (input.find_first_not_of(base.substr(0, nNumberBase)) == string::npos);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
bool isNumeric(const std::string& input) {
|
||||
return std::all_of(input.begin(), input.end(), ::isdigit);
|
||||
}
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
#include <ctype.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
int isNumeric (const char * s)
|
||||
{
|
||||
if (s == NULL || *s == '\0' || isspace(*s))
|
||||
return 0;
|
||||
char * p;
|
||||
strtod (s, &p);
|
||||
|
||||
bool isNumeric(const char *s) {
|
||||
if (s == NULL || *s == '\0' || isspace(*s)) {
|
||||
return false;
|
||||
}
|
||||
char *p;
|
||||
strtod(s, &p);
|
||||
return *p == '\0';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue