BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
api_documentation.hpp
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 #pragma once
25 
26 #include <string>
27 
28 #include <boost/multi_index_container.hpp>
29 #include <boost/multi_index/ordered_index.hpp>
30 #include <boost/multi_index/member.hpp>
31 
33 
34 namespace graphene { namespace wallet {
35 
37  {
38  std::string method_name;
39  std::string brief_description;
40  std::string detailed_description;
41  };
42 
44  {
45  using method_description_set = boost::multi_index::multi_index_container<method_description,
46  boost::multi_index::indexed_by<
47  boost::multi_index::ordered_unique<
48  boost::multi_index::member<method_description, std::string, &method_description::method_name> > > >;
49  method_description_set method_descriptions;
50  public:
52  std::string get_brief_description(const std::string& method_name) const
53  {
54  auto iter = method_descriptions.find(method_name);
55  if (iter != method_descriptions.end())
56  return iter->brief_description;
57  else
58  FC_THROW_EXCEPTION(fc::key_not_found_exception, "No entry for method ${name}", ("name", method_name));
59  }
60  std::string get_detailed_description(const std::string& method_name) const
61  {
62  auto iter = method_descriptions.find(method_name);
63  if (iter != method_descriptions.end())
64  return iter->detailed_description;
65  else
66  FC_THROW_EXCEPTION(fc::key_not_found_exception, "No entry for method ${name}", ("name", method_name));
67  }
68  std::vector<std::string> get_method_names() const
69  {
70  std::vector<std::string> method_names;
71  for (const method_description& method_description: method_descriptions)
72  method_names.emplace_back(method_description.method_name);
73  return method_names;
74  }
75  };
76 
77 } } // end namespace graphene::wallet
graphene::wallet::method_description::detailed_description
std::string detailed_description
Definition: api_documentation.hpp:40
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
graphene::wallet::api_documentation::get_brief_description
std::string get_brief_description(const std::string &method_name) const
Definition: api_documentation.hpp:52
graphene::wallet::api_documentation::get_detailed_description
std::string get_detailed_description(const std::string &method_name) const
Definition: api_documentation.hpp:60
graphene::wallet::api_documentation
Definition: api_documentation.hpp:43
exception.hpp
Defines exception's used by fc.
graphene::wallet::api_documentation::get_method_names
std::vector< std::string > get_method_names() const
Definition: api_documentation.hpp:68
graphene::wallet::method_description::method_name
std::string method_name
Definition: api_documentation.hpp:38
FC_THROW_EXCEPTION
#define FC_THROW_EXCEPTION(EXCEPTION, FORMAT,...)
Definition: exception.hpp:379
graphene
Definition: api.cpp:48