-
Notifications
You must be signed in to change notification settings - Fork 0
/
ccp4_ccplib_fem.hpp
155 lines (132 loc) · 2 KB
/
ccp4_ccplib_fem.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#ifndef CCP4IO_ADAPTBX_CCP4_CCPLIB_FEM_HPP
#define CCP4IO_ADAPTBX_CCP4_CCPLIB_FEM_HPP
#include <fem.hpp> // Fortran EMulation library of fable module
extern "C" {
void
ccp4_version_(
char* version,
int version_len);
void
ccpfyp_();
void
ccpdat_(
char* caldat,
int caldat_len);
}
namespace ccp4_ccplib_fem {
using namespace fem::major_types;
inline
void
ccpupc(
str_ref string)
{
int n = string.len();
char* s = string.elems();
for(int i=0;i<n;i++) {
s[i] = fem::utils::to_upper(s[i]);
}
}
inline
int
lenstr(
str_cref string)
{
return fem::len_trim(string);
}
inline
void
ccperr(
int const& istat,
str_cref errstr)
{
throw TBXX_NOT_IMPLEMENTED();
}
inline
void
ccpdat(
str_ref caldat)
{
ccpdat_(caldat.elems(), caldat.len());
}
inline
void
ccplwc(
str_ref string)
{
throw TBXX_NOT_IMPLEMENTED();
}
inline
bool
litend(
int const& /* idum */)
{
bool return_value = fem::bool0;
throw TBXX_NOT_IMPLEMENTED();
}
inline
bool
litend()
{
// true if the system byte-order is little endian
short int word = 0x0001;
char* byte = (char*) &word;
return byte[0]==0x01;
}
inline
bool
ccponl(
int const& /* idum */)
{
return false;
}
inline
int
ccpe2i(
str_cref name,
int const& defval)
{
std::string k = fem::utils::strip_leading_and_trailing_blank_padding(name);
char* v = std::getenv(k.c_str());
if (v == 0) return defval;
int result;
int n = std::sscanf(v, "%d", result);
if (n != 1) {
std::ostringstream o;
o << "Environment variable \""
<< std::string(k)
<< "\" is not an integer: \""
<< v << "\"";
throw std::runtime_error(o.str());
}
return result;
}
inline
void
ccp4_version(
str_ref version)
{
ccp4_version_(version.elems(),version.len());
}
inline
void
ccpfyp()
{
ccpfyp_();
}
inline
int
lunsto(
int const& /*idum*/)
{
return 6;
}
inline
bool
hkleq(
arr_cref<int> ih,
arr_cref<int> kh)
{
return (ih(1) == kh(1)) && (ih(2) == kh(2)) && (ih(3) == kh(3));
}
} // namespace ccp4_ccplib_fem
#endif // GUARD