Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/ |
| 3 | * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/ |
| 4 | * |
| 5 | * Written by Václav Kubernát <kubervac@fit.cvut.cz> |
| 6 | * |
| 7 | */ |
| 8 | |
Václav Kubernát | 19097f3 | 2020-10-05 10:08:29 +0200 | [diff] [blame] | 9 | #include <experimental/iterator> |
Václav Kubernát | 19097f3 | 2020-10-05 10:08:29 +0200 | [diff] [blame] | 10 | #include <sstream> |
Václav Kubernát | b4e5b18 | 2020-11-16 19:55:09 +0100 | [diff] [blame] | 11 | #include <sysrepo-cpp/Session.hpp> |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 12 | #include <sysrepo-cpp/utils/exception.hpp> |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 13 | #include "libyang_utils.hpp" |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 14 | #include "sysrepo_access.hpp" |
Jan Kundrát | 6ee8479 | 2020-01-24 01:43:36 +0100 | [diff] [blame] | 15 | #include "utils.hpp" |
Václav Kubernát | a6c5fff | 2018-09-07 15:16:25 +0200 | [diff] [blame] | 16 | #include "yang_schema.hpp" |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 17 | |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 18 | const auto OPERATION_TIMEOUT_MS = std::chrono::milliseconds{1000}; |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 19 | |
Václav Kubernát | 812ee28 | 2018-08-30 17:10:03 +0200 | [diff] [blame] | 20 | SysrepoAccess::~SysrepoAccess() = default; |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 21 | |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 22 | sysrepo::Datastore toSrDatastore(Datastore datastore) |
Václav Kubernát | 715c85c | 2020-04-14 01:46:08 +0200 | [diff] [blame] | 23 | { |
| 24 | switch (datastore) { |
| 25 | case Datastore::Running: |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 26 | return sysrepo::Datastore::Running; |
Václav Kubernát | 715c85c | 2020-04-14 01:46:08 +0200 | [diff] [blame] | 27 | case Datastore::Startup: |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 28 | return sysrepo::Datastore::Startup; |
Václav Kubernát | 715c85c | 2020-04-14 01:46:08 +0200 | [diff] [blame] | 29 | } |
| 30 | __builtin_unreachable(); |
| 31 | } |
| 32 | |
Václav Kubernát | f5d7515 | 2020-12-03 03:52:34 +0100 | [diff] [blame] | 33 | SysrepoAccess::SysrepoAccess() |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 34 | : m_connection() |
| 35 | , m_session(m_connection.sessionStart()) |
| 36 | , m_schema(std::make_shared<YangSchema>(m_session.getContext())) |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 37 | { |
Jan Kundrát | 0b9ef8f | 2023-10-03 13:02:53 +0200 | [diff] [blame] | 38 | m_session.setOriginatorName("sysrepo-cli"); |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 39 | } |
| 40 | |
Václav Kubernát | f5d7515 | 2020-12-03 03:52:34 +0100 | [diff] [blame] | 41 | namespace { |
| 42 | auto targetToDs_get(const DatastoreTarget target) |
| 43 | { |
| 44 | switch (target) { |
| 45 | case DatastoreTarget::Operational: |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 46 | return sysrepo::Datastore::Operational; |
Václav Kubernát | f5d7515 | 2020-12-03 03:52:34 +0100 | [diff] [blame] | 47 | case DatastoreTarget::Running: |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 48 | return sysrepo::Datastore::Running; |
Václav Kubernát | f5d7515 | 2020-12-03 03:52:34 +0100 | [diff] [blame] | 49 | case DatastoreTarget::Startup: |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 50 | return sysrepo::Datastore::Startup; |
Václav Kubernát | f5d7515 | 2020-12-03 03:52:34 +0100 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | __builtin_unreachable(); |
| 54 | } |
| 55 | |
| 56 | auto targetToDs_set(const DatastoreTarget target) |
| 57 | { |
| 58 | switch (target) { |
| 59 | case DatastoreTarget::Operational: |
| 60 | case DatastoreTarget::Running: |
| 61 | // TODO: Doing candidate here doesn't work, why? |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 62 | return sysrepo::Datastore::Running; |
Václav Kubernát | f5d7515 | 2020-12-03 03:52:34 +0100 | [diff] [blame] | 63 | case DatastoreTarget::Startup: |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 64 | return sysrepo::Datastore::Startup; |
Václav Kubernát | f5d7515 | 2020-12-03 03:52:34 +0100 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | __builtin_unreachable(); |
| 68 | } |
| 69 | } |
| 70 | |
Václav Kubernát | d628291 | 2020-06-23 14:49:34 +0200 | [diff] [blame] | 71 | DatastoreAccess::Tree SysrepoAccess::getItems(const std::string& path) const |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 72 | { |
Václav Kubernát | b6ff0b6 | 2018-08-30 16:14:53 +0200 | [diff] [blame] | 73 | using namespace std::string_literals; |
Jan Kundrát | b331b55 | 2020-01-23 15:25:29 +0100 | [diff] [blame] | 74 | Tree res; |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 75 | |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 76 | try { |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 77 | m_session.switchDatastore(targetToDs_get(m_target)); |
Jan Kundrát | f59b83c | 2022-03-18 18:12:08 +0100 | [diff] [blame] | 78 | auto config = m_session.getData((path == "/") ? "/*" : path); |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 79 | if (config) { |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 80 | lyNodesToTree(res, config->siblings()); |
Václav Kubernát | b6ff0b6 | 2018-08-30 16:14:53 +0200 | [diff] [blame] | 81 | } |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 82 | } catch (sysrepo::Error& ex) { |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 83 | reportErrors(); |
Václav Kubernát | c89736b | 2018-08-30 16:14:05 +0200 | [diff] [blame] | 84 | } |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 85 | return res; |
| 86 | } |
| 87 | |
| 88 | void SysrepoAccess::setLeaf(const std::string& path, leaf_data_ value) |
| 89 | { |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 90 | try { |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 91 | m_session.switchDatastore(targetToDs_set(m_target)); |
| 92 | auto lyValue = value.type() == typeid(empty_) ? "" : leafDataToString(value); |
Jan Kundrát | f59b83c | 2022-03-18 18:12:08 +0100 | [diff] [blame] | 93 | m_session.setItem(path, lyValue, sysrepo::EditOptions::Isolate); |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 94 | } catch (sysrepo::Error& ex) { |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 95 | reportErrors(); |
| 96 | } |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 97 | } |
| 98 | |
Jan Kundrát | cbf288b | 2020-06-18 20:44:39 +0200 | [diff] [blame] | 99 | void SysrepoAccess::createItem(const std::string& path) |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 100 | { |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 101 | try { |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 102 | m_session.switchDatastore(targetToDs_set(m_target)); |
Jan Kundrát | f59b83c | 2022-03-18 18:12:08 +0100 | [diff] [blame] | 103 | m_session.setItem(path, std::nullopt); |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 104 | } catch (sysrepo::Error& ex) { |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 105 | reportErrors(); |
| 106 | } |
Václav Kubernát | 80aacc0 | 2018-08-22 17:41:54 +0200 | [diff] [blame] | 107 | } |
| 108 | |
Jan Kundrát | cbf288b | 2020-06-18 20:44:39 +0200 | [diff] [blame] | 109 | void SysrepoAccess::deleteItem(const std::string& path) |
Václav Kubernát | f5f64f0 | 2019-03-19 17:15:47 +0100 | [diff] [blame] | 110 | { |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 111 | try { |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 112 | // Have to use sysrepo::EditOptions::Isolate, because deleting something that's been set without committing is |
| 113 | // not supported. |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 114 | // https://github.com/sysrepo/sysrepo/issues/1967#issuecomment-625085090 |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 115 | m_session.switchDatastore(targetToDs_set(m_target)); |
Jan Kundrát | f59b83c | 2022-03-18 18:12:08 +0100 | [diff] [blame] | 116 | m_session.deleteItem(path, sysrepo::EditOptions::Isolate); |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 117 | } catch (sysrepo::Error& ex) { |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 118 | reportErrors(); |
| 119 | } |
Václav Kubernát | f5f64f0 | 2019-03-19 17:15:47 +0100 | [diff] [blame] | 120 | } |
| 121 | |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 122 | struct impl_toSrMoveOp { |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 123 | sysrepo::MovePosition operator()(yang::move::Absolute& absolute) |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 124 | { |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 125 | return absolute == yang::move::Absolute::Begin ? sysrepo::MovePosition::First : sysrepo::MovePosition::Last; |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 126 | } |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 127 | sysrepo::MovePosition operator()(yang::move::Relative& relative) |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 128 | { |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 129 | return relative.m_position == yang::move::Relative::Position::After ? sysrepo::MovePosition::After : sysrepo::MovePosition::Before; |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 130 | } |
| 131 | }; |
| 132 | |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 133 | sysrepo::MovePosition toSrMoveOp(std::variant<yang::move::Absolute, yang::move::Relative> move) |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 134 | { |
| 135 | return std::visit(impl_toSrMoveOp{}, move); |
| 136 | } |
| 137 | |
| 138 | void SysrepoAccess::moveItem(const std::string& source, std::variant<yang::move::Absolute, yang::move::Relative> move) |
| 139 | { |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 140 | std::string destination; |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 141 | if (std::holds_alternative<yang::move::Relative>(move)) { |
| 142 | auto relative = std::get<yang::move::Relative>(move); |
| 143 | if (m_schema->nodeType(source) == yang::NodeTypes::LeafList) { |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 144 | destination = leafDataToString(relative.m_path.at(".")); |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 145 | } else { |
Václav Kubernát | 654303f | 2020-07-31 13:16:54 +0200 | [diff] [blame] | 146 | destination = instanceToString(relative.m_path); |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 147 | } |
| 148 | } |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 149 | m_session.switchDatastore(targetToDs_set(m_target)); |
Jan Kundrát | f59b83c | 2022-03-18 18:12:08 +0100 | [diff] [blame] | 150 | m_session.moveItem(source, toSrMoveOp(move), destination); |
Václav Kubernát | bf65dd7 | 2020-05-28 02:32:31 +0200 | [diff] [blame] | 151 | } |
| 152 | |
Václav Kubernát | 812ee28 | 2018-08-30 17:10:03 +0200 | [diff] [blame] | 153 | void SysrepoAccess::commitChanges() |
| 154 | { |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 155 | try { |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 156 | m_session.switchDatastore(targetToDs_set(m_target)); |
| 157 | m_session.applyChanges(OPERATION_TIMEOUT_MS); |
| 158 | } catch (sysrepo::Error& ex) { |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 159 | reportErrors(); |
| 160 | } |
Václav Kubernát | 812ee28 | 2018-08-30 17:10:03 +0200 | [diff] [blame] | 161 | } |
Václav Kubernát | a6c5fff | 2018-09-07 15:16:25 +0200 | [diff] [blame] | 162 | |
Václav Kubernát | 6d79143 | 2018-10-25 16:00:35 +0200 | [diff] [blame] | 163 | void SysrepoAccess::discardChanges() |
| 164 | { |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 165 | try { |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 166 | m_session.switchDatastore(targetToDs_set(m_target)); |
| 167 | m_session.discardChanges(); |
| 168 | } catch (sysrepo::Error& ex) { |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 169 | reportErrors(); |
| 170 | } |
Václav Kubernát | 6d79143 | 2018-10-25 16:00:35 +0200 | [diff] [blame] | 171 | } |
| 172 | |
Václav Kubernát | b3960f8 | 2020-12-01 03:21:48 +0100 | [diff] [blame] | 173 | DatastoreAccess::Tree SysrepoAccess::execute(const std::string& path, const Tree& input) |
Václav Kubernát | a878960 | 2020-07-20 15:18:19 +0200 | [diff] [blame] | 174 | { |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 175 | auto inputNode = treeToRpcInput(m_session.getContext(), path, input); |
| 176 | m_session.switchDatastore(targetToDs_set(m_target)); |
| 177 | auto output = m_session.sendRPC(inputNode); |
| 178 | return rpcOutputToTree(output); |
Václav Kubernát | a878960 | 2020-07-20 15:18:19 +0200 | [diff] [blame] | 179 | } |
Jan Kundrát | 6ee8479 | 2020-01-24 01:43:36 +0100 | [diff] [blame] | 180 | |
Václav Kubernát | 7160a13 | 2020-04-03 02:11:01 +0200 | [diff] [blame] | 181 | void SysrepoAccess::copyConfig(const Datastore source, const Datastore destination) |
| 182 | { |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 183 | m_session.switchDatastore(toSrDatastore(destination)); |
Jan Kundrát | f59b83c | 2022-03-18 18:12:08 +0100 | [diff] [blame] | 184 | m_session.copyConfig(toSrDatastore(source), std::nullopt, OPERATION_TIMEOUT_MS); |
Václav Kubernát | a6c5fff | 2018-09-07 15:16:25 +0200 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | std::shared_ptr<Schema> SysrepoAccess::schema() |
| 188 | { |
| 189 | return m_schema; |
| 190 | } |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 191 | |
Václav Kubernát | d628291 | 2020-06-23 14:49:34 +0200 | [diff] [blame] | 192 | [[noreturn]] void SysrepoAccess::reportErrors() const |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 193 | { |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 194 | std::vector<DatastoreError> res; |
| 195 | |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 196 | for (const auto& err : m_session.getErrors()) { |
| 197 | res.emplace_back(err.errorMessage); |
| 198 | } |
| 199 | |
| 200 | for (const auto& err : m_session.getNetconfErrors()) { |
| 201 | res.emplace_back(err.message, err.path); |
Václav Kubernát | c58e4aa | 2019-04-03 18:37:32 +0200 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | throw DatastoreException(res); |
| 205 | } |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 206 | |
| 207 | std::vector<ListInstance> SysrepoAccess::listInstances(const std::string& path) |
| 208 | { |
| 209 | std::vector<ListInstance> res; |
Jan Kundrát | f59b83c | 2022-03-18 18:12:08 +0100 | [diff] [blame] | 210 | auto lists = m_session.getData(path); |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 211 | if (!lists) { |
| 212 | return res; |
| 213 | } |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 214 | |
Jan Kundrát | f59b83c | 2022-03-18 18:12:08 +0100 | [diff] [blame] | 215 | auto instances = lists->findXPath(path); |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 216 | if (instances.empty()) { |
| 217 | return res; |
| 218 | } |
| 219 | |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 220 | auto keys = instances.front().schema().asList().keys(); |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 221 | |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 222 | for (const auto& instance : instances) { |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 223 | ListInstance instanceRes; |
| 224 | for (const auto& key : keys) { |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 225 | auto leaf = instance.findPath(key.name().data()); |
| 226 | instanceRes.emplace(std::string{leaf->schema().name()}, leafValueFromNode(leaf->asTerm())); |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 227 | } |
Václav Kubernát | faacd02 | 2020-07-08 16:44:38 +0200 | [diff] [blame] | 228 | res.emplace_back(instanceRes); |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | return res; |
| 232 | } |
Václav Kubernát | 70d7f7a | 2020-06-23 14:40:40 +0200 | [diff] [blame] | 233 | |
| 234 | std::string SysrepoAccess::dump(const DataFormat format) const |
| 235 | { |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 236 | auto root = m_session.getData("/*"); |
| 237 | auto str = root->printStr(format == DataFormat::Xml ? libyang::DataFormat::XML : libyang::DataFormat::JSON, libyang::PrintFlags::WithSiblings); |
| 238 | if (!str) { |
| 239 | return ""; |
| 240 | } |
| 241 | |
| 242 | return std::string{*str}; |
Václav Kubernát | 70d7f7a | 2020-06-23 14:40:40 +0200 | [diff] [blame] | 243 | } |