Orbiter 2022
Combinatorial Objects
function_polish_description.cpp
Go to the documentation of this file.
1/*
2 * function_polish_description.cpp
3 *
4 * Created on: Apr 18, 2020
5 * Author: betten
6 */
7
8
9#include "foundations.h"
10
11
12using namespace std;
13
14
15namespace orbiter {
16namespace layer1_foundations {
17
18
20{
21 nb_constants = 0;
22 //const_names = NULL;
23 //const_values = NULL;
24 nb_variables = 0;
25 //variable_names = NULL;
26 code_sz = 0;
27 //code = NULL;
28}
29
31{
32}
33
34
36 int argc, std::string *argv,
37 int verbose_level)
38{
39 int f_v = (verbose_level >= 1);
40 int i, i0, h;
42
43 if (f_v) {
44 cout << "function_polish_description::read_arguments" << endl;
45 }
46 for (i = 0; i < argc; i++) {
47
48 if (ST.stringcmp(argv[i], "-const") == 0) {
49 if (f_v) {
50 cout << "-const" << endl;
51 }
52 i0 = i + 1;
53 for (++i; i < argc; i++) {
54 if (ST.stringcmp(argv[i], "-const_end") == 0) {
55 break;
56 }
57 }
58 if (i < argc) {
59 nb_constants = (i - i0) >> 1;
60
61 for (h = 0; h < nb_constants; h++) {
62
63 string str;
64
65 str.assign(argv[i0 + 2 * h + 0]);
66
67 const_names.push_back(str);
68
69 str.assign(argv[i0 + 2 * h + 1]);
70
71 const_values.push_back(str);
72
73 }
74 if (f_v) {
75 cout << "read " << nb_constants << " constants" << endl;
76 }
77 }
78 else {
79 cout << "cannot find -cost_end command" << endl;
80 exit(1);
81 }
82 }
83 else if (ST.stringcmp(argv[i], "-var") == 0) {
84 if (f_v) {
85 cout << "-var" << endl;
86 }
87 i0 = i + 1;
88 for (++i; i < argc; i++) {
89 if (ST.stringcmp(argv[i], "-var_end") == 0) {
90 break;
91 }
92 }
93 if (i < argc) {
94 nb_variables = i - i0;
95
96
97 for (h = 0; h < nb_variables; h++) {
98
99 string str;
100
101 str.assign(argv[i0 + h]);
102
103 variable_names.push_back(str);
104
105 }
106 if (f_v) {
107 cout << "read " << nb_variables << " variables" << endl;
108 }
109 }
110 else {
111 cout << "cannot find -var_end command" << endl;
112 exit(1);
113 }
114 }
115 else if (ST.stringcmp(argv[i], "-code") == 0) {
116 if (f_v) {
117 cout << "-code" << endl;
118 }
119 i0 = i + 1;
120 for (++i; i < argc; i++) {
121 if (ST.stringcmp(argv[i], "-code_end") == 0) {
122 break;
123 }
124 }
125 if (i < argc) {
126 code_sz = i - i0;
127 for (h = 0; h < code_sz; h++) {
128
129 string str;
130
131 str.assign(argv[i0 + h]);
132
133 code.push_back(str);
134 }
135 if (f_v) {
136 cout << "read " << code_sz << " code items" << endl;
137 for (h = 0; h < code_sz; h++) {
138 cout << h << " : " << code[h] << endl;
139 }
140 }
141 }
142 else {
143 cout << "cannot find -code_end command" << endl;
144 exit(1);
145 }
146 }
147 else if (ST.stringcmp(argv[i], "-function_end") == 0) {
148 if (f_v) {
149 cout << "-function_end" << endl;
150 }
151 break;
152 }
153 else {
154 cout << "function_polish_description::read_arguments "
155 "unrecognized option " << argv[i] << endl;
156 }
157 } // next i
158 if (f_v) {
159 cout << "function_polish_description::read_arguments done" << endl;
160 }
161 return i + 1;
162}
163
165{
166 cout << "-function_polish_description" << endl;
167}
168
169
170}}
171
172
functions related to strings and character arrays
int read_arguments(int argc, std::string *argv, int verbose_level)
the orbiter library for the classification of combinatorial objects