cloudy
trunk
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
source
elementnames.cpp
Go to the documentation of this file.
1
/* This file is part of Cloudy and is copyright (C)1978-2022 by Gary J. Ferland and
2
* others. For conditions of distribution and use see copyright notice in license.txt */
3
#include "
cddefines.h
"
4
#include "
elementnames.h
"
5
t_elementnames
elementnames
;
6
7
/* nelem_symbol_to_index - obtain the array index the input element symbol refers to.
8
* The first letter is expected to be uppercase, and the second lowercase. */
9
int
nelem_symbol_to_index
(
const
char
*chSym )
10
{
11
int
ielem = -1;
12
13
size_t
symlen = strlen( chSym );
14
if
( symlen == 0 || symlen >=
size_t
(
CHARS_ELEMENT_SYM
) )
15
return
ielem;
16
17
for
(
int
i = 0; i <
LIMELM
; ++i )
18
{
19
if
( symlen == 1 )
20
{
21
if
(
toupper
( chSym[0] ) == elementnames.
chElementSym
[i][0] &&
22
elementnames.
chElementSym
[i][1] ==
' '
)
23
{
24
ielem = i;
25
break
;
26
}
27
}
28
else
if
( strncmp( elementnames.
chElementSym
[i], chSym,
CHARS_ELEMENT_SYM
) == 0 )
29
{
30
ielem = i;
31
break
;
32
}
33
}
34
return
ielem;
35
}
36
37
/* isElementSym - search for string among element symbols. */
38
bool
isElementSym
(
const
char
*chSym )
39
{
40
return
(
nelem_symbol_to_index
( chSym ) != -1 ) ?
true
:
false
;
41
}
nelem_symbol_to_index
int nelem_symbol_to_index(const char *chSym)
Definition:
elementnames.cpp:9
elementnames.h
CHARS_ELEMENT_SYM
Definition:
elementnames.h:7
elementnames
t_elementnames elementnames
Definition:
elementnames.cpp:5
toupper
char toupper(char c)
Definition:
cddefines.h:739
t_elementnames
Definition:
elementnames.h:12
t_elementnames::chElementSym
char chElementSym[LIMELM][CHARS_ELEMENT_SYM]
Definition:
elementnames.h:25
cddefines.h
LIMELM
const int LIMELM
Definition:
cddefines.h:308
isElementSym
bool isElementSym(const char *chSym)
Definition:
elementnames.cpp:38
Generated by
1.8.5