Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8766367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:32:06+00:00 2026-06-13T16:32:06+00:00

I am using the boost program_options library to process command line and configuration file

  • 0

I am using the boost program_options library to process command line and configuration file data, but it is not clear to me how to get the required string from the processed data.

How do I get the program_options command line parameters into the correct form for the getaddrinfo function.

//First, the options are declared

po::options_description config("Configuration");
    config.add_options()
        ("IPAddress", po::value< vector<string> >(),"127.0.0.1")
        ("Port", po::value< vector<string> >(),"5000")
         ;
//...

// Attach the config descriptions to the command line and/or config file

    po::options_description cmdline_options;
    cmdline_options.add(config).add(hidden);

    po::options_description config_file_options;
            config_file_options.add(hidden);

    po::options_description visible("Allowed options");
            visible.add(config);

    po::positional_options_description p;
            p.add("input-file", -1);

    po::variables_map vm;
    store(po::command_line_parser(ac, av).
          options(cmdline_options).positional(p).run(), vm);
    notify(vm);

// Use the command line options for IPAddress and Port
// TODO: Load the config file's address and port information
int retval = getaddrinfo(vm["IPAdress"].as< string >(),vm["Port"].as<string>(),    &hint, &list);
// This doesn't work and neither does this
//  int retval = getaddrinfo(vm["IPAdress"].as< vector<string> >(),vm["Port"].as<vector <string> >(),    &hint, &list);

// getaddressinfo

The prototype from netdb for getaddrinfo is:

extern int getaddrinfo (__const char *__restrict __name,
        __const char *__restrict __service,
        __const struct addrinfo *__restrict __req,
        struct addrinfo **__restrict __pai);

Here the link to boost program_options API:

http://www.boost.org/doc/libs/1_37_0/doc/html/program_options.html

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:32:08+00:00Added an answer on June 13, 2026 at 4:32 pm

    If the needed argument should have the type char * and you try to supply a string, the compiler will tell you what’s wrong. Read that error message and try to understand it.

    To get a char * from a string, you use the method c_str().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using boost::program_options, I can not get my own option type to compile when it
I'm using boost::program_options to implement a command-line utility with this syntax: myutil command [--in
I'm using boost::program_options to read the users' input from the command line argument. It
I'm using Boost Program Options Library to parse the command line arguments. I have
If my command line is: > prog --mylist=a,b,c Can Boost's program_options be setup to
I am using boost optionsparser to parse the command-line arguments passed by the user.
I'm using boost::program_options and it suffers from the same as many other c++ libs,
I am not using boost libraries. How can i do this using STL? class
So I'm working off one of the examples for Boost program_options library, and I
I am using boost::program_options like this: namespace po = boost::program_options; po::options_description desc(Options); desc.add_options() (help,?,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.