MCPcopy Create free account
hub / github.com/GreycLab/CImg / main

Function main

examples/generate_loop_macros.cpp:311–353  ·  view source on GitHub ↗

----------------- Main Procedure -----------------

Source from the content-addressed store, hash-verified

309// Main Procedure
310//-----------------
311int main(int argc, char **argv) {
312
313 cimg_usage("Generate C++ macros to deal with MxN[xP] neighborhood loops within the CImg Library");
314
315 // Read command line arguments
316 //----------------------------
317 const char *const size = cimg_option("-s","5x4","Size of the neighborhood");
318 const bool do_forN = cimg_option("-forN",true,"Generate 'cimg_forN()'");
319 const bool do_for_inN = cimg_option("-for_inN",true,"Generate 'cimg_for_inN()'");
320 const bool do_for = cimg_option("-for",true,"Generate 'cimg_forMxNxP()'");
321 const bool do_for_in = cimg_option("-for_in",true,"Generate 'cimg_for_inMxNxP()'");
322 const bool do_get = cimg_option("-get",true,"Generate 'cimg_getMxNxP()'");
323 if (cimg_option("-h",false,0)) std::exit(0);
324
325 unsigned int M = 1, N = 1 , P = 1;
326 std::sscanf(size,"%u%*c%u%*c%u",&M,&N,&P);
327 if (!M || !N || !P || (M==1 && N==1 && P==1)) {
328 std::fprintf(stderr,"\n%s : Error, bad neighborhood size '%s'\n",argv[0],size);
329 std::exit(0);
330 }
331 if (!do_forN && !do_get && !do_for) return 0;
332
333 if (P>1)
334 std::printf("// Define %ux%ux%u loop macros\n"
335 "//----------------------------\n",M,N,P);
336 else
337 std::printf("// Define %ux%u loop macros\n"
338 "//-------------------------\n",M,N);
339
340 if (do_forN) {
341 if (N>1) generate_forN(N);
342 if (P>1 && P!=N) generate_forN(P);
343 }
344 if (do_for_inN) {
345 if (N>1) generate_for_inN(N);
346 if (P>1 && P!=N) generate_for_inN(P);
347 }
348 if (do_for) generate_forMxNxP(M,N,P);
349 if (do_for_in) generate_for_inMxNxP(M,N,P);
350 if (do_get) generate_getMxNxP(M,N,P);
351
352 return 0;
353}

Callers

nothing calls this directly

Calls 5

generate_forNFunction · 0.85
generate_for_inNFunction · 0.85
generate_forMxNxPFunction · 0.85
generate_for_inMxNxPFunction · 0.85
generate_getMxNxPFunction · 0.85

Tested by

no test coverage detected