libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
fix_to_mit_program_options_impl.hpp
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright © 2017 by J.M.McGuiness, isimud@hussar.me.uk
3 **
4 ** This library is free software; you can redistribute it and/or
5 ** modify it under the terms of the GNU Lesser General Public
6 ** License as published by the Free Software Foundation; either
7 ** version 2.1 of the License, or (at your option) any later version.
8 **
9 ** This library is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ** Lesser General Public License for more details.
13 **
14 ** You should have received a copy of the GNU Lesser General Public
15 ** License along with this library; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 
19 namespace isimud { namespace ISIMUD_VER_NAMESPACE { namespace exchanges { namespace MIT {
20 
21 template<class Link>
22 inline boost::program_options::options_description
23 create_program_options(boost::program_options::options_description &&all) noexcept(false) {
24  using link_t=Link;
25  using exchange_msg_details_t=typename link_t::exchg_link_t::exchange_msg_details_t;
26  using proc_rules_t=MIT::common::simulator_responses<exchange_msg_details_t>;
27 
28  std::string const MIC_code=[]() {
29  std::ostringstream ss;
30  exchanges::common::mic_codes::to_stream<exchange_msg_details_t::MIC_code>(ss);
31  return ss.str();
32  }();
33  std::ostringstream os;
34  std::string const details=os.str()+"\n"+[]() {
35  std::ostringstream ss;
36  ss<<"ISO 10383: MIC Codes official information: ";
37  decltype(+exchanges::common::mic_codes::collection[
38  boost::hana::int_c<
39  static_cast<
40  std::underlying_type<exchanges::common::mic_codes::ISO_10383_MIC_Codes>::type
41  >(
42  exchange_msg_details_t::MIC_code
43  )
44  >
45  ])::type::to_stream(ss);
46  return ss.str();
47  }();
48 
49  boost::program_options::options_description link_opts((MIC_code+" link options.").c_str());
50  link_opts.add_options()
51  (
52  (MIC_code+"_ref_data").c_str(),
53  boost::program_options::value<std::string>()->required(),
54  "The file-path of a file that contains the full reference-data supplied for the exchange, that must map ISINs to exchange-specific instrument IDs in CSV format separated by semicolons."
55  );
56  boost::program_options::options_description exchange("Exchange options (the defaults are suitable for use with the simulator)");
57  exchange.add_options()
58  (
59  (MIC_code+"_primary_gateway_address").c_str(),
60  boost::program_options::value<std::string>()->required()->default_value(boost::asio::ip::address_v4::loopback().to_string()),
61  "IP address (in v4 format) of the primary gateway to which the translator should connect."
62  )
63  (
64  (MIC_code+"_primary_gateway_port").c_str(),
65  boost::program_options::value<unsigned short>()->required(),
66  "The port of the primary gateway to which the translator should connect."
67  )
68  (
69  (MIC_code+"_secondary_gateway_address").c_str(),
70  boost::program_options::value<std::string>()->required()->default_value(boost::asio::ip::address_v4::loopback().to_string()),
71  "IP address (in v4 format) of the secondary gateway to which the translator should connect."
72  )
73  (
74  (MIC_code+"_secondary_gateway_port").c_str(),
75  boost::program_options::value<unsigned short>()->required(),
76  "The port of the secondary gateway to which the translator should connect."
77  )
78  (
79  (MIC_code+"_username").c_str(),
80  boost::program_options::value<std::string>()->required()->default_value(proc_rules_t::username.begin()),
81  "The username with which to connect to the exchange."
82  )
83  (
84  (MIC_code+"_password").c_str(),
85  boost::program_options::value<std::string>()->required()->default_value(proc_rules_t::password.begin()),
86  "The password with which to connect to the exchange."
87  )
88  (
89  (MIC_code+"_new_password").c_str(),
90  boost::program_options::value<std::string>()->required()->default_value(proc_rules_t::new_password.begin()),
91  "The new password with which to connect to the exchange."
92  )
93  (
94  (MIC_code+"_logout_reason").c_str(),
95  boost::program_options::value<std::string>()->required()->default_value("TTFN"),
96  "The reason that should be used when logging out of the connected exchange."
97  );
98  boost::program_options::options_description all_opts(details);
99  all_opts.add(link_opts).add(exchange);
100  all.add(all_opts);
101  return std::move(all);
102 }
103 
104 } } } }