Re: commandline arguments using Glib::OptionEntry
- From: Dancefire <dancefire gmail com>
- To: Paul Jorgensen <pauljorgensen5 gmail com>
- Cc: gtkmm-list gnome org
- Subject: Re: commandline arguments using Glib::OptionEntry
- Date: Tue, 27 Jan 2009 12:19:37 +1100
Hi, Paul,
You may try boost::program_options, it is a template library in boost, which handles the program options. you can check the following links about the tutorial.
http://www.boost.org/doc/libs/1_37_0/doc/html/program_options.html
Tao Wang
On Mon, Jan 26, 2009 at 2:50 PM, Paul Jorgensen
<pauljorgensen5 gmail com> wrote:
Hi Bernd,
Yes, your right I think, I will code a class as I have in Visual Studio MFC that will do everything for the commandline arguments. I went through the same thing with Windows, I looked at different options that were available and ended up having to do it all myself. I know some people are using the Glib::OptionEntry code to detect their args, others use getopt, and others use completely custom code. I like your vector idea, I plan to try using that!
thanks!
Paul
On Sat, Jan 24, 2009 at 6:43 AM, Bernd Robertz
<bernd robertz cssweb de> wrote:
Hello Paul,
you can use the options as in any other C++ application.
You can derefence it through the "char**" parameter of the main
function.
For expampe:
# progname -n para1,para2,para3,para4
You would check in your application for the "-n" parameter wich would be
found in this exampla in "char[1]" and then you can reach the "paraX"
over "char[2]".
The above example would store the parameter as:
"progname" = argc = 1 = argv[0]
"-n" = argc = 2 = argv[1]
"para1,para2..." = argc = 2 = argv[2]
So argv[2] IS already a char-string.
For example you could cast it to a Glib::ustring and search/replace by
the "," and store them in a vector or something Gtkmm equivalent
(perhaps as an own class or function). After that, you can pass it as a
parameter to your class wich builds the OptionEntry and work with your
vectorized data.
If I have to deal with cli parameter, I often do it like this way
depends on what I need. It works for me.
Cheers
Bernd
Am Donnerstag, den 22.01.2009, 23:58 -0400 schrieb Paul Jorgensen:
> hello all!
>
> I have looked through the gtkmm documention, etc and I can browse
> through more source and documentation, but I thought I would give this
> mailing list a shot for an answer first!
>
> How would one add a variable commandline argument such as the
> following in gtkmm?
>
> -n:one,two,three,...
>
> ie once the -n is specified, then the user could add up to 1-10 items
> for example that are comma delimited.
>
> I have added the -n arg using the OptionEntry etc, but I am not sure
> how to go about getting the parameters on the -n argument passed back/
> parsed. I want the "one,two,three,..." either passed back as a string,
> or tokenized into individual tokens..and I would want to omit the ":"
> from the results..
>
> If anyone knows this off the top of their head I would really
> appreciate it.
>
> [pauljorgensen5]@
gmail.com ( remove the brackets to send me an
> email )
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list
--
Microsoft Certified Technology Specialist
CCNA
http://www.dancefire.org/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]