How do I use boost options

I want to have two options for the program to work on, the start address and end address so that the program options are as follows:

--start_address 0xc0000000 --end_address 0xffffffff

Is it possible for options_description to take such hex input? Do I have to consider the input as string and convert them to hex values. I have this at the moment:

  po::options_description desc("Allowed options");

  desc.add_options()
    ("help,h", "display this help message")
    ("path,p", po::value<std::string>(), "Executable file path")
    ("start_address,s", po::value<std::string>(), "Start address")
    ("end_address,e", po::value<std::string>(), "End address")
    ;

Can boost::lexical_cast do such a conversion?


ok. just discovered I can use options_description to enter the options and then parse the options using std::stringstream to convert to a hex number as follows

  boost::uint32_t start_address;
  std::stringstream interpreter;

  interpreter << std::hex << vm["start_address"].as<std::string>();

  interpreter >> start_address;
链接地址: http://www.djcxy.com/p/45548.html

上一篇: 警告:施放需要对齐

下一篇: 我如何使用增强选项