BitShares-Core  5.0.0
BitShares blockchain implementation and command-line interface 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  typedef 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> > > > method_description_set;
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
Definition: api.cpp:56
std::string get_detailed_description(const std::string &method_name) const
std::string get_brief_description(const std::string &method_name) const
#define FC_THROW_EXCEPTION(EXCEPTION, FORMAT,...)
Definition: exception.hpp:378
Defines exception&#39;s used by fc.
std::vector< std::string > get_method_names() const