Joedb
9.5.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
src
joedb
is_identifier.cpp
Go to the documentation of this file.
1
#include "
joedb/is_identifier.h
"
2
3
namespace
joedb
4
{
5
constexpr
bool
is_letter
(
char
c)
6
{
7
return
(
'a'
<= c && c <=
'z'
) || (
'A'
<= c && c <=
'Z'
);
8
}
9
10
constexpr
bool
is_number
(
char
c)
11
{
12
return
(
'0'
<= c && c <=
'9'
);
13
}
14
15
/// @ingroup joedb
16
bool
is_identifier
(
const
std::string &s)
17
{
18
if
(s.empty())
19
return
false
;
20
21
if
(
is_number
(s[0]))
22
return
false
;
23
24
char
previous = 0;
25
for
(
const
char
c: s)
26
{
27
if
(c !=
'_'
&& !
is_letter
(c) && !
is_number
(c))
28
return
false
;
29
if
(c ==
'_'
&& previous ==
'_'
)
30
return
false
;
31
previous = c;
32
}
33
34
return
true
;
35
}
36
}
joedb::is_identifier
bool is_identifier(const std::string &s)
Definition
is_identifier.cpp:16
is_identifier.h
joedb
Definition
Blob.h:7
joedb::is_letter
constexpr bool is_letter(char c)
Definition
is_identifier.cpp:5
joedb::is_number
constexpr bool is_number(char c)
Definition
is_identifier.cpp:10
Generated by
1.9.8