Coverage Report

Created: 2026-04-07 06:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/trafficserver/include/tsutil/SourceLocation.h
Line
Count
Source
1
/** @file
2
 *
3
 *  A brief file description
4
 *
5
 *  @section license 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/bwf_fwd.h"
27
28
// The SourceLocation class wraps up a source code location, including
29
// file name, function name, and line number, and contains a method to
30
// format the result into a string buffer.
31
32
0
#define MakeSourceLocation() SourceLocation(__FILE__, __FUNCTION__, __LINE__)
33
34
class SourceLocation
35
{
36
public:
37
  const char *file;
38
  const char *func;
39
  int         line;
40
41
  SourceLocation()                          = default;
42
  SourceLocation(const SourceLocation &rhs) = default;
43
44
0
  SourceLocation(const char *_file, const char *_func, int _line) : file(_file), func(_func), line(_line) {}
45
46
  bool
47
  valid() const
48
0
  {
49
0
    return file && line;
50
0
  }
51
52
  SourceLocation &
53
  operator=(const SourceLocation &rhs)
54
0
  {
55
0
    this->file = rhs.file;
56
0
    this->func = rhs.func;
57
0
    this->line = rhs.line;
58
0
    return *this;
59
0
  }
60
61
  char               *str(char *buf, int buflen) const;
62
  swoc::BufferWriter &print(swoc::BufferWriter &w, swoc::bwf::Spec const &spec) const;
63
};
64
65
namespace swoc
66
{
67
inline BufferWriter &
68
bwformat(BufferWriter &w, bwf::Spec const &spec, SourceLocation const &loc)
69
0
{
70
0
  return loc.print(w, spec);
71
0
}
72
} // namespace swoc