MCPcopy Create free account
hub / github.com/apngasm/apngasm / assemble

Method assemble

cli/src/cli.cpp:162–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162int CLI::assemble(void) {
163 using std::cout;
164 std::string outfile;
165 options.outputFile(outfile);
166
167 // if(!checkOverwrite(outfile)) {
168 // return ERRCODE_OUTPUTFILE_ALREADYEXISTS;
169 // }
170
171 static const boost::regex PNG_RE(".+\\.png\\z");
172 static const boost::regex DELAY_RE("[0-9]+[:[0-9]+]?");
173 const FrameDelay DEFAULT_DELAY = options.getDefaultDelay();
174
175 std::string lastFile;
176 std::string errorFile;
177 Options::INPUTS::const_iterator arg = options.inputFilesBegin();
178 for (; arg != options.inputFilesEnd(); ++arg) {
179 if (regex_match(*arg, DELAY_RE)) {
180 if (!lastFile.empty()) {
181 const FrameDelay delay = *arg;
182 assembler.addFrame(lastFile, delay.num, delay.den);
183 lastFile.clear();
184 continue;
185 }
186 } else if (regex_match(*arg, PNG_RE) || arg->find("*", 0)) {
187 if (!lastFile.empty()) {
188 const FrameDelay delay = DEFAULT_DELAY;
189 const int frameCount = assembler.frameCount();
190 if (frameCount < assembler.addFrame(lastFile, delay.num, delay.den)) {
191 lastFile = *arg;
192 continue;
193 }
194 errorFile = lastFile;
195 } else {
196 lastFile = *arg;
197 continue;
198 }
199 } else {
200 errorFile = *arg;
201 }
202 }
203 if (!lastFile.empty()) {
204 const FrameDelay delay = DEFAULT_DELAY;
205 const int frameCount = assembler.frameCount();
206 if (frameCount >= assembler.addFrame(lastFile, delay.num, delay.den))
207 errorFile = lastFile;
208 }
209
210 if (!errorFile.empty()) {
211 // Error.
212 cout << "argument `" << errorFile << "' is invalid." << std::endl;
213 return ERRCODE_INVALIDARGUMENT;
214 }
215
216 if (assembler.frameCount() == 0)
217 cout << "apngasm " << assembler.version()
218 << "\nNo source frames were specified. Use --help for usage "
219 "information."

Callers 1

mainFunction · 0.45

Calls 7

outputFileMethod · 0.80
getDefaultDelayMethod · 0.80
inputFilesBeginMethod · 0.80
inputFilesEndMethod · 0.80
addFrameMethod · 0.80
frameCountMethod · 0.80
versionMethod · 0.80

Tested by 1

mainFunction · 0.36