YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/yql/cql/ql/parser/location.h
Line
Count
Source
1
//--------------------------------------------------------------------------------------------------
2
// Copyright (c) YugaByte, Inc.
3
//
4
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5
// in compliance with the License.  You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software distributed under the License
10
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11
// or implied.  See the License for the specific language governing permissions and limitations
12
// under the License.
13
//
14
//
15
// Wrapper for BISON location.hh. This module implements the abstract interface YBLocation, which
16
// identifies the location of tokens in SQL statement. When generating parse tree, the parser
17
// (BISON) will save the location values in the tree nodes.
18
//--------------------------------------------------------------------------------------------------
19
20
#ifndef YB_YQL_CQL_QL_PARSER_LOCATION_H_
21
#define YB_YQL_CQL_QL_PARSER_LOCATION_H_
22
23
#include "yb/yql/cql/ql/ptree/yb_location.h"
24
#include "yb/yql/cql/ql/parser/location.hh"
25
26
namespace yb {
27
namespace ql {
28
29
class Location : public YBLocation {
30
 public:
31
  //------------------------------------------------------------------------------------------------
32
  // Public types.
33
  typedef MCSharedPtr<Location> SharedPtr;
34
  typedef MCSharedPtr<const Location> SharedPtrConst;
35
36
  //------------------------------------------------------------------------------------------------
37
  // Constructor.
38
99
  explicit Location(const location& loc) : loc_(loc) {
39
99
  }
40
4.42M
  Location(MemoryContext *memctx, const location& loc) : loc_(loc) {
41
4.42M
  }
42
4.42M
  virtual ~Location() {
43
4.42M
  }
44
45
  // shared_ptr support.
46
  template<typename... TypeArgs>
47
4.40M
  inline static Location::SharedPtr MakeShared(MemoryContext *memctx, TypeArgs&&... args) {
48
4.40M
    return MCMakeShared<Location>(memctx, std::forward<TypeArgs>(args)...);
49
4.40M
  }
50
51
  // Abstract interface.
52
137k
  virtual int BeginLine() const {
53
137k
    return loc_.begin.line;
54
137k
  }
55
56
73.3k
  virtual int BeginColumn() const {
57
73.3k
    return loc_.begin.column;
58
73.3k
  }
59
60
8.98k
  virtual int EndLine() const {
61
8.98k
    return loc_.end.line;
62
8.98k
  }
63
64
8.99k
  virtual int EndColumn() const {
65
8.99k
    return loc_.end.column;
66
8.99k
  }
67
68
 private:
69
  location loc_;
70
};
71
72
} // namespace ql
73
} // namespace yb
74
75
#endif // YB_YQL_CQL_QL_PARSER_LOCATION_H_