BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
api_documentation_standin.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cryptonomex, Inc., and contributors.
3  *
4  * The MIT License
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #include <iomanip>
25 #include <boost/algorithm/string/join.hpp>
28 
29 namespace graphene { namespace wallet {
30  namespace detail {
31  namespace
32  {
33  template <typename... Args>
34  struct types_to_string_list_helper;
35 
36  template <typename First, typename... Args>
37  struct types_to_string_list_helper<First, Args...>
38  {
39  std::list<std::string> operator()() const
40  {
41  std::list<std::string> argsList = types_to_string_list_helper<Args...>()();
42  argsList.push_front(fc::get_typename<typename std::decay<First>::type>::name());
43  return argsList;
44  }
45  };
46 
47  template <>
48  struct types_to_string_list_helper<>
49  {
50  std::list<std::string> operator()() const
51  {
52  return std::list<std::string>();
53  }
54  };
55 
56  template <typename... Args>
57  std::list<std::string> types_to_string_list()
58  {
59  return types_to_string_list_helper<Args...>()();
60  }
61  } // end anonymous namespace
62 
63  struct help_visitor
64  {
65  std::vector<method_description> method_descriptions;
66 
67  template<typename R, typename... Args>
68  void operator()( const char* name, std::function<R(Args...)>& memb )
69  {
70  method_description this_method;
71  this_method.method_name = name;
72  std::ostringstream ss;
73  ss << std::setw(40) << std::left << fc::get_typename<R>::name() << " " << name << "(";
74  ss << boost::algorithm::join(types_to_string_list<Args...>(), ", ");
75  ss << ")\n";
76  this_method.brief_description = ss.str();
77  method_descriptions.push_back(this_method);
78  }
79  };
80  } // end namespace detail
81 
83  {
85  detail::help_visitor visitor;
86  tmp->visit(visitor);
87  std::copy(visitor.method_descriptions.begin(), visitor.method_descriptions.end(),
88  std::inserter(method_descriptions, method_descriptions.end()));
89  }
90 
91 } } // end namespace graphene::wallet
fc::copy
void copy(const path &from, const path &to)
Definition: filesystem.cpp:241
graphene::wallet::method_description
Definition: api_documentation.hpp:36
graphene::wallet::api_documentation::api_documentation
api_documentation()
Definition: api_documentation_standin.cpp:82
graphene::wallet::method_description::brief_description
std::string brief_description
Definition: api_documentation.hpp:39
wallet.hpp
fc::get_typename
Definition: typename.hpp:20
graphene::wallet::detail::help_visitor::method_descriptions
std::vector< method_description > method_descriptions
Definition: api_documentation_standin.cpp:65
graphene::wallet::detail::help_visitor::operator()
void operator()(const char *name, std::function< R(Args...)> &memb)
Definition: api_documentation_standin.cpp:68
graphene::wallet::method_description::method_name
std::string method_name
Definition: api_documentation.hpp:38
graphene::wallet::detail::help_visitor
Definition: api_documentation_standin.cpp:63
api_documentation.hpp
fc::api
Definition: api.hpp:120
graphene
Definition: api.cpp:48