1 | #include <iostream>
|
---|
2 | #include <fstream>
|
---|
3 | #include <boost/program_options.hpp>
|
---|
4 |
|
---|
5 | namespace po = boost::program_options ;
|
---|
6 | int main(int argc, char **argv)
|
---|
7 | {
|
---|
8 | std::ifstream file ;
|
---|
9 | file.exceptions(std::ifstream::failbit | std::ifstream::badbit) ;
|
---|
10 | po::options_description options_ ;
|
---|
11 |
|
---|
12 | try
|
---|
13 | {
|
---|
14 | file.open("test.cfg") ;
|
---|
15 | std::cout << "opening test.cfg: failbit: " << file.fail() << " - badbit: " << file.bad() << std::endl ;
|
---|
16 | std::cout << "let s call parse_config_file()..." << std::endl ;
|
---|
17 | po::parse_config_file(file, options_) ;
|
---|
18 | }
|
---|
19 | catch(std::ios::failure const & exc)
|
---|
20 | {
|
---|
21 | std::cout << "ios failure: failbit: " << file.fail() << " - badbit: " << file.bad() << std::endl ;
|
---|
22 | std::cout << "perror() value : " << std::flush ;
|
---|
23 | perror("test.cfg") ;
|
---|
24 | }
|
---|
25 | }
|
---|