void CmdLineParser::add(int id, const std::string& name, const std::string& help, char short_name) { if (id < OPTION_FIRST_AVILABLE) { THROW("invalid id"); } add_private(id, name, short_name, NO_ARGUMENT, help, ""); }
void CmdLineParser::add(int id, const std::string& name, const std::string& help, const std::string& arg_name, bool reqired_arg, char short_name) { if (id < OPTION_FIRST_AVILABLE) { THROW("invalid id"); } if (arg_name.size() == 0) { THROW("invalid arg name"); } add_private(id, name, short_name, reqired_arg ? REQUIRED_ARGUMENT : OPTIONAL_ARGUMENT, help, arg_name); }
void CmdLineParser::begin(int argc, char** argv) { if (_argv) { THROW("unexpected"); } if (!argv || argc < 1) { THROW("invalid args"); } add_private(CmdLineParser::OPTION_HELP, "help", 0, NO_ARGUMENT, "show command help", ""); opterr = 0; _argv = argv; _argc = argc; build(); }
CLIP_DLLEXPORT ClipVar * _clip_ref_memvar(ClipMachine * ClipMachineMemory, long hash) { VarEntry *vp = fetch_var(ClipMachineMemory, hash); if (!vp) { #if 1 vp = add_private(ClipMachineMemory, hash); #else char buf[64]; _clip_hash_name(ClipMachineMemory, hash, buf, sizeof(buf)); _clip_trap_printf(ClipMachineMemory, __file__, __LINE__, "no variable '%s'", buf); _clip_call_errblock(ClipMachineMemory, EG_NOVAR); return 0; #endif } return &vp->ClipVar_var_of_VarEntry; }
CLIP_DLLEXPORT void _clip_memvar_param(ClipMachine * ClipMachineMemory, long hash, int no) { ClipVar *cp = 0; VarEntry *vp; if (no >= 0 && no < ClipMachineMemory->argc) cp = ClipMachineMemory->bp - (ClipMachineMemory->argc - no); vp = add_private(ClipMachineMemory, hash); if (cp) { _clip_destroy(ClipMachineMemory, &vp->ClipVar_var_of_VarEntry); vp->ClipVar_var_of_VarEntry = *cp; if ((vp->ClipVar_var_of_VarEntry.ClipType_t_of_ClipVar.ClipFlags_flags_of_ClipType & F_MPTR_ClipFlags) && vp->ClipVar_var_of_VarEntry.ClipType_t_of_ClipVar.field_of_ClipType) { vp->ClipVar_var_of_VarEntry.ClipType_t_of_ClipVar.field_of_ClipType = 0; vp->ClipVar_var_of_VarEntry.ClipRefVar_p_of_ClipVar.ClipFieldDef_of_ClipRefVar = 0; } CLEAR_CLIPVAR(cp); } }
CLIP_DLLEXPORT void _clip_memvar_private(ClipMachine * ClipMachineMemory, long hash) { add_private(ClipMachineMemory, hash); }