Coverage Report

Created: 2026-11-11 06:15

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/trafficserver/include/config/config_result.h
Line
Count
Source
1
/** @file
2
3
  Generic configuration parsing result type.
4
5
  @par License
6
7
  Licensed to the Apache Software Foundation (ASF) under one
8
  or more contributor license agreements.  See the NOTICE file
9
  distributed with this work for additional information
10
  regarding copyright ownership.  The ASF licenses this file
11
  to you under the Apache License, Version 2.0 (the
12
  "License"); you may not use this file except in compliance
13
  with the License.  You may obtain a copy of the License at
14
15
      http://www.apache.org/licenses/LICENSE-2.0
16
17
  Unless required by applicable law or agreed to in writing, software
18
  distributed under the License is distributed on an "AS IS" BASIS,
19
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
  See the License for the specific language governing permissions and
21
  limitations under the License.
22
*/
23
24
#pragma once
25
26
#include "swoc/Errata.h"
27
28
namespace config
29
{
30
31
/**
32
 * Result of a configuration parse operation.
33
 *
34
 * This template is the standard return type for all configuration parsers in
35
 * the config library. It bundles a parsed configuration value with an errata
36
 * that may contain warnings or errors encountered during parsing.
37
 *
38
 * Design rationale:
39
 * - Parsers can return partial results (value populated) even when warnings
40
 *   are present, allowing callers to decide how to handle degraded configs.
41
 * - The ok() method checks whether parsing succeeded without errors, but
42
 *   callers should also inspect the errata for warnings.
43
 * - This type is reused across all configuration file types (ssl_multicert,
44
 *   etc.) to provide a consistent API.
45
 *
46
 * Example usage:
47
 * @code
48
 *   config::SSLMultiCertParser parser;
49
 *   auto result = parser.parse("/path/to/ssl_multicert.yaml");
50
 *   if (!result.ok()) {
51
 *       // Handle error
52
 *       return;
53
 *   }
54
 *   for (const auto& entry : result.value) {
55
 *       // Use parsed entries
56
 *   }
57
 * @endcode
58
 *
59
 * @tparam T The configuration type (e.g., SSLMultiCertConfig).
60
 */
61
template <typename T> struct ConfigResult {
62
  T            value;                  ///< The parsed configuration value.
63
  swoc::Errata errata;                 ///< Errors or warnings from parsing.
64
  bool         file_not_found = false; ///< True if the file was not found (ENOENT).
65
66
  /**
67
   * Check if parsing succeeded without errors.
68
   *
69
   * @return true if no errors occurred, false otherwise.
70
   */
71
  bool
72
  ok() const
73
0
  {
74
0
    return errata.is_ok();
75
0
  }
Unexecuted instantiation: config::ConfigResult<std::__1::vector<PluginYAMLEntry, std::__1::allocator<PluginYAMLEntry> > >::ok() const
Unexecuted instantiation: config::ConfigResult<config::StorageConfig>::ok() const
Unexecuted instantiation: config::ConfigResult<std::__1::vector<config::SSLMultiCertEntry, std::__1::allocator<config::SSLMultiCertEntry> > >::ok() const
76
};
77
78
} // namespace config