MCPcopy Create free account
hub / github.com/SGL-UT/gnsstk / initialize

Method initialize

core/tests/df_diff.cpp:140–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138 }
139
140 bool initialize(int argc, char *argv[]) noexcept
141 {
142 gnsstk::CommandOptionWithAnyArg
143 input1Option('1', "input1", "First file to take the input from.", true),
144 input2Option('2', "input2", "Second file to take the input from.", true),
145 lineSkipOption('l', "lines", "Number of lines to skip at beginning of file."),
146 epsilonOption('e', "epsilon", "Percent allowable difference in floating point values."),
147 outputOption('o', "output", "A file to receive the output. The default is stdout."),
148 regexOption('X', "regexclude", "Exclude lines matching a regular"
149 " expression"),
150 igregOption('I', "ign-reg", "Ignore column X (starting with 0) on"
151 " lines matching regular expression Y, ARG=X,Y"),
152 lastLineOption('z', "last", "ignore the last X lines of the file");
153
154 if (!BasicFramework::initialize(argc,argv))
155 return false;
156
157 input1Fn = input1Option.getValue()[0];
158 input2Fn = input2Option.getValue()[0];
159
160 input1.open(input1Fn.c_str(), istringstream::in);
161 input2.open(input2Fn.c_str(), istringstream::in);
162
163 if (!input1)
164 {
165 cerr << "Could not open: " << input1Fn << endl;
166 exitCode=1;
167 return false;
168 }
169
170 if (!input2)
171 {
172 cerr << "Could not open: " << input2Fn << endl;
173 exitCode=1;
174 return false;
175 }
176
177 // Determine total number of lines in input file 1
178 string line;
179 while (getline(input1, line))
180 totalLines++;
181
182 if (debugLevel)
183 cout << "File 1 has " << totalLines << " lines" << endl;
184
185 // Determine how many lines to ignore at the end of the file
186 if (lastLineOption.getCount())
187 lastlineValue = gnsstk::StringUtils::asInt(lastLineOption.getValue()[0]);
188
189 totalLines = totalLines - lastlineValue;
190
191 // clear and reset the buffer for input file 1
192 input1.clear();
193 input1.seekg(0,ios::beg);
194
195 if (outputOption.getCount())
196 outputFn = outputOption.getValue()[0];
197

Callers 6

mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45

Calls 14

asIntFunction · 0.85
asDoubleFunction · 0.85
numWordsFunction · 0.85
firstWordFunction · 0.85
isDigitStringFunction · 0.85
asUnsignedFunction · 0.85
wordsFunction · 0.85
rdstateMethod · 0.80
push_backMethod · 0.80
getValueMethod · 0.45
openMethod · 0.45
getCountMethod · 0.45

Tested by

no test coverage detected