タグ付けされた質問 「boost-program-options」

4
Boostライブラリプログラムオプションを使用した必須およびオプションの引数
Boost Program OptionsLibraryを使用してコマンドライン引数を解析しています。 次の要件があります。 「ヘルプ」が提供されると、他のすべてのオプションはオプションになります。 「ヘルプ」が提供されない場合、他のすべてのオプションが必要です。 どうすればこれに対処できますか?これを処理する私のコードは次のとおりですが、非常に冗長であることがわかりました。簡単に実行できるはずですよね? #include <boost/program_options.hpp> #include <iostream> #include <sstream> namespace po = boost::program_options; bool process_command_line(int argc, char** argv, std::string& host, std::string& port, std::string& configDir) { int iport; try { po::options_description desc("Program Usage", 1024, 512); desc.add_options() ("help", "produce help message") ("host,h", po::value<std::string>(&host), "set the host server") ("port,p", …
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.