From ad064f541fac983225bcdd67472919c97d2ba6f5 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 21 Jul 2003 18:40:53 +0000 Subject: [PATCH] allow comma-separated tokens --- pandatool/src/egg-optchar/eggOptchar.cxx | 16 ++++++++-------- pandatool/src/progbase/programBase.cxx | 24 ++++++++++++++++++++++++ pandatool/src/progbase/programBase.h | 1 + 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/pandatool/src/egg-optchar/eggOptchar.cxx b/pandatool/src/egg-optchar/eggOptchar.cxx index 898ae5c388..42af678f83 100644 --- a/pandatool/src/egg-optchar/eggOptchar.cxx +++ b/pandatool/src/egg-optchar/eggOptchar.cxx @@ -59,17 +59,17 @@ EggOptchar() { &EggOptchar::dispatch_none, &_list_hierarchy_p); add_option - ("keep", "joint", 0, - "Keep the named joint (or slider) in the character, even if it does " + ("keep", "joint[,joint...]", 0, + "Keep the named joints (or sliders) in the character, even if they do " "not appear to be needed by the animation.", - &EggOptchar::dispatch_vector_string, NULL, &_keep_components); + &EggOptchar::dispatch_vector_string_comma, NULL, &_keep_components); add_option - ("expose", "joint", 0, - "Expose the named joint by flagging it with a DCS attribute, so " - "it can be found in the scene graph when the character is loaded, and " - "objects can be parented to it. This implies -keep.", - &EggOptchar::dispatch_vector_string, NULL, &_expose_components); + ("expose", "joint[,joint...]", 0, + "Expose the named joints by flagging them with a DCS attribute, so " + "each one can be found in the scene graph when the character is loaded, " + "and objects can be parented to it. This implies -keep.", + &EggOptchar::dispatch_vector_string_comma, NULL, &_expose_components); add_option ("keepall", "", 0, diff --git a/pandatool/src/progbase/programBase.cxx b/pandatool/src/progbase/programBase.cxx index 5d23149b46..1ac66a3793 100644 --- a/pandatool/src/progbase/programBase.cxx +++ b/pandatool/src/progbase/programBase.cxx @@ -1015,6 +1015,30 @@ dispatch_vector_string(const string &, const string &arg, void *var) { return true; } +//////////////////////////////////////////////////////////////////// +// Function: ProgramBase::dispatch_vector_string_comma +// Access: Protected, Static +// Description: Similar to dispatch_vector_string, but a comma is +// allowed to separate multiple tokens in one argument, +// without having to repeat the argument for each token. +// +// The data pointer is to a vector_string variable. +//////////////////////////////////////////////////////////////////// +bool ProgramBase:: +dispatch_vector_string_comma(const string &, const string &arg, void *var) { + vector_string *ip = (vector_string *)var; + + vector_string words; + tokenize(arg, words, ","); + + vector_string::const_iterator wi; + for (wi = words.begin(); wi != words.end(); ++wi) { + (*ip).push_back(*wi); + } + + return true; +} + //////////////////////////////////////////////////////////////////// // Function: ProgramBase::dispatch_filename // Access: Protected, Static diff --git a/pandatool/src/progbase/programBase.h b/pandatool/src/progbase/programBase.h index cea4897a30..eb3f90367e 100644 --- a/pandatool/src/progbase/programBase.h +++ b/pandatool/src/progbase/programBase.h @@ -98,6 +98,7 @@ protected: static bool dispatch_color(const string &opt, const string &arg, void *var); static bool dispatch_string(const string &opt, const string &arg, void *var); static bool dispatch_vector_string(const string &opt, const string &arg, void *var); + static bool dispatch_vector_string_comma(const string &opt, const string &arg, void *var); static bool dispatch_filename(const string &opt, const string &arg, void *var); static bool dispatch_search_path(const string &opt, const string &arg, void *var); static bool dispatch_coordinate_system(const string &opt, const string &arg, void *var);