ywkaras commented on a change in pull request #7478: URL: https://github.com/apache/trafficserver/pull/7478#discussion_r592005527
########## File path: src/traffic_ctl_jsonrpc/jsonrpc/yaml_codecs.h ########## @@ -0,0 +1,362 @@ +/** + @section license License + + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +#pragma once + +#include <string_view> +#include <yaml-cpp/yaml.h> + +#include "RPCRequests.h" + +// the whole point if to not fail if the data is not available, and just return something +// back so we can still display some error. +template <typename T> +static auto +try_extract(YAML::Node const &node, std::string_view name, bool throwOnFail = false) Review comment: It seems like, in all places where this is used, the "name" parameter is a C (null terminated) string that implicitly converts to a string_view. And, if fact, line 34 would likely cause a segment violation if "name" was _not_ a C string. Seems like it would be more clear to make `const char *` the type of name. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
