Scorum
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 
32 #include <fc/exception/exception.hpp>
33 
34 namespace scorum {
35 namespace wallet {
36 
38 {
39  std::string method_name;
40  std::string brief_description;
41  std::string detailed_description;
42 };
43 
45 {
46  typedef boost::multi_index::multi_index_container<method_description,
47  boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::member<method_description,
48  std::string, &method_description::method_name>>>>
49  method_description_set;
50  method_description_set method_descriptions;
51 
52 public:
54  std::string get_brief_description(const std::string& method_name) const
55  {
56  auto iter = method_descriptions.find(method_name);
57  if (iter != method_descriptions.end())
58  return iter->brief_description;
59  else
60  FC_THROW_EXCEPTION(fc::key_not_found_exception, "No entry for method ${name}", ("name", method_name));
61  }
62  std::string get_detailed_description(const std::string& method_name) const
63  {
64  auto iter = method_descriptions.find(method_name);
65  if (iter != method_descriptions.end())
66  return iter->detailed_description;
67  else
68  FC_THROW_EXCEPTION(fc::key_not_found_exception, "No entry for method ${name}", ("name", method_name));
69  }
70  std::vector<std::string> get_method_names() const
71  {
72  std::vector<std::string> method_names;
73  for (const method_description& method_description : method_descriptions)
74  method_names.emplace_back(method_description.method_name);
75  return method_names;
76  }
77 };
78 }
79 } // end namespace scorum::wallet
std::string get_detailed_description(const std::string &method_name) const
std::string get_brief_description(const std::string &method_name) const
std::vector< std::string > get_method_names() const
Definition: asset.cpp:15