45 const string printable =
" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~`!@#$%^&*()_-+={[}]|\\:;<,>.?/'\"\n\t\r";
46 const string ESC =
"\\";
47 const string DOUBLE_ESC = ESC + ESC;
48 const string QUOTE =
"\"";
49 const string ESCQUOTE = ESC + QUOTE;
53 while ((ind = s.find(ESC, ind)) != string::npos) {
54 s.replace(ind, 1, DOUBLE_ESC);
55 ind += DOUBLE_ESC.length();
60 while ((ind = s.find_first_not_of(printable, ind)) != string::npos)
61 s.replace(ind, 1, ESC + octstring(s[ind]));
66 while ((ind = s.find(QUOTE, ind)) != string::npos) {
67 s.replace(ind, 1, ESCQUOTE);
68 ind += ESCQUOTE.length();
79 buf << oct << setw(3) << setfill(
'0')
80 <<
static_cast<unsigned int>(val);
86 void HDF5CFDAPUtil::replace_double_quote(
string & str) {
88 const string offend_char =
"\"";
89 const string replace_str =
""e";
90 size_t found_quote = 0;
92 while (found_quote != string::npos) {
93 found_quote = str.find(offend_char,start_pos);
94 if (found_quote!= string::npos){
95 str.replace(found_quote,offend_char.size(),replace_str);
96 start_pos = found_quote+1;
102 string HDF5CFDAPUtil::print_type(H5DataType type) {
106 string DAPUNSUPPORTED =
"Unsupported";
107 string DAPBYTE =
"Byte";
108 string DAPINT16 =
"Int16";
109 string DAPUINT16 =
"Uint16";
110 string DAPINT32 =
"Int32";
111 string DAPUINT32 =
"Uint32";
112 string DAPFLOAT32 =
"Float32";
113 string DAPFLOAT64 =
"Float64";
114 string DAP4INT64 =
"Int64";
115 string DAP4UINT64 =
"UInt64";
116 string DAPSTRING =
"String";
154 return DAPUNSUPPORTED;
157 return DAPUNSUPPORTED;
163 HDF5CFDAPUtil::get_mem_dtype(H5DataType dtype,
size_t mem_dtype_size ) {
167 return ((H5INT16 == dtype) && (1 == mem_dtype_size))?H5CHAR:dtype;
171 HDF5CFDAPUtil:: print_attr(H5DataType type,
int loc,
void *vals)
183 unsigned long long *ullp;
193 gp.ucp = (
unsigned char *) vals;
203 gp.cp = (
char *) vals;
217 gp.sp = (
short *) vals;
225 gp.usp = (
unsigned short *) vals;
226 rep << *(gp.usp+loc);
233 gp.ip = (
int *) vals;
240 gp.uip = (
unsigned int *) vals;
241 rep << *(gp.uip+loc);
246 gp.llp = (
long long *) vals;
247 rep << *(gp.llp+loc);
253 gp.ullp = (
unsigned long long *) vals;
254 rep << *(gp.ullp+loc);
262 float attr_val = *(
float*)vals;
263 bool is_a_fin = isfinite(attr_val);
264 gp.fp = (
float *) vals;
266 rep << setprecision(10);
268 string tmp_rep_str = rep.str();
269 if (tmp_rep_str.find(
'.') == string::npos
270 && tmp_rep_str.find(
'e') == string::npos
271 && tmp_rep_str.find(
'E') == string::npos
272 && (
true == is_a_fin)){
280 double attr_val = *(
double*)vals;
281 bool is_a_fin = isfinite(attr_val);
282 gp.dp = (
double *) vals;
283 rep << std::showpoint;
284 rep << std::setprecision(17);
286 string tmp_rep_str = rep.str();
287 if (tmp_rep_str.find(
'.') == string::npos
288 && tmp_rep_str.find(
'e') == string::npos
289 && tmp_rep_str.find(
'E') == string::npos
290 && (
true == is_a_fin)) {
296 return string(
"UNKNOWN");
307 else if (s ==
"Int8")
309 else if (s ==
"UInt8")
311 else if (s ==
"Int16")
313 else if (s ==
"UInt16")
314 return attr_uint16_c;
315 else if (s ==
"Int32")
317 else if (s ==
"UInt32")
318 return attr_uint32_c;
319 else if (s ==
"Int64")
321 else if (s ==
"UInt64")
322 return attr_uint64_c;
323 else if (s ==
"Float32")
324 return attr_float32_c;
325 else if (s ==
"Float64")
326 return attr_float64_c;
327 else if (s ==
"String")