Particle::Particle(int p, double hs_sigma, double lj_sigma, double lj_epsilon, double jg_lambda0, double jg_lambda1, double jg_lambda2, double jg_epsilon1, double jg_epsilon2){ // ptype = p; init_params(); assign_params(p, hs_sigma, lj_sigma, lj_epsilon, jg_lambda0, jg_lambda1, jg_lambda2, jg_epsilon1, jg_epsilon2); }
Particle::Particle(){ // assume 3D LJ //zero_coords(3); assign_params(0, HS_SIGMA, LJ_SIGMA, LJ_EPSILON, JG_LAMBDA0, JG_LAMBDA1, JG_LAMBDA2, JG_EPSILON1, JG_EPSILON2); }
struct narg_result narg_findopt( char **argv, const struct narg_optspec *optv, struct narg_optparam *ansv, unsigned optc, unsigned max_positional_args, unsigned dashes_longopt) { // Be able to guarrantee that the character data are not modified // even though the api does not; that would require a client side cast. const char **args = (const char**)argv; argv = NULL; const unsigned dashes_shortopt = (dashes_longopt > 1) ? dashes_longopt - 1 : dashes_longopt ; struct narg_optparam posargs = {0, NULL}; // positional (non-optional) arguments for (unsigned a=1; ; ++a) { const char *arg = args[a]; if (arg == NULL) { ignore_rest: max_positional_args = 0; positional_argument: assign_params(&posargs, args+a, 1, 0, &posargs, ansv, optc, args); if (max_positional_args) { --max_positional_args; continue; } break; } const unsigned dashcount = leadingchars(arg, '-'); if (dashcount < dashes_shortopt) { goto positional_argument; } arg += dashcount; //shortopt loop for (;;) { unsigned len_paramsep; unsigned expectedlen; if (dashcount >= dashes_longopt) { len_paramsep = 1; // strlen("=") expectedlen = strlen_delim(arg, '='); } else { len_paramsep = 0; // strlen("") int_fast8_t test = narg_utf8len(arg); if (test == -1) { struct narg_result ret = { .err=NARG_EILSEQ, .arg=a }; return ret; } expectedlen = test; } unsigned o; for (o=0; o != optc; o++) { if (dashcount >= dashes_longopt) { if (has_prefix_of_len(arg, optv[o].longopt, expectedlen)) { break; } } if (dashcount == dashes_shortopt) { if (has_prefix_of_len(arg, optv[o].shortopt, expectedlen)) { break; } } } if (o == optc) { struct narg_result ret = { .err=NARG_ENOSUCHOPTION, .arg=a }; return ret; } arg += expectedlen; const unsigned expectedparams = narg_wordcount(optv[o].metavar); if (expectedparams == 0) { ansv[o].paramv = args + a; ansv[o].paramc = 1; if (arg[0]) { if (len_paramsep) { struct narg_result ret = { .err = NARG_EUNEXPECTEDPARAM, .arg = a }; return ret; } continue; //shortopt loop } if (optv[o].metavar == &narg_metavar.ignore_rest) { arg = args[++a]; goto ignore_rest; } } else { const unsigned num_firstparam = (arg[0]) ? 1 // the first parameter is in the option argument : 0 // zero parameters in the option argument ; const char **paramvec = args + a + 1 - num_firstparam; unsigned paramcount = num_firstparam; while (paramcount != expectedparams && paramvec[paramcount]) { ++paramcount; } if (paramcount != expectedparams) { struct narg_result ret = { .err = NARG_EMISSINGPARAM, .arg = a }; return ret; } if (num_firstparam) { paramvec[0] = arg + len_paramsep; } assign_params(ansv+o, paramvec, expectedparams, 1-num_firstparam, &posargs, ansv, optc, args); a += expectedparams - num_firstparam; } break; }