From 5592b9854e2c1f405b46ecfc8d14ff1f4ca718a7 Mon Sep 17 00:00:00 2001 From: Huiming Lv Date: Fri, 3 Apr 2015 13:09:46 +0800 Subject: [PATCH] add a file --- headers/options_utils_convert.h | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 headers/options_utils_convert.h diff --git a/headers/options_utils_convert.h b/headers/options_utils_convert.h new file mode 100644 index 0000000..536e0c3 --- /dev/null +++ b/headers/options_utils_convert.h @@ -0,0 +1,48 @@ +/************************************************************************************************** + * Authors: + * Zhiyuan Shao, Jian He, Huiming Lv + * + * Declaration: + * Program parameter parsing. + * + * Notes: + * 1.modify bfs::bfs_root to bfs::bfs-root by Huiming Lv 2014/12/21 + *************************************************************************************************/ + +#ifndef __OPTIONS_UTILS_CONVERT_H__ +#define __OPTIONS_UTILS_CONVERT_H__ + +#include +#include + +boost::program_options::options_description desc; +boost::program_options::variables_map vm; + +static void setup_options_convert(int argc, const char* argv[]) +{ + desc.add_options() + ( "help,h", "Display help message") + ( "type,t", boost::program_options::value()->required(), "Type of the snap file(edgelist or adjlist)") + ( "graph,g", boost::program_options::value()->required(), "Name of the graph in snap format") + ( "destination,d", boost::program_options::value()->required(), "Destination folder that will contain the index and edge file") + ("out-type,o", boost::program_options::value()->required(), "Type of out edge file, type1(with edge value) or type2(no edge value)") + ("in-edge,i", boost::program_options::value()->default_value(false),"With or without in-edge, backtrace-algorithm(WCC, SCC) must be true!"); + try { + boost::program_options::store(boost::program_options::parse_command_line(argc, + argv, + desc), + vm); + boost::program_options::notify(vm); + } + catch (boost::program_options::error &e) { + if(vm.count("help") || argc ==1) { + std::cerr << desc << "\n"; + } + std::cerr << "Error:" << e.what() << std::endl; + std::cerr << "Try: " << argv[0] << " --help" << std::endl; + exit(-1); + } +} + + +#endif