souffle  2.0.2-371-g6315b36
Location.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved
4  * Licensed under the Universal Permissive License v 1.0 as shown at:
5  * - https://opensource.org/licenses/UPL
6  * - <souffle root>/licenses/SOUFFLE-UPL.txt
7  */
8 
9 /************************************************************************
10  *
11  * @file Location.h
12  *
13  ***********************************************************************/
14 
15 #pragma once
16 
19 #include <ostream>
20 #include <string>
21 #include <utility>
22 
23 namespace souffle::ast2ram {
24 
25 struct Location {
26  const int identifier;
27  const int element;
28  std::string relation;
29 
30  Location(int ident, int elem, std::string rel = "")
31  : identifier(ident), element(elem), relation(std::move(rel)) {}
32 
33  Location(const Location& l) = default;
34 
35  bool operator==(const Location& loc) const {
36  return identifier == loc.identifier && element == loc.element;
37  }
38 
39  bool operator!=(const Location& loc) const {
40  return !(*this == loc);
41  }
42 
43  bool operator<(const Location& loc) const {
44  return identifier < loc.identifier || (identifier == loc.identifier && element < loc.element);
45  }
46 
47  void print(std::ostream& out) const {
48  out << "(" << identifier << "," << element << ")";
49  }
50 
51  friend std::ostream& operator<<(std::ostream& out, const Location& loc) {
52  loc.print(out);
53  return out;
54  }
55 };
56 
57 } // namespace souffle::ast2ram
souffle::ast2ram::Location::operator<
bool operator<(const Location &loc) const
Definition: Location.h:51
MiscUtil.h
souffle::ast2ram::Location
Definition: Location.h:29
souffle::ast2ram::Location::Location
Location(int ident, int elem, std::string rel="")
Definition: Location.h:38
souffle::ast2ram::Location::relation
std::string relation
Definition: Location.h:36
l
var l
Definition: htmlJsChartistMin.h:15
souffle::ast2ram::Location::operator==
bool operator==(const Location &loc) const
Definition: Location.h:43
souffle::ast2ram::Location::element
const int element
Definition: Location.h:35
ContainerUtil.h
souffle::ast2ram::Location::print
void print(std::ostream &out) const
Definition: Location.h:55
std
Definition: Brie.h:3053
souffle::ast2ram
Definition: AstToRamTranslator.cpp:132
souffle::ast2ram::Location::operator<<
friend std::ostream & operator<<(std::ostream &out, const Location &loc)
Definition: Location.h:59
souffle::ast2ram::Location::operator!=
bool operator!=(const Location &loc) const
Definition: Location.h:47
rel
void rel(size_t limit, bool showLimit=true)
Definition: Tui.h:1086
souffle::ast2ram::Location::identifier
const int identifier
Definition: Location.h:34