+ if(l.empty())
+ throw invalid_argument("GetOpt::add_option");
+ if(t.is_list() && a!=REQUIRED_ARG)
+ throw invalid_argument("GetOpt::add_option");
+
+ for(OptionList::iterator i=opts.begin(); i!=opts.end(); )
+ {
+ if((s!=0 && (*i)->get_short()==s) || (*i)->get_long()==l)
+ {
+ delete *i;
+ opts.erase(i++);
+ }
+ else
+ ++i;
+ }
+
+ opts.push_back(new OptionImpl(s, l, t, a));
+ return *opts.back();
+}
+
+GetOpt::ArgumentImpl &GetOpt::add_argument(const string &n, const Store &t, ArgType a)
+{
+ if(a==NO_ARG)
+ throw invalid_argument("GetOpt::add_argument");
+
+ bool have_list = false;
+ bool have_optional = false;
+ for(ArgumentList::const_iterator i=args.begin(); i!=args.end(); ++i)
+ {
+ if((*i)->is_list_store())
+ have_list = true;
+ else if((*i)->get_type()==OPTIONAL_ARG)
+ have_optional = true;
+ }
+
+ if(have_optional && (t.is_list() || a!=OPTIONAL_ARG))
+ throw invalid_argument("GetOpt::add_argument");
+ if(have_list && (t.is_list() || a==OPTIONAL_ARG))
+ throw invalid_argument("GetOpt::add_argument");
+
+ args.push_back(new ArgumentImpl(n, t, a));
+ return *args.back();
+}
+
+GetOpt::OptionImpl &GetOpt::get_option(char s)
+{
+ for(OptionList::iterator i=opts.begin(); i!=opts.end(); ++i)