souffle  2.0.2-371-g6315b36
IO.h
Go to the documentation of this file.
1 /*
2  * Souffle - A Datalog Compiler
3  * Copyright (c) 2013, 2014, 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 IO.h
12  *
13  ***********************************************************************/
14 
15 #pragma once
16 
17 #include "ram/Node.h"
18 #include "ram/Relation.h"
19 #include "ram/RelationStatement.h"
23 #include <algorithm>
24 #include <map>
25 #include <memory>
26 #include <ostream>
27 #include <string>
28 #include <utility>
29 
30 namespace souffle::ram {
31 
32 /**
33  * @class IO
34  * @brief I/O statement for a relation
35  *
36  * I/O operation for a relation, e.g., input/output/printsize
37  */
38 class IO : public RelationStatement {
39 public:
40  IO(std::string rel, std::map<std::string, std::string> directives)
42 
43  /** @brief get I/O directives */
44  const std::map<std::string, std::string>& getDirectives() const {
45  return directives;
46  }
47 
48  /** @get value of I/O directive */
49  const std::string get(const std::string& key) const {
50  return directives.at(key);
51  }
52 
53  IO* clone() const override {
54  return new IO(relation, directives);
55  }
56 
57 protected:
58  void print(std::ostream& os, int tabpos) const override {
59  os << times(" ", tabpos);
60  os << "IO " << relation << " (";
61  os << join(directives, ",", [](std::ostream& out, const auto& arg) {
62  out << arg.first << "=\"" << escape(arg.second) << "\"";
63  });
64  os << ")" << std::endl;
65  };
66 
67  bool equal(const Node& node) const override {
68  const auto& other = static_cast<const IO&>(node);
69  return RelationStatement::equal(other) && directives == other.directives;
70  }
71 
72  /** IO directives */
73  const std::map<std::string, std::string> directives;
74 };
75 
76 } // namespace souffle::ram
RelationStatement.h
souffle::ram::IO::IO
IO(std::string rel, std::map< std::string, std::string > directives)
Definition: IO.h:44
souffle::ram::IO::equal
bool equal(const Node &node) const override
Equality check for two RAM nodes.
Definition: IO.h:71
souffle::ram::RelationStatement::equal
bool equal(const Node &node) const override
Equality check for two RAM nodes.
Definition: RelationStatement.h:47
souffle::ram::RelationStatement::RelationStatement
RelationStatement(std::string rel)
Definition: RelationStatement.h:39
souffle::ram::RelationStatement::relation
std::string relation
Relation.
Definition: RelationStatement.h:54
MiscUtil.h
souffle::ram
Definition: AstToRamTranslator.h:54
souffle::ram::IO::get
const std::string get(const std::string &key) const
@get value of I/O directive
Definition: IO.h:53
souffle::times
detail::multiplying_printer< T > times(const T &value, unsigned num)
A utility printing a given value multiple times.
Definition: StreamUtil.h:322
Relation.h
souffle::join
detail::joined_sequence< Iter, Printer > join(const Iter &a, const Iter &b, const std::string &sep, const Printer &p)
Creates an object to be forwarded to some output stream for printing sequences of elements interspers...
Definition: StreamUtil.h:175
souffle::ram::IO::directives
const std::map< std::string, std::string > directives
IO directives.
Definition: IO.h:77
StringUtil.h
souffle::ram::IO::print
void print(std::ostream &os, int tabpos) const override
Pretty print with indentation.
Definition: IO.h:62
souffle::ram::IO::clone
IO * clone() const override
Create a clone (i.e.
Definition: IO.h:57
souffle::ram::IO::getDirectives
const std::map< std::string, std::string > & getDirectives() const
get I/O directives
Definition: IO.h:48
souffle::ram::IO
I/O statement for a relation.
Definition: IO.h:42
Node.h
souffle::escape
std::string escape(const std::string &inputString, const std::string &needle, const std::string &replacement)
Definition: StringUtil.h:417
std
Definition: Brie.h:3053
StreamUtil.h
rel
void rel(size_t limit, bool showLimit=true)
Definition: Tui.h:1086