blob: 0bc27cd5b43a956e367205888d288e66a5b761b9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "result.h"
#include <vector>
#include <vespa/document/fieldvalue/variablemap.h>
namespace document::select {
class ResultList : public Printable {
public:
using VariableMap = fieldvalue::VariableMap;
using ResultPair = std::pair<VariableMap, const Result*>;
using Results = std::vector<ResultPair>;
using iterator = Results::iterator;
using const_iterator = Results::const_iterator;
using reverse_iterator = Results::reverse_iterator;
ResultList();
ResultList(ResultList &&) noexcept;
ResultList & operator = (ResultList &&) noexcept;
ResultList(const ResultList &) = delete;
ResultList & operator = (const ResultList &) = delete;
~ResultList();
/**
Creates a result list with one element with the given result type and no parameters.
*/
explicit ResultList(const Result& result);
void add(VariableMap variables, const Result& result);
ResultList operator&&(const ResultList& other) const;
ResultList operator||(const ResultList& other) const;
ResultList operator!() &&;
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
bool isEmpty() const { return _results.empty(); }
const Result& combineResults() const;
bool operator==(const ResultList& other) const;
const Results& getResults() const { return _results; }
const_iterator begin() const { return _results.begin(); }
const_iterator end() const { return _results.end(); }
reverse_iterator rbegin() { return _results.rbegin(); }
reverse_iterator rend() { return _results.rend(); }
private:
Results _results;
static bool combineVariables(VariableMap & combination, const VariableMap& output, const VariableMap& input);
};
inline bool operator==(const ResultList& list, const Result& other) {
return (list.combineResults() == other);
}
inline bool operator!=(const ResultList& list, const Result& other) {
return (list.combineResults() != other);
}
}
|