 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
25 unsigned int i, j, start(0), last = strlen(
string);
27 if ( last < 1 )
return string;
29 while ( isspace(
string[start]) && start < strlen(
string) ) start++;
34 for ( i=start; i<strlen(
string); i++ ) {
35 if (
string[i] !=
'\n' &&
string[i] !=
'\r' ) {
36 if (
string[i] <
'\r' ) aptr[j] =
' ';
37 else aptr[j] =
string[i];
38 if ( aptr[j] !=
' ' ) last = j;
51 size_t i, j(0), start(0), last(s.length());
53 if ( last < 1 )
return s;
56 s.erase(0, s.find_first_not_of(
" \t"));
58 for ( i=start; i<s.length(); i++ ) {
59 if ( s[i] !=
'\n' && s[i] !=
'\r' ) {
60 if ( s[i] <
'\r' ) s[j] =
' ';
62 if ( s[j] !=
' ' ) last = j;
79 cout <<
"Removing square brackets from tags" << endl;
81 for ( block = star->
block; block; block = block->
next ) {
82 for ( item = block->
item; item; item = item->
next ) {
93 if ( item_tag == tag )
return true;
97 if ( item_tag == tag )
return true;
114 cout <<
"DEBUG init_star: Initializing" << endl;
118 memset(star, 0,
sizeof(
Bstar));
134 if ( star == NULL )
return 0;
137 cout <<
"DEBUG kill_star: Deleting STAR data base" << endl;
141 for ( block=star->
block; block; ) {
142 block2 = block->
next;
165 if ( block == NULL )
return 0;
170 cout <<
"DEBUG kill_block: Deleting block " << block->
tag << endl;
172 for ( item = block->
item; item; ) {
184 delete[] (
char*) block;
199 if ( item == NULL )
return 0;
202 cout <<
"DEBUG kill_item: Deleting item " << item->
tag << endl;
209 delete[] (
char*) item;
250 error_show(
"No file names found!", __FILE__, __LINE__);
258 cout <<
"DEBUG read_star: STAR filenames: " << endl;
259 for ( thisfile = file_list; thisfile; thisfile = thisfile->
next )
260 cout <<
" " << *thisfile;
265 ifstream* fstar =
new ifstream;
271 int comment_done(0), comment_add(1);
274 for ( thisfile = file_list; thisfile; thisfile = thisfile->
next ) {
276 cerr <<
"Warning: Carriage returns not fixed in " << *thisfile << endl;
282 cout <<
"Opening " << *thisfile << endl;
283 fstar->open(thisfile->
c_str());
284 if ( fstar->fail() ) {
290 cout <<
"# Reading STAR file: " << *thisfile << endl;
293 while ( !comment_done ) {
294 getline(*fstar, sline);
297 if ( fstar->eof() ) comment_done = 1;
302 sline.erase(0, sline.find_first_not_of(
" \t"));
303 if ( sline.compare(0, 5,
"data_", 5) == 0 ) comment_done = 1;
304 else if ( comment_add ) comment = comment + sline +
"\n";
313 if ( strncmp(aptr,
"data_", 5) == 0 ) {
316 for ( block = star->
block; block->
next; block = block->
next ) ;
320 cerr <<
"Error: No data blocks in file " << *thisfile << endl;
328 for ( block = star->
block; block->
next; block = block->
next )
335 cout <<
"DEBUG read_star: Transferring comments:" << star->
comment << endl << endl;
340 cout <<
"DEBUG read_star: Done!" << endl;
366 int loop_counter(0), loop = -1;
370 if ( strlen(aptr) > 0 )
376 cout <<
"# Reading block: " << block->
tag << endl;
383 if ( strncmp(aptr,
"data_", 5) == 0 ) {
386 if ( aptr[0] ==
'_' || aptr[0] ==
'#' || aptr[0] ==
';' ) {
389 }
else if ( strncmp(aptr,
"loop_", 5) == 0 ) {
391 loop = ++loop_counter;
394 if ( item ) item->
next = new_item;
396 block->
item = item = new_item;
399 while ( item->
next ) {
433 int k, digit(0), alpha(0);
438 if ( aptr[0] ==
'#' && strlen(aptr) < 2 )
return 0;
439 if ( aptr[0] ==
'_' && strlen(aptr) < 4 )
return 0;
442 cout <<
"DEBUG single item: Starting" << endl;
446 if ( aptr[0] ==
'#' || aptr[0] ==
';' ) {
447 item->
tag =
"comment";
449 sscanf(aptr,
"%s%n", temp, &k);
450 item->
tag = &temp[1];
452 if ( strlen(aptr) < 1 ) {
458 if ( aptr[0] ==
'#' ) {
461 }
else if ( aptr[0] ==
'\'' ) {
463 k = strcspn(aptr,
"\'");
466 }
else if ( aptr[0] ==
'\"' ) {
467 while ( aptr[0] ==
'\"' ) aptr++;
468 k = strcspn(aptr,
"\"");
471 }
else if ( aptr[0] ==
';' ) {
473 k = strcspn(aptr,
"\n");
475 if ( k > 0 ) svalue = aptr;
476 while ( fstar->getline(aline,
MAXLINELEN) && aline[0] !=
';' ) {
477 k = strcspn(aline,
"\n");
479 if ( k > 0 ) svalue += aline;
482 k = strcspn(aptr,
"#");
487 if ( svalue.
length() < 1 ) {
488 cerr <<
"Warning: Tag " << item->
tag <<
" value not read!" << endl;
493 svalue = svalue.
remove(
'\"');
497 for ( k=0; k<svalue.
length(); k++ ) {
498 if ( isalpha(svalue[k]) ) alpha++;
499 else if ( isdigit(svalue[k]) ) digit++;
504 cout <<
"DEBUG single item: Tag: " << item->
tag <<
", maxlen=" << item->
maxlen << endl;
505 cout <<
"DEBUG single item: Data: " << *(item->
data) << endl;
538 int i, j, k, loopdone(0), number(0);
543 cout <<
"DEBUG loop: Starting" << endl;
549 sscanf(aptr,
"%s%n", aval, &k);
550 item->
tag = &aval[1];
556 cout <<
"DEBUG loop: number of tags=" << nitems << endl;
559 cerr <<
"Error: No tags in the loop!" << endl;
567 memset(sval, 0, nitems*
sizeof(
Bstring));
568 memset(data, 0, nitems*
sizeof(
Bstring*));
569 memset(datalist, 0, nitems*
sizeof(
Bstring*));
571 loopdone = number = 0;
572 if ( strlen(aptr) < 1 || aptr[0] ==
'\n' || aptr[0] ==
'#' )
574 while ( !loopdone ) {
576 cout <<
"DEBUG loop: starting " << number <<
" " << aline << endl;
579 for ( i=0; i<nitems && !loopdone; i++ ) {
581 if ( strlen(aptr) < 1 ) {
586 if ( aline[0] ==
';' ) {
588 j = strcspn(aptr,
"\n");
591 while ( fstar->getline(aline,
MAXLINELEN) && aline[0] !=
';' ) {
592 j = strcspn(aline,
"\n");
594 sval[i] = sval[i] + aline;
597 if ( sscanf(aptr,
"%s", aval) < 1 ) {
600 if ( sscanf(aptr,
"%s", aval) < 1 )
603 }
else sval[i] = aval;
605 if ( ( aptr = strchr(aptr,
' ') ) == NULL )
606 aptr = aline + strlen(aline);
609 cout <<
"DEBUG loop: finishing " << number << endl;
610 for ( i=0; i<nitems; i++ ) cout <<
tab << sval[i] << endl;
613 if ( i == nitems && !loopdone ) {
615 for ( j=0, item=
item_list; j<nitems; j++, item=item->
next ) {
616 sval[j] = sval[j].
remove(
'\"');
617 if ( item->maxlen < (
int)sval[j].
length() ) item->maxlen = sval[j].
length();
619 if ( !datalist[j] ) datalist[j] = data[j];
621 for ( k=0; k<(int)sval[j].
length(); k++ ) {
622 if ( isalpha(sval[j][k]) ) alpha++;
623 else if ( isdigit(sval[j][k]) ) digit++;
631 if ( strlen(aptr) < 1 || aptr[0] ==
'\n' || aptr[0] ==
'#' )
635 for ( i=0, item=
item_list; i<nitems && item; i++, item=item->
next )
636 item->data = datalist[i];
639 cout <<
"DEBUG loop: Columns=" << nitems <<
" Rows=" << number << endl;
648 cout <<
"DEBUG loop: memory freed" << endl;
676 if ( star->
split < 9 )
677 if ( filename.
length() < 1 )
return -1;
679 ofstream* fstar =
new ofstream;
680 Bstring default_comment =
"# Written by Bsoft";
684 if ( star->
split == 0 ) {
685 fstar->open(filename.
c_str());
686 if ( fstar->fail() ) {
687 cerr <<
"Error: Not able to write " << filename << endl;
692 cout <<
"# Writing file: " << filename << endl;
694 *fstar << star->
comment << endl;
697 cout <<
"Splitting STAR file (" << star->
split <<
"):" << endl;
705 snprintf(format, 32,
"_%%0%dd.", star->
split);
707 for ( i=0, block = star->
block; block; block = block->
next, i++ )
if ( block->
item ) {
709 if ( star->
split == 9 ) {
711 blockname = block->
tag;
712 blockname = blockname.
replace(
' ',
'_');
713 blockname +=
".star";
715 blockname =
Bstring(i+1,
"%09d.star");
720 fstar->open(blockname.
c_str());
721 if ( fstar->fail() ) {
722 cerr <<
"Error: Not able to write " << blockname << endl;
726 cout <<
"# Writing file: " << blockname << endl;
727 *fstar << star->
comment << endl;
730 if ( star->
split ) fstar->close();
733 if ( star->
split == 0 ) fstar->close();
753 long j, m, size, nitems, pos;
759 *fstar << endl <<
"data_" << block->
tag << endl << endl;
763 for ( item = block->
item; item; item = item->
next ) {
767 if ( item->
tag[0] ==
'_' ) tag = item->
tag;
768 else tag =
"_" + item->
tag;
770 if ( item->
loop < 0 ) {
773 *fstar << tag << endl;
774 *fstar <<
";" << endl;
775 for ( j=0; j<item->
data->
length(); j += linelength ) {
777 if ( size > linelength ) size = linelength;
780 *fstar << tstr << endl;
783 *fstar <<
";" << endl;
788 *fstar << tag << endl <<
"\"" << item->
data <<
"\"" << endl;
789 }
else if ( strchr(item->
data->
c_str(),
' ') ) {
790 *fstar << setw(40) << tag <<
" \"" << *(item->
data) <<
"\"" << endl;
792 *fstar << setw(40) << tag <<
" " << *(item->
data) << endl;
794 *fstar << setw(40) << tag <<
" " << *(item->
data) << endl;
797 *fstar << *(item->
data) << endl;
800 }
else if ( item->
data ) {
801 *fstar << endl <<
"loop_" << endl;
802 for ( nitems=0, item2=item; item2 && item2->
loop == item->
loop; item2=item2->
next, nitems++ ) {
803 if ( item2->
tag[0] ==
'_' ) tag = item2->
tag;
804 else tag =
"_" + item2->
tag;
805 *fstar << tag << endl;
808 for ( j=0, item2=item; j<nitems; item2=item2->
next, j++ )
809 dptr[j] = item2->
data;
813 for ( j=0, item2=item; j<nitems; item2=item2->
next, j++ ) {
814 if ( item2->
maxlen > linelength ) {
826 for ( m=0; m<dptr[j]->
length(); m += linelength ) {
827 size = dptr[j]->
length() - m;
828 if ( size > linelength )
831 tstr += dptr[j]->
substr(m, size) +
"\n";
834 if ( j == nitems - 1 )
844 if ( dptr[j]->contains(
"'") ) *dptr[j] =
"\"" + *dptr[j] +
"\"";
851 if ( pos + item2->
maxlen > linelength && j < nitems - 1 ) {
855 dptr[j] = dptr[j]->
next;
857 *fstar << tstr << endl;
859 for ( j=1; item->
next && j<nitems; j++ ) item = item->
next;
882 time_t ti = time(NULL);
887 for ( i=0; i<n; i++ )
888 new_comment = new_comment + strings[i] +
" ";
890 new_comment = new_comment +
"\n# " + asctime(localtime(&ti)) +
"\n";
893 cout << endl << new_comment << endl;
909 if ( len < 1 ) len = 10000000000;
917 for ( s = strarr; s; s = s->
next ) {
918 if ( (*s)[0] ==
'#' ) {
944 for ( block = star->
block; block; block = block->
next ) {
945 for ( item = block->
item; item; item = item->
next ) {
946 for ( data = item->
data; data; data = data->
next )
972 cout <<
"Changing all tags \"" << tag <<
"\" to \"" << newtag <<
"\"" << endl;
974 for ( block = star->
block; block; block = block->
next ) {
975 for ( item = block->
item; item; item = item->
next ) {
976 if ( item->
tag == tag ) {
998 for ( block = star->
block; block; block = block->
next ) {
999 cout << endl <<
"data_" << block->
tag << endl;
1000 cout << endl <<
"loop_" << endl;
1001 cout <<
"_star_tag" << endl;
1002 cout <<
"_star_type" << endl;
1003 for ( item = block->
item; item; item = item->
next ) {
1004 tag =
"\"_" + item->
tag +
"\"";
1005 cout << setw(40) << item->
tag;
1007 cout <<
"String" << endl;
1009 cout <<
"Number" << endl;
1036 if ( !item ) i = -1;
1039 cout <<
"DEBUG item_index: " << tag <<
" " << i << endl;
1056 for ( block = star->
block; block; block = block->
next ) {
1057 for ( item = block->
item; item; item = item->
next ) {
1058 if ( item->
tag == tag ) {
1067 cout <<
"DEBUG item_get_first_block: " << tag <<
" " << &block << endl;
1090 cout <<
"DEBUG item_find: " << tag <<
" " << &item << endl;
1119 cout <<
"DEBUG item_find_or_make: " << tag <<
" " << &item << endl;
1140 for ( block = star->
block; block; block = block->
next ) {
1141 for ( item = block->
item; item; item = item->
next ) {
1142 if ( item->
tag == tag )
1148 cout <<
"DEBUG item_get_number: " << tag <<
" " << &number << endl;
1168 for ( item = block->
item; item; item = item->
next ) {
1169 if ( item->
tag == tag )
1174 cout <<
"DEBUG item_get_number_for_block: " << tag <<
" " << &number << endl;
1193 char*
string = NULL;
1195 for ( item = block->
item; item && !
string; item = item->
next ) {
1196 if ( item->
tag == tag ) {
1198 for ( i=0; i<item->
data->
length(); i++ )
string[i] = (*item->
data)[i];
1204 cout <<
"DEBUG item_get_string: " << tag <<
" " <<
string << endl;
1224 for ( item = block->
item; item; item = item->
next ) {
1225 if ( item->
tag == tag )
1230 cout <<
"DEBUG item_copy_string: " << tag <<
" " <<
string << endl;
1250 for ( item = block->
item; item; item = item->
next ) {
1251 if ( item->
tag == tag ) {
1252 if ( *(item->
data) ==
"?" || *(item->
data) ==
"." ) value = 0;
1258 cout <<
"DEBUG item_get_integer: " << tag <<
" " << value << endl;
1278 for ( item = block->
item; item; item = item->
next ) {
1279 if ( item->
tag == tag ) {
1280 if ( *(item->
data) ==
"?" || *(item->
data) ==
"." )
1281 value = strtod (
"NAN()",NULL);
1287 cout <<
"DEBUG item_get_float: " << tag <<
" " << value << endl;
1308 if ( !block )
return -1;
1310 long len =
string.length();
1312 if ( len < 1 )
return 0;
1324 cout <<
"DEBUG item_put_string: " << tag <<
" " << *(item->
data) << endl;
1339 if ( !block )
return -1;
1347 for (
string = list; string;
string =
string->
next ) {
1349 if ( !item->
data ) item->
data = data;
1354 cout <<
"DEBUG item_put_string_list: " << tag <<
" " << *(item->
data) << endl;
1370 if ( !block )
return -1;
1372 char string[32] =
"";
1373 snprintf(
string, 32, format, value);
1375 long len = strlen(
string);
1387 cout <<
"DEBUG item_put_integer: " << tag <<
" " << *(item->
data) << endl;
1403 if ( !block )
return -1;
1405 char string[32] =
"";
1406 snprintf(
string, 32, format, value);
1407 if ( isnan(value) ) snprintf(
string, 32,
".");
1409 long len = strlen(
string);
1421 cout <<
"DEBUG item_put_float: " << tag <<
" " << *(item->
data) << endl;
1437 size_t offset,
const char* format)
1439 if ( !block )
return -1;
1443 if ( data )
while ( data->
next ) data = data->
next;
1448 char string[32] =
"";
1451 for ( it = (
char **) list; it; it = (
char **) *it ) {
1452 if ( strstr(format,
"s") )
1453 snprintf(
string, 32, format, (
char *)it + offset);
1454 else if ( strstr(format,
"d") )
1455 snprintf(
string, 32, format, *((
int*)((
char *)it + offset)));
1456 else if ( strstr(format,
"lf") )
1457 snprintf(
string, 32, format, *((
double*)((
char *)it + offset)));
1459 snprintf(
string, 32, format, *((
float*)((
char *)it + offset)));
1460 if ( strstr(
string,
"nan") ) snprintf(
string, 32,
".");
1462 if ( !item->
data ) item->
data = data;
1463 if ( item->
maxlen < strlen(
string) ) item->
maxlen = strlen(
string);
1467 cout <<
"DEBUG item_put_list: " << tag <<
" (" << offset <<
") " << *(item->
data) << endl;
1487 float* value,
const char* format)
1489 if ( !block || number < 1 || !value )
return -1;
1493 if ( data )
while ( data->
next ) data = data->
next;
1497 char string[32] =
"";
1500 for ( i=0; i<number; i++ ) {
1501 snprintf(
string, 32, format, value[i]);
1502 if ( strstr(
string,
"nan") ) snprintf(
string, 32,
".");
1504 if ( !item->
data ) item->
data = data;
1505 if ( item->
maxlen < strlen(
string) ) item->
maxlen = strlen(
string);
1509 cout <<
"DEBUG item_put_float_array: " << tag <<
" " << *(item->
data) << endl;
1529 size_t offset,
const char* format)
1531 if ( !block )
return -1;
1535 if ( data )
while ( data->
next ) data = data->
next;
1540 char string[32] =
"";
1543 for ( it = (
char **) list; it; it = (
char **) *it ) {
1544 if ( strstr(format,
"lf") )
1545 angle = *((
double*)((
char *)it + offset));
1547 angle = *((
float*)((
char *)it + offset));
1548 snprintf(
string, 32, format, angle*180.0/
M_PI);
1549 if ( strstr(
string,
"nan") ) snprintf(
string, 32,
".");
1551 if ( !item->
data ) item->
data = data;
1552 if ( item->
maxlen < strlen(
string) ) item->
maxlen = strlen(
string);
1556 cout <<
"DEBUG item_put_float_list: " << tag <<
" " << *(item->
data) << endl;
1578 cout <<
"Listing all items associated with tag \"" << tag <<
"\"" << endl;
1580 for ( block = star->
block; block; block = block->
next ) {
1581 for ( item = block->
item; item; item = item->
next ) {
1582 if ( item->
tag == tag ) {
1583 for ( data = item->
data; data; data = data->
next )
1584 cout <<
" " << *data;
1608 cout <<
"Deleting all items associated with tag \"" << tag <<
"\"" << endl;
1610 for ( block = star->
block; block; block = block->
next )
1631 cout <<
"Deleting tag \"" << tag <<
"\" from block" << endl;
1632 for ( item = item2 = block->
item; item; ) {
1633 if ( item->
tag == tag ) {
1634 if ( item == block->
item ) {
1669 cout <<
"Deleting all blocks associated with tag \"" << tag <<
"\"" << endl;
1671 for ( block = block2 = star->
block; block; ) {
1672 for ( del = 0, item = block->
item; item && del == 0; item = item->
next )
1673 if ( item->
tag == tag ) del = 1;
1675 if ( block == star->
block ) {
1682 block = block2->
next;
1687 block = block->
next;
1692 cout <<
"Blocks deleted: " << ndel << endl;
1711 int idata, total(0);
1718 cout <<
"Modifying all integer items associated with tag \"" << tag <<
"\"" << endl;
1719 cout <<
"Scale and shift: " << iscale <<
" " << ishift << endl;
1721 cout <<
"Modifying all integer items associated with tag \"" << tag <<
"\"" << endl;
1723 for ( block = star->
block; block; block = block->
next ) {
1724 for ( item = block->
item; item; item = item->
next ) {
1725 if ( item->
tag == tag ) {
1726 snprintf(format, 32,
"%%%dd", item->
maxlen);
1727 for ( data = item->
data; data; data = data->
next ) {
1728 idata = data->
integer()*iscale + ishift;
1729 data[0] =
Bstring(idata, format);
1753 int total(0), type, len;
1754 float fdata, maxpre;
1761 cout <<
"Modifying all floating point items associated with tag \"" << tag <<
"\"" << endl;
1762 cout <<
"Scale and shift: " << scale <<
" " << shift << endl;
1764 cout <<
"Modifying all floating point items associated with tag \"" << tag <<
"\"" << endl;
1767 for ( block = star->
block; block; block = block->
next ) {
1768 for ( item = block->
item; item; item = item->
next ) {
1769 if ( item->
tag == tag ) {
1771 if ( type < 2 ) snprintf(format, 32,
"%%%d.0f", item->
maxlen);
1772 maxpre = pow(10.0, 1.0*format[1])*scale + shift;
1773 if ( maxpre < 1 ) maxpre = 1;
1774 format[1] = (char) (log(maxpre)/log(10.0) + 1) +
'0';
1776 cout <<
"DEBUG item_float_scale_shift: format = " << format << endl;
1777 for ( data = item->
data; data; data = data->
next ) {
1778 fdata = data->
real()*scale + shift;
1779 data[0] =
Bstring(fdata, format);
1780 len = (*data).length();
1811 for ( i=0; i<n; i++ ) {
1812 tag_pattern = va_arg(ap,
char *);
1813 for ( item = block->
item; item; item = item->
next ) {
1823 cout <<
"DEBUG loop_set_identifier: loop=" << loop <<
" number=" << nloop << endl;
1839 int type(0), pre, post, maxpre(0), maxpost(0);
1843 strcpy(format,
"%s");
1846 for ( data = item->
data; data; data = data->
next ) {
1847 if ( data->
find(
".") > -1 && data->
length() > 1 ) {
1851 if ( maxpre < pre ) maxpre = pre;
1852 if ( maxpost < post ) maxpost = post;
1857 snprintf(format, 32,
"%%%d.%df", maxpre + maxpost + 1, maxpost);
1859 snprintf(format, 32,
"%%%dd", item->
maxlen);
char * clean_line(char *string)
Bstring remove(const char c)
int item_delete_from_block(Bstar_block *block, const char *tag)
Deletes an item associated with a given tag from a block in the STAR data base.
int kill_block(Bstar_block *block)
Destroys a STAR data block.
int block_delete(Bstar *star, Bstring &tag)
Deletes all blocks with a given tag from the STAR data base.
int string_kill(Bstring *list)
Kills a string linked list.
Header file for file checking functions.
int write_block(ofstream *fstar, Bstar_block *block, int linelength)
Writes paramaters and data from a STAR data block into an open file.
char * add_item(char **list, unsigned long size)
Adds an item to a linked list.
bool tag_compare(Bstring item_tag, Bstring tag)
Bstar_item * read_loop_items(ifstream *fstar)
Reads a loop structure with multiple items into a STAR data block from an open file.
Bstring replace(char cold, char cnew)
int error_show(string message, string file, int line)
Displays the error with file and line reference.
Bstar_item * item_find_or_make(Bstar_block *block, const char *tag)
Gets the STAR item associated with a tag in a STAR data block.
int item_put_float(Bstar_block *block, const char *tag, float value, const char *format)
Writes a floating point value into a data item associated with a specific data block and tag in a STA...
double length(vector< T > v)
long count_list(char *list)
Counts the number of items in a linked list.
int star_update_comment(Bstar *star, int n, char **strings)
Puts a set of strings and time in the main comment of the STAR data base.
int read_star(const char *filename, Bstar *star)
Reads paramaters and data into a STAR data base from a list of files.
int item_put_angle_list(Bstar_block *block, const char *tag, char *list, size_t offset, const char *format)
Writes a list of angular values in degrees into a data item associated with a specific data block and...
int kill_star(Bstar *star)
Destroys a STAR data base.
Bstar_item * item_find(Bstar_block *block, const char *tag)
Gets the STAR item associated with a tag in a STAR data block.
int item_put_string(Bstar_block *block, const char *tag, char *string)
Writes a string into a data item associated with a specific data block and tag in a STAR data base.
long star_list_comments(Bstar *star, long len)
Lists the command lines in the STAR header.
long find(const Bstring &s)
int item_delete_all(Bstar *star, const char *tag)
Deletes all items associated with a given tag from the STAR data base.
Bstar_item * read_single_item(ifstream *fstar, char *aline)
Reads a single-valued item or comment line into a STAR data block from an open file.
int detect_and_fix_carriage_return(const char *filename)
Detects carriage returns in text files and converts them to new-lines.
int item_put_string_list(Bstar_block *block, const char *tag, Bstring *list)
Writes a list of strings into a data item associated with a specific data block and tag in a STAR dat...
int item_index(Bstar_block *block, const char *tag)
Gets the STAR item associated with a tag in a STAR data block.
Bstar_block * read_block(ifstream *fstar, char *aptr, Bstring &filename)
Reads paramaters and data into a STAR data block from an open file.
int no_square_brackets(Bstar *star)
int show_tags(Bstar *star)
Prints the list of tags in the STAR data base.
Bstar_block * block_find_with_tag(Bstar *star, const char *tag)
Gets the first block associated with a tag in a STAR data base.
Header file for general utilities.
ostream & tab(ostream &out)
Bstring substr(long start, long len)
int star_set_string_lengths(Bstar *star)
Sets the maximum string lengths for each item in each block.
int item_list(Bstar *star, Bstring &tag)
Lists all items associated with a given tag from the STAR data base.
char * item_get_string(Bstar_block *block, const char *tag)
Gets a string value associated with a tag in a STAR data block.
int loop_set_identifier(Bstar_block *block, int loop, int n,...)
Assigns a loop identification number to items.
int item_put_list(Bstar_block *block, const char *tag, char *list, size_t offset, const char *format)
Writes a list of string or numeric values into a data item associated with a specific data block and ...
int item_integer_scale_shift(Bstar *star, Bstring &tag, int iscale, int ishift)
Scales and shifts all items associated with a given tag from the STAR data base.
Header file for generalized linked list functions.
int item_get_integer(Bstar_block *block, const char *tag)
Gets an integer value associated with a tag in a STAR data block.
int item_put_float_array(Bstar_block *block, const char *tag, int number, float *value, const char *format)
Writes a list of floating point numbers into a data item associated with a specific data block and ta...
Bstar * init_star()
Creates a STAR data base.
long item_get_number(Bstar *star, const char *tag)
Gets the number of values associated with a tag in a STAR data base.
float item_get_float(Bstar_block *block, const char *tag)
Gets a floating point value associated with a tag in a STAR data block.
int item_copy_string(char *string, Bstar_block *block, const char *tag)
Copies a string value associated with a tag in a STAR data block.
int write_star(const char *filename, Bstar *star)
Writes a STAR data base to one or more STAR format files.
A header file for STAR format files.
int kill_item(Bstar_item *item)
Destroys an item in a data block in a STAR data base.
bool contains(const Bstring &s)
long item_get_number_for_block(Bstar_block *block, const char *tag)
Gets the number of values associated with a tag in a STAR data block.
int item_change_tag(Bstar *star, const char *tag, const char *newtag)
Replaces one tag with another in the STAR data base.
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
int item_put_integer(Bstar_block *block, const char *tag, int value, const char *format)
Writes a integer into a data item associated with a specific data block and tag in a STAR data base.
int item_get_format(Bstar_item *item, char *format)
Gets the format from the item.
int item_float_scale_shift(Bstar *star, Bstring &tag, float scale, float shift)
Scales and shifts all items associated with a given tag from the STAR data base.