17namespace layer1_foundations {
18namespace data_structures {
38 if (strcmp(ext,
".csv") == 0) {
51 if (strcmp(ext,
".inc") == 0) {
64 if (strcmp(ext,
".xml") == 0) {
79 if (strcmp(str1,
",") == 0) {
85 sscanf(str1,
"%d", i);
96 if (strcmp(str1,
",") == 0) {
102 sscanf(str1,
"%ld", i);
118 if (c ==
' ' || c ==
'\t' ||
119 c ==
'\r' || c == 10 || c == 13) {
127 if (isdigit(c) || c ==
'-') {
129 while (isdigit(c) || c ==
'.' || c ==
'e' || c ==
'-') {
140 sscanf(str1,
"%lf", d);
154 if (c ==
' ' || c ==
'\t' ||
155 c ==
'\r' || c == 10 || c == 13) {
166 while (isalnum(c) || c ==
'_') {
176 else if (isdigit(c) || c ==
'-') {
210 if (c ==
' ' || c ==
'\t' ||
211 c ==
'\r' || c == 10 || c == 13) {
219 while (c != 0 && c !=
' ' && c !=
'\t' &&
220 c !=
'\r' && c != 10 && c != 13) {
244 if (c ==
' ' || c ==
'\t' ||
245 c ==
'\r' || c == 10 || c == 13) {
252 cout <<
"s_scan_str() error: c != '\"'" << endl;
269 else if (c ==
'\"') {
296 if (c == 10 || c == 13) {
298 sprintf(str,
"END_OF_LINE");
308 while (c != 13 && c !=
',') {
321 cout <<
"s_scan_token_comma_separated: "
322 "end of line inside string" << endl;
323 cout <<
"while scanning '" << str <<
"'" << endl;
355 int *&perm,
int °ree,
int verbose_level)
357 int f_v = (verbose_level >= 1);
360 cout <<
"string_tools::scan_permutation_from_string s = " << s << endl;
362 istringstream ins(s);
364 cout <<
"string_tools::scan_permutation_from_string before scan_permutation_from_stream" << endl;
368 cout <<
"string_tools::scan_permutation_from_string done" << endl;
373 int *&perm,
int °ree,
int verbose_level)
376 int f_v = (verbose_level >= 1);
379 cout <<
"string_tools::scan_permutation_from_string" << endl;
385 int i, a_last, a, dig, ci;
387 int si, largest_point = 0;
400 while (c ==
' ' || c ==
'\t') {
408 cout <<
"opening parenthesis" << endl;
412 while (c ==
' ' || c ==
'\t') {
418 while (c >=
'0' && c <=
'9') {
422 while (c ==
' ' || c ==
'\t') {
430 if (dig > largest_point) {
434 cout <<
"digit as string: " << s <<
", numeric: " << dig << endl;
437 cout <<
"string_tools::scan_permutation_from_stream digit < 0" << endl;
447 l1 =
MAXIMUM(l + (l >> 1), largest_point + 1);
449 cout <<
"string_tools::scan_permutation_from_stream digit = "
450 << dig <<
" >= " << l
451 <<
", extending permutation degree to "
458 for (i = 0; i < l; i++) {
462 for (i = l; i < l1; i++) {
471 for (i = 0; i < l; i++) {
473 cycle1[i] = cycle[i];
486 cout <<
"closing parenthesis, cycle = ";
487 for (i = 0; i < ci; i++)
488 cout << cycle[i] <<
" ";
491 for (i = 1; i < ci; i++) {
492 a_last = cycle[i - 1];
497 a_last = cycle[ci - 1];
512 while (c ==
' ' || c ==
'\t') {
522 perm1.m_l(largest_point + 1);
523 for (i = 0; i <= largest_point; i++) {
524 perm1.m_ii(i, perm.s_i(i));
529 degree = largest_point + 1;
531 cout <<
"read permutation: ";
559 cout <<
"Token " << setw(6) << i <<
" is '"
560 << buf <<
"'" << endl;
575 cout <<
"Token " << setw(6) << i <<
" is '"
576 << buf <<
"'" << endl;
580 strcpy(argv[i], buf);
585 cout <<
"argv:" << endl;
586 for (i = 0; i < argc; i++) {
587 cout << i <<
" : " << argv[i] << endl;
595 for (i = 0; i < argc; i++) {
624 cout <<
"Token " << setw(6) << i <<
" is '"
625 << buf <<
"'" << endl;
640 cout <<
"Token " << setw(6) << i <<
" is '"
641 << buf <<
"'" << endl;
645 strcpy(argv[i], buf);
650 cout <<
"argv:" << endl;
651 for (i = 0; i < argc; i++) {
652 cout << i <<
" : " << argv[i] << endl;
660 for (i = 0; i < argc; i++) {
672 vector<string> Arg_vec;
674 for (i = 0; i < argc; i++) {
677 string variable_name;
679 int loop_upper_bound;
681 int index_of_repeat_start;
682 int index_of_repeat_end;
684 variable_name.assign(argv[++i]);
685 loop_from = atoi(argv[++i]);
686 loop_upper_bound = atoi(argv[++i]);
687 loop_increment = atoi(argv[++i]);
689 index_of_repeat_start = i;
691 if (strcmp(argv[i],
"-repeat_end") == 0) {
692 index_of_repeat_end = i;
701 variable.assign(
"%");
702 variable.append(variable_name);
704 for (loop_var = loop_from; loop_var < loop_upper_bound; loop_var += loop_increment) {
705 for (h = index_of_repeat_start; h < index_of_repeat_end; h++) {
710 sprintf(str,
"%d", loop_var);
715 while (arg.find(variable) != std::string::npos) {
716 arg.replace(arg.find(variable), variable.length(), value_L);
720 Arg_vec.push_back(arg);
728 Arg_vec.push_back(str);
731 argc = Arg_vec.size();
732 Argv =
new string[argc];
733 for (i = 0; i < argc; i++) {
734 Argv[i].assign(Arg_vec[i]);
741 int f_v = (verbose_level >= 1);
745 cout <<
"string_tools::get_character at end" << endl;
750 cout <<
"string_tools::get_character: \"" << c
751 <<
"\", ascii=" << (int)c << endl;
761 for (i = l - 1; i >= 0; i--) {
766 else if (p[i] ==
'/') {
779 for (i = l - 1; i >= 0; i--) {
785 else if (p[i] ==
'/') {
802 for (i = len - 1; i >= 0; i--) {
827 for (i = l - 1; i >= 0; i--) {
847 q = p.substr(0, p.length() - ext.length());
859 for (i = l - 1; i >= 0; i--) {
861 q = p.substr(i + 1, l - i - 1);
875 int l2 = strlen(ext);
879 q = p.substr(l1 - l2, l2);
880 if (strcmp(p.c_str(), ext) == 0) {
882 r = q.substr(0, l1 - l2);
892 int l2 = strlen(ext);
894 if (l1 > l2 && strcmp(p + l1 - l2, ext) == 0) {
901 int i, l = strlen(p);
903 strcpy(fname_base, p);
904 for (i = l - 1; i >= 0; i--) {
905 if (fname_base[i] ==
'.') {
915 int i, l = p.length();
918 for (i = l - 1; i >= 0; i--) {
921 ext = p.substr(i, l - i);
934 int i, l = strlen(p);
938 for (i = l - 1; i >= 0; i--) {
949 int i, l = strlen(p);
953 for (i = l - 1; i >= 0; i--) {
971 while (str.find(str_t) != std::string::npos) {
972 str.replace(str.find(str_t),str_t.length(),
"\t");
975 while (str.find(str_D) != std::string::npos) {
976 str.replace(str.find(str_D),str_D.length(),
"$");
979 while (str.find(str_B) != std::string::npos) {
980 str.replace(str.find(str_B),str_B.length(),
"\\");
983 while (str.find(str_n) != std::string::npos) {
984 str.replace(str.find(str_n),str_n.length(),
"\n");
998 while (str.find(str_t) != std::string::npos) {
999 str.replace(str.find(str_t),str_t.length(),
"");
1010 sprintf(str,
"%ld", input[0]);
1012 for (i = 1; i < input_sz; i++) {
1014 sprintf(str,
"%ld", input[i]);
1026 for (i = 0; i < l; i++) {
1027 if (str[i] ==
' ') {
1030 if (str[i] ==
'\\') {
1035 if (str[i] ==
'n') {
1050 Num.
vec_scan(text.c_str(), data, data_sz);
1052 cout <<
"string_tools::text_to_three_double "
1053 "data_sz != 3, data_sz = " << data_sz << endl;
1076 strcpy(str1 + strlen(str1), p);
1077 strcpy(str1 + strlen(str1),
"\"");
1086 strcpy(str2 + strlen(str2), q);
1087 strcpy(str2 + strlen(str2),
"\"");
1089 ret = strcmp(str1, str2);
1100 if (c >=
'0' && c <=
'9') {
1110 return strcmp(str.c_str(), p);
1117 i = atoi(str.c_str());
1125 l = (int) str.length();
1127 for (i = 0; i < l; i++) {
1128 res = (res * 10) + (str[i] - 48);
1137 i = atol(str.c_str());
1145 f = atof(str.c_str());
1151 char *A = (
char *) a;
1152 char *B = (
char *) b;
1153 return strcmp(A, B);
a collection of combinatorial functions
void perm_print(std::ostream &ost, int *a, int n)
void perm_identity(int *a, long int n)
numerical functions, mostly concerned with double
void vec_scan(const char *s, double *&v, int &len)
int string_tools_compare_strings(void *a, void *b, void *data)
the orbiter library for the classification of combinatorial objects