LCOV - code coverage report
Current view: top level - shared_model/backend/protobuf/impl - permissions.cpp (source / functions) Hit Total Coverage
Test: coverage_cleared.info Lines: 15 24 62.5 %
Date: 2018-12-05 17:11:35 Functions: 7 8 87.5 %

          Line data    Source code
       1             : /**
       2             :  * Copyright Soramitsu Co., Ltd. All Rights Reserved.
       3             :  * SPDX-License-Identifier: Apache-2.0
       4             :  */
       5             : 
       6             : #include "backend/protobuf/permissions.hpp"
       7             : 
       8             : namespace shared_model {
       9             :   namespace proto {
      10             :     namespace permissions {
      11             : 
      12             :       interface::permissions::Role fromTransport(
      13             :           iroha::protocol::RolePermission perm) noexcept {
      14       36796 :         return static_cast<interface::permissions::Role>(perm);
      15             :       }
      16             : 
      17             :       iroha::protocol::RolePermission toTransport(
      18             :           interface::permissions::Role r) {
      19       14101 :         return static_cast<iroha::protocol::RolePermission>(r);
      20             :       }
      21             : 
      22             :       std::string toString(interface::permissions::Role r) {
      23         593 :         return iroha::protocol::RolePermission_Name(toTransport(r));
      24             :       }
      25             : 
      26             :       interface::permissions::Grantable fromTransport(
      27             :           iroha::protocol::GrantablePermission perm) noexcept {
      28         255 :         return static_cast<interface::permissions::Grantable>(perm);
      29             :       }
      30             : 
      31             :       iroha::protocol::GrantablePermission toTransport(
      32             :           interface::permissions::Grantable r) {
      33         139 :         return static_cast<iroha::protocol::GrantablePermission>(r);
      34             :       }
      35             : 
      36             :       std::string toString(interface::permissions::Grantable r) {
      37          34 :         return iroha::protocol::GrantablePermission_Name(toTransport(r));
      38             :       }
      39             : 
      40             :       std::vector<std::string> toString(
      41             :           const interface::PermissionSet<interface::permissions::Role> &set) {
      42         340 :         std::vector<std::string> v;
      43       14960 :         for (size_t i = 0; i < set.size(); ++i) {
      44       14620 :           auto perm = static_cast<interface::permissions::Role>(i);
      45       14620 :           if (set.test(perm)) {
      46         593 :             v.push_back(toString(perm));
      47         593 :           }
      48       14620 :         }
      49         340 :         return v;
      50         340 :       }
      51             : 
      52             :       std::vector<std::string> toString(
      53             :           const interface::PermissionSet<interface::permissions::Grantable>
      54             :               &set) {
      55           0 :         std::vector<std::string> v;
      56           0 :         for (size_t i = 0; i < set.size(); ++i) {
      57           0 :           auto perm = static_cast<interface::permissions::Grantable>(i);
      58           0 :           if (set.test(perm)) {
      59           0 :             v.push_back(toString(perm));
      60           0 :           }
      61           0 :         }
      62           0 :         return v;
      63           0 :       }
      64             :     }  // namespace permissions
      65             :   }    // namespace proto
      66             : }  // namespace shared_model

Generated by: LCOV version 1.13