summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--document/src/vespa/document/select/bodyfielddetector.h11
-rw-r--r--document/src/vespa/document/select/branch.cpp7
-rw-r--r--document/src/vespa/document/select/branch.h9
-rw-r--r--document/src/vespa/document/select/cloningvisitor.cpp11
-rw-r--r--document/src/vespa/document/select/cloningvisitor.h7
-rw-r--r--document/src/vespa/document/select/compare.cpp25
-rw-r--r--document/src/vespa/document/select/compare.h7
-rw-r--r--document/src/vespa/document/select/constant.cpp1
-rw-r--r--document/src/vespa/document/select/constant.h7
-rw-r--r--document/src/vespa/document/select/context.cpp2
-rw-r--r--document/src/vespa/document/select/context.h11
-rw-r--r--document/src/vespa/document/select/doctype.h9
-rw-r--r--document/src/vespa/document/select/gid_filter.h6
-rw-r--r--document/src/vespa/document/select/invalidconstant.h9
-rw-r--r--document/src/vespa/document/select/node.h9
-rw-r--r--document/src/vespa/document/select/operator.h7
-rw-r--r--document/src/vespa/document/select/parse_utils.h6
-rw-r--r--document/src/vespa/document/select/result.cpp10
-rw-r--r--document/src/vespa/document/select/result.h3
-rw-r--r--document/src/vespa/document/select/resultlist.cpp26
-rw-r--r--document/src/vespa/document/select/resultlist.h3
-rw-r--r--document/src/vespa/document/select/simpleparser.cpp12
-rw-r--r--document/src/vespa/document/select/traversingvisitor.h5
-rw-r--r--document/src/vespa/document/select/value.cpp6
-rw-r--r--document/src/vespa/document/select/value.h21
-rw-r--r--document/src/vespa/document/select/valuenodes.cpp123
-rw-r--r--document/src/vespa/document/select/valuenodes.h14
-rw-r--r--document/src/vespa/document/select/visitor.h78
28 files changed, 154 insertions, 291 deletions
diff --git a/document/src/vespa/document/select/bodyfielddetector.h b/document/src/vespa/document/select/bodyfielddetector.h
index 8e9fc83b750..028519c8101 100644
--- a/document/src/vespa/document/select/bodyfielddetector.h
+++ b/document/src/vespa/document/select/bodyfielddetector.h
@@ -4,10 +4,11 @@
#include "traversingvisitor.h"
namespace document {
-class DocumentTypeRepo;
-class DocumentType;
+ class DocumentTypeRepo;
+ class DocumentType;
+}
-namespace select {
+namespace document::select {
class BodyFieldDetector : public TraversingVisitor
{
@@ -47,6 +48,4 @@ public:
bool needDocument() const { return _needDocument; }
};
-} // namespace select
-} // namespace document
-
+}
diff --git a/document/src/vespa/document/select/branch.cpp b/document/src/vespa/document/select/branch.cpp
index 5b28fad0df8..b3d5f97ccab 100644
--- a/document/src/vespa/document/select/branch.cpp
+++ b/document/src/vespa/document/select/branch.cpp
@@ -5,8 +5,7 @@
#include <cassert>
#include <ostream>
-namespace document {
-namespace select {
+namespace document::select {
And::And(std::unique_ptr<Node> left, std::unique_ptr<Node> right, const char* name)
: Branch(name ? name : "and"),
@@ -141,6 +140,4 @@ Not::trace(const Context& context, std::ostream& out) const
return traceNotValue(context, out, *_child);
}
-
-} // select
-} // document
+}
diff --git a/document/src/vespa/document/select/branch.h b/document/src/vespa/document/select/branch.h
index a750c2512f9..8637b41de89 100644
--- a/document/src/vespa/document/select/branch.h
+++ b/document/src/vespa/document/select/branch.h
@@ -6,8 +6,6 @@
* @brief Base class for branch nodes in the document selection tree.
*
* @author H�kon Humberset
- * @date 2005-06-07
- * @version $Id$
*/
#pragma once
@@ -16,8 +14,7 @@
#include <list>
#include "node.h"
-namespace document {
-namespace select {
+namespace document::select {
class Branch : public Node
{
@@ -91,6 +88,4 @@ public:
}
};
-} // select
-} // document
-
+}
diff --git a/document/src/vespa/document/select/cloningvisitor.cpp b/document/src/vespa/document/select/cloningvisitor.cpp
index d695e3ec83d..75c8be55729 100644
--- a/document/src/vespa/document/select/cloningvisitor.cpp
+++ b/document/src/vespa/document/select/cloningvisitor.cpp
@@ -8,9 +8,7 @@
#include "invalidconstant.h"
#include "doctype.h"
-namespace document {
-
-namespace select {
+namespace document::select {
const int CloningVisitor::OrPriority;
const int CloningVisitor::AndPriority;
@@ -46,7 +44,7 @@ CloningVisitor::CloningVisitor()
{ }
-CloningVisitor::~CloningVisitor() { }
+CloningVisitor::~CloningVisitor() = default;
void
@@ -350,14 +348,11 @@ CloningVisitor::swap(CloningVisitor &rhs)
void
-CloningVisitor::revisit(void)
+CloningVisitor::revisit()
{
_constVal = false;
_priority = -1;
_resultSet.clear();
}
-
-}
-
}
diff --git a/document/src/vespa/document/select/cloningvisitor.h b/document/src/vespa/document/select/cloningvisitor.h
index 2c5f94c20a4..adc795042a3 100644
--- a/document/src/vespa/document/select/cloningvisitor.h
+++ b/document/src/vespa/document/select/cloningvisitor.h
@@ -5,9 +5,7 @@
#include "resultset.h"
#include <memory>
-namespace document {
-
-namespace select {
+namespace document::select {
class Node;
class ValueNode;
@@ -83,6 +81,3 @@ public:
};
}
-
-}
-
diff --git a/document/src/vespa/document/select/compare.cpp b/document/src/vespa/document/select/compare.cpp
index 1c6b2a9da14..7db40929a64 100644
--- a/document/src/vespa/document/select/compare.cpp
+++ b/document/src/vespa/document/select/compare.cpp
@@ -9,8 +9,7 @@
#include <vespa/document/util/stringutil.h>
#include <ostream>
-namespace document {
-namespace select {
+namespace document::select {
Compare::Compare(std::unique_ptr<ValueNode> left,
const Operator& op,
@@ -24,11 +23,10 @@ Compare::Compare(std::unique_ptr<ValueNode> left,
{
}
-Compare::~Compare()
-{
-}
+Compare::~Compare() = default;
-Node::UP Compare::clone() const
+Node::UP
+Compare::clone() const
{
return wrapParens(new Compare(_left->clone(),
_operator,
@@ -53,10 +51,8 @@ namespace {
&& (op == FunctionOperator::EQ || op == FunctionOperator::NE
|| op == GlobOperator::GLOB))
{
- document::BucketId b(
- static_cast<IntegerValue&>(bVal).getValue());
- document::BucketId s(
- static_cast<IntegerValue&>(nVal).getValue());
+ document::BucketId b( static_cast<IntegerValue&>(bVal).getValue());
+ document::BucketId s( static_cast<IntegerValue&>(nVal).getValue());
ResultList resultList(Result::get(s.contains(b)));
@@ -120,12 +116,14 @@ namespace {
}
}
-ResultList Compare::contains(const Context& context) const
+ResultList
+Compare::contains(const Context& context) const
{
return containsValue<Context>(context, *_left, *_right, _operator);
}
-ResultList Compare::trace(const Context& context, std::ostream& out) const
+ResultList
+Compare::trace(const Context& context, std::ostream& out) const
{
return traceValue(context, *_left, *_right, _operator, out);
}
@@ -150,5 +148,4 @@ Compare::print(std::ostream& out, bool verbose, const std::string& indent) const
if (_parentheses) out << ')';
}
-} // select
-} // document
+}
diff --git a/document/src/vespa/document/select/compare.h b/document/src/vespa/document/select/compare.h
index a4c6a464899..4fa46c2562f 100644
--- a/document/src/vespa/document/select/compare.h
+++ b/document/src/vespa/document/select/compare.h
@@ -17,8 +17,7 @@
#include "operator.h"
#include <vespa/document/bucket/bucketidfactory.h>
-namespace document {
-namespace select {
+namespace document::select {
class ValueNode;
@@ -52,6 +51,4 @@ public:
const BucketIdFactory &getBucketIdFactory(void) const { return _bucketIdFactory; }
};
-} // select
-} // document
-
+}
diff --git a/document/src/vespa/document/select/constant.cpp b/document/src/vespa/document/select/constant.cpp
index 8d1445f40a0..6bca17ff917 100644
--- a/document/src/vespa/document/select/constant.cpp
+++ b/document/src/vespa/document/select/constant.cpp
@@ -2,7 +2,6 @@
#include "constant.h"
#include "visitor.h"
-#include <cassert>
#include <ostream>
namespace document::select {
diff --git a/document/src/vespa/document/select/constant.h b/document/src/vespa/document/select/constant.h
index 46a98ed7eaa..5766f7c9039 100644
--- a/document/src/vespa/document/select/constant.h
+++ b/document/src/vespa/document/select/constant.h
@@ -13,8 +13,7 @@
#include "node.h"
-namespace document {
-namespace select {
+namespace document::select {
class Constant : public Node
{
@@ -36,6 +35,4 @@ public:
};
-} // select
-} // document
-
+}
diff --git a/document/src/vespa/document/select/context.cpp b/document/src/vespa/document/select/context.cpp
index 3a728db33f8..384ac0dad6e 100644
--- a/document/src/vespa/document/select/context.cpp
+++ b/document/src/vespa/document/select/context.cpp
@@ -34,7 +34,7 @@ Context::Context(const DocumentUpdate& docUpdate)
_variables()
{ }
-Context::~Context() { }
+Context::~Context() = default;
std::unique_ptr<Value>
Context::getValue(const vespalib::string & value) const {
diff --git a/document/src/vespa/document/select/context.h b/document/src/vespa/document/select/context.h
index 208a9eb0ee7..d808e8907ae 100644
--- a/document/src/vespa/document/select/context.h
+++ b/document/src/vespa/document/select/context.h
@@ -5,12 +5,12 @@
#include <memory>
namespace document {
+ class Document;
+ class DocumentId;
+ class DocumentUpdate;
+}
-class Document;
-class DocumentId;
-class DocumentUpdate;
-
-namespace select {
+namespace document::select {
class Value;
class VariableMap;
@@ -34,4 +34,3 @@ private:
};
}
-}
diff --git a/document/src/vespa/document/select/doctype.h b/document/src/vespa/document/select/doctype.h
index e72f4c3b56d..749ecedc25f 100644
--- a/document/src/vespa/document/select/doctype.h
+++ b/document/src/vespa/document/select/doctype.h
@@ -6,16 +6,13 @@
* @brief Class matching whether a document is of given type or not.
*
* @author H�kon Humberset
- * @date 2005-06-07
- * @version $Id$
*/
#pragma once
#include "node.h"
-namespace document {
-namespace select {
+namespace document::select {
class DocType : public Node
{
@@ -34,6 +31,4 @@ public:
};
-} // select
-} // document
-
+}
diff --git a/document/src/vespa/document/select/gid_filter.h b/document/src/vespa/document/select/gid_filter.h
index cced811d4dc..a6ea7e083cf 100644
--- a/document/src/vespa/document/select/gid_filter.h
+++ b/document/src/vespa/document/select/gid_filter.h
@@ -3,8 +3,7 @@
#include <vespa/document/base/globalid.h>
-namespace document {
-namespace select {
+namespace document::select {
class Node;
@@ -87,5 +86,4 @@ public:
}
};
-} // select
-} // document
+}
diff --git a/document/src/vespa/document/select/invalidconstant.h b/document/src/vespa/document/select/invalidconstant.h
index b99d0f5a066..a3f4a4d2c4b 100644
--- a/document/src/vespa/document/select/invalidconstant.h
+++ b/document/src/vespa/document/select/invalidconstant.h
@@ -6,16 +6,13 @@
* @brief Class describing an invalid constant in the select tree.
*
* @author H�kon Humberset
- * @date 2005-06-07
- * @version $Id$
*/
#pragma once
#include "node.h"
-namespace document {
-namespace select {
+namespace document::select {
class InvalidConstant : public Node
{
@@ -31,6 +28,4 @@ public:
};
-} // select
-} // document
-
+}
diff --git a/document/src/vespa/document/select/node.h b/document/src/vespa/document/select/node.h
index 1f5c78785d1..48a64ae63f5 100644
--- a/document/src/vespa/document/select/node.h
+++ b/document/src/vespa/document/select/node.h
@@ -6,7 +6,6 @@
* @brief Base class for all nodes in the document selection tree.
*
* @author Håkon Humberset
- * @date 2005-06-07
*/
#pragma once
@@ -14,9 +13,7 @@
#include "resultlist.h"
#include "context.h"
-namespace document {
-
-namespace select {
+namespace document::select {
class Visitor;
@@ -55,6 +52,4 @@ protected:
}
};
-} // select
-} // document
-
+}
diff --git a/document/src/vespa/document/select/operator.h b/document/src/vespa/document/select/operator.h
index 54ef82b01b2..7383b6cf545 100644
--- a/document/src/vespa/document/select/operator.h
+++ b/document/src/vespa/document/select/operator.h
@@ -15,8 +15,7 @@
#include "value.h"
#include <vespa/vespalib/stllike/hash_map.h>
-namespace document {
-namespace select {
+namespace document::select {
class Operator : public Printable {
private:
@@ -101,6 +100,4 @@ private:
ResultList traceImpl(const Value&, const Value&, std::ostream& trace) const;
};
-} // select
-} // document
-
+}
diff --git a/document/src/vespa/document/select/parse_utils.h b/document/src/vespa/document/select/parse_utils.h
index 38c36dfe94a..fb8667f0f7c 100644
--- a/document/src/vespa/document/select/parse_utils.h
+++ b/document/src/vespa/document/select/parse_utils.h
@@ -1,8 +1,8 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <stdint.h>
-#include <stddef.h>
+#include <cstdint>
+#include <cstddef>
namespace document::select::util {
@@ -14,4 +14,4 @@ bool parse_hex_i64(const char* str, size_t len, int64_t& out);
bool parse_i64(const char* str, size_t len, int64_t& out);
bool parse_double(const char* str, size_t len, double& out);
-} \ No newline at end of file
+}
diff --git a/document/src/vespa/document/select/result.cpp b/document/src/vespa/document/select/result.cpp
index 3a6b8783faa..f7f95732c78 100644
--- a/document/src/vespa/document/select/result.cpp
+++ b/document/src/vespa/document/select/result.cpp
@@ -3,16 +3,13 @@
#include "result.h"
#include <ostream>
-namespace document {
-namespace select {
+namespace document::select {
Result Result::Invalid;
Result Result::False;
Result Result::True;
-Result::Result()
-{
-}
+Result::Result() = default;
const Result&
Result::operator!() const {
@@ -50,5 +47,4 @@ Result::print(std::ostream& out, bool,
else out << "False";
}
-} // select
-} // document
+}
diff --git a/document/src/vespa/document/select/result.h b/document/src/vespa/document/select/result.h
index 4e30cb5a8af..9cc33b79944 100644
--- a/document/src/vespa/document/select/result.h
+++ b/document/src/vespa/document/select/result.h
@@ -13,13 +13,10 @@
* thus used as it has 3 outcomes.. True, false & invalid.
*
* @author H�kon Humberset
- * @date 2007-20-05
- * @version $Id$
*/
#pragma once
-#include <assert.h>
#include <vespa/vespalib/util/hdr_abort.h>
#include <vespa/document/util/printable.h>
diff --git a/document/src/vespa/document/select/resultlist.cpp b/document/src/vespa/document/select/resultlist.cpp
index c69f7a5d5f8..60361223a64 100644
--- a/document/src/vespa/document/select/resultlist.cpp
+++ b/document/src/vespa/document/select/resultlist.cpp
@@ -3,12 +3,11 @@
#include "resultlist.h"
#include <ostream>
-namespace document {
-namespace select {
+namespace document::select {
-ResultList::ResultList() : _results() { }
+ResultList::ResultList() = default;
-ResultList::~ResultList() { }
+ResultList::~ResultList() = default;
ResultList::ResultList(const Result& result) {
add(VariableMap(), result);
@@ -68,27 +67,27 @@ ResultList::combineVariables(
const fieldvalue::VariableMap& input) const
{
// First, verify that all variables are overlapping
- for (fieldvalue::VariableMap::const_iterator iter = output.begin(); iter != output.end(); iter++) {
- fieldvalue::VariableMap::const_iterator found(input.find(iter->first));
+ for (const auto & ovar : output) {
+ auto found(input.find(ovar.first));
if (found != input.end()) {
- if (!(found->second == iter->second)) {
+ if (!(found->second == ovar.second)) {
return false;
}
}
}
- for (fieldvalue::VariableMap::const_iterator iter = input.begin(); iter != input.end(); iter++) {
- fieldvalue::VariableMap::const_iterator found(output.find(iter->first));
+ for (const auto & ivar : input) {
+ auto found(output.find(ivar.first));
if (found != output.end()) {
- if (!(found->second == iter->second)) {
+ if (!(found->second == ivar.second)) {
return false;
}
}
}
// Ok, variables are overlapping. Add all variables from input to output.
- for (fieldvalue::VariableMap::const_iterator iter = input.begin(); iter != input.end(); iter++) {
- output[iter->first] = iter->second;
+ for (const auto & ivar : input) {
+ output[ivar.first] = ivar.second;
}
return true;
@@ -147,5 +146,4 @@ bool ResultList::operator==(const ResultList& other) const {
return (combineResultsLocal(_results) == combineResultsLocal(other._results));
}
-} // select
-} // document
+}
diff --git a/document/src/vespa/document/select/resultlist.h b/document/src/vespa/document/select/resultlist.h
index cd019828ce1..43b9b40e8fd 100644
--- a/document/src/vespa/document/select/resultlist.h
+++ b/document/src/vespa/document/select/resultlist.h
@@ -41,11 +41,8 @@ public:
bool operator==(const ResultList& other) const;
const Results& getResults() const { return _results; }
- Results& getResults() { return _results; }
const_iterator begin() const { return _results.begin(); }
const_iterator end() const { return _results.end(); }
- iterator begin() { return _results.begin(); }
- iterator end() { return _results.end(); }
const_reverse_iterator rbegin() const { return _results.rbegin(); }
const_reverse_iterator rend() const { return _results.rend(); }
diff --git a/document/src/vespa/document/select/simpleparser.cpp b/document/src/vespa/document/select/simpleparser.cpp
index 879a1f195e8..9a898e63eeb 100644
--- a/document/src/vespa/document/select/simpleparser.cpp
+++ b/document/src/vespa/document/select/simpleparser.cpp
@@ -4,11 +4,7 @@
#include "compare.h"
#include <cerrno>
-namespace document {
-
-namespace select {
-
-namespace simple {
+namespace document::select::simple {
size_t eatWhite(const char * s, size_t len)
{
@@ -197,8 +193,4 @@ bool SelectionParser::parse(vespalib::stringref s)
return retval;
}
-
-
-} // simple
-} // select
-} // parser
+}
diff --git a/document/src/vespa/document/select/traversingvisitor.h b/document/src/vespa/document/select/traversingvisitor.h
index f8b0377b102..6b9a4317bea 100644
--- a/document/src/vespa/document/select/traversingvisitor.h
+++ b/document/src/vespa/document/select/traversingvisitor.h
@@ -3,8 +3,7 @@
#include "visitor.h"
-namespace document {
-namespace select {
+namespace document::select {
class
TraversingVisitor : public Visitor
@@ -32,5 +31,3 @@ public:
};
}
-
-}
diff --git a/document/src/vespa/document/select/value.cpp b/document/src/vespa/document/select/value.cpp
index 5ebf527b82b..a33ee27afdb 100644
--- a/document/src/vespa/document/select/value.cpp
+++ b/document/src/vespa/document/select/value.cpp
@@ -5,8 +5,7 @@
#include <vespa/document/fieldvalue/fieldvalue.h>
#include <ostream>
-namespace document {
-namespace select {
+namespace document::select {
ResultList
Value::globCompare(const Value& value) const
@@ -418,5 +417,4 @@ ArrayValue::doCompare(const Value& value, const Predicate& cmp) const
}
}
-} // select
-} // document
+}
diff --git a/document/src/vespa/document/select/value.h b/document/src/vespa/document/select/value.h
index 2951117302e..a7f3abef81a 100644
--- a/document/src/vespa/document/select/value.h
+++ b/document/src/vespa/document/select/value.h
@@ -23,8 +23,7 @@
#include <iosfwd>
#include "resultlist.h"
-namespace document {
-namespace select {
+namespace document::select {
class Value : public document::Printable
{
@@ -69,7 +68,7 @@ public:
ResultList operator<(const Value&) const override;
ResultList operator==(const Value&) const override;
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
- Value::UP clone() const override { return Value::UP(new InvalidValue()); }
+ Value::UP clone() const override { return std::make_unique<InvalidValue>(); }
};
class NullValue : public Value
@@ -83,7 +82,7 @@ public:
ResultList operator>=(const Value &) const override;
ResultList operator<=(const Value &) const override;
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
- Value::UP clone() const override { return Value::UP(new NullValue()); }
+ Value::UP clone() const override { return std::make_unique<NullValue>(); }
};
class StringValue : public Value
@@ -97,7 +96,7 @@ public:
ResultList operator<(const Value& value) const override;
ResultList operator==(const Value& value) const override;
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
- Value::UP clone() const override { return Value::UP(new StringValue(_value)); }
+ Value::UP clone() const override { return std::make_unique<StringValue>(_value); }
};
class IntegerValue;
@@ -140,7 +139,7 @@ public:
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
Value::UP clone() const override {
- return Value::UP(new IntegerValue(_value, getType() == Value::Bucket));
+ return std::make_unique<IntegerValue>(_value, getType() == Value::Bucket);
}
private:
ValueType _value;
@@ -165,7 +164,7 @@ public:
ResultList operator==(const FloatValue& value) const override;
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
- Value::UP clone() const override { return Value::UP(new FloatValue(_value)); }
+ Value::UP clone() const override { return std::make_unique<FloatValue>(_value); }
private:
ValueType _value;
};
@@ -211,7 +210,7 @@ public:
template <typename Predicate>
ResultList doCompare(const Value& value, const Predicate& cmp) const;
- Value::UP clone() const override { return Value::UP(new ArrayValue(_values)); }
+ Value::UP clone() const override { return std::make_unique<ArrayValue>(_values); }
private:
struct EqualsComparator;
@@ -236,11 +235,9 @@ public:
ResultList operator==(const Value& value) const override;
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
- Value::UP clone() const override { return Value::UP(new StructValue(_values)); }
+ Value::UP clone() const override { return std::make_unique<StructValue>(_values); }
private:
ValueMap _values;
};
-} // select
-} // document
-
+}
diff --git a/document/src/vespa/document/select/valuenodes.cpp b/document/src/vespa/document/select/valuenodes.cpp
index bc94e3667d2..1eb25b9b6c6 100644
--- a/document/src/vespa/document/select/valuenodes.cpp
+++ b/document/src/vespa/document/select/valuenodes.cpp
@@ -60,7 +60,7 @@ InvalidValueNode::print(std::ostream& out, bool verbose,
if (hadParentheses()) out << ')';
}
-NullValueNode::NullValueNode() {}
+NullValueNode::NullValueNode() = default;
void
NullValueNode::visit(Visitor &visitor) const
@@ -222,8 +222,8 @@ private:
std::unique_ptr<Value> getInternalValue(const FieldValue &fval) const;
};
-IteratorHandler::IteratorHandler() { }
-IteratorHandler::~IteratorHandler() { }
+IteratorHandler::IteratorHandler() = default;
+IteratorHandler::~IteratorHandler() = default;
bool
IteratorHandler::hasSingleValue() const {
@@ -343,13 +343,13 @@ std::unique_ptr<Value>
FieldValueNode::getValue(const Context& context) const
{
if (context._doc == NULL) {
- return std::unique_ptr<Value>(new InvalidValue());
+ return std::make_unique<InvalidValue>();
}
const Document& doc = *context._doc;
if (!documentTypeEqualsName(doc.getType(), _doctype)) {
- return std::unique_ptr<Value>(new InvalidValue());
+ return std::make_unique<InvalidValue>();
}
try{
initFieldPath(doc.getType());
@@ -363,17 +363,17 @@ FieldValueNode::getValue(const Context& context) const
const std::vector<ArrayValue::VariableValue>& values = handler.getValues();
if (values.size() == 0) {
- return std::unique_ptr<Value>(new NullValue());
+ return std::make_unique<NullValue>();
} else {
- return std::unique_ptr<Value>(new ArrayValue(handler.getValues()));
+ return std::make_unique<ArrayValue>(handler.getValues());
}
}
} catch (vespalib::IllegalArgumentException& e) {
LOG(warning, "Caught exception while fetching field from document: %s", e.what());
- return std::unique_ptr<Value>(new InvalidValue());
+ return std::make_unique<InvalidValue>();
} catch (FieldNotFoundException& e) {
LOG(warning, "Tried to compare to field %s, not found in document type", _fieldExpression.c_str());
- return std::unique_ptr<Value>(new InvalidValue());
+ return std::make_unique<InvalidValue>();
}
}
@@ -405,7 +405,7 @@ FieldValueNode::traceValue(const Context &context, std::ostream& out) const
if (!documentTypeEqualsName(doc.getType(), _doctype)) {
out << "Document is of type " << doc.getType() << " which isn't a "
<< _doctype << " document, thus resolving invalid.\n";
- return std::unique_ptr<Value>(new InvalidValue());
+ return std::make_unique<InvalidValue>();
}
try{
initFieldPath(doc.getType());
@@ -419,9 +419,9 @@ FieldValueNode::traceValue(const Context &context, std::ostream& out) const
const std::vector<ArrayValue::VariableValue>& values = handler.getValues();
if (values.size() == 0) {
- return std::unique_ptr<Value>(new NullValue());
+ return std::make_unique<NullValue>();
} else {
- return std::unique_ptr<Value>(new ArrayValue(handler.getValues()));
+ return std::make_unique<ArrayValue>(handler.getValues());
}
}
} catch (FieldNotFoundException& e) {
@@ -429,7 +429,7 @@ FieldValueNode::traceValue(const Context &context, std::ostream& out) const
_fieldExpression.c_str());
out << "Field not found in document type " << doc.getType()
<< ". Returning invalid.\n";
- return std::unique_ptr<Value>(new InvalidValue());
+ return std::make_unique<InvalidValue>();
}
}
@@ -489,9 +489,7 @@ IdValueNode::getValue(const DocumentId& id) const
vespalib::string value;
switch (_type) {
case BUCKET:
- return std::unique_ptr<Value>(
- new IntegerValue(
- _bucketIdFactory.getBucketId(id).getId(), true));
+ return std::make_unique<IntegerValue>(_bucketIdFactory.getBucketId(id).getId(), true);
case NS:
value = id.getScheme().getNamespace(); break;
case SCHEME:
@@ -501,7 +499,7 @@ IdValueNode::getValue(const DocumentId& id) const
if (id.getScheme().hasDocType()) {
value = id.getScheme().getDocType();
} else {
- return std::unique_ptr<Value>(new InvalidValue);
+ return std::make_unique<InvalidValue>();
}
break;
case SPEC:
@@ -516,7 +514,7 @@ IdValueNode::getValue(const DocumentId& id) const
} else {
fprintf(stderr, "***** Returning invalid value for %s\n",
id.toString().c_str());
- return std::unique_ptr<Value>(new InvalidValue);
+ return std::make_unique<InvalidValue>();
}
break;
case GID:
@@ -524,14 +522,13 @@ IdValueNode::getValue(const DocumentId& id) const
break;
case USER:
if (id.getScheme().hasNumber()) {
- return std::unique_ptr<Value>(
- new IntegerValue(id.getScheme().getNumber(), false));
+ return std::make_unique<IntegerValue>(id.getScheme().getNumber(), false);
} else {
- return std::unique_ptr<Value>(new InvalidValue);
+ return std::make_unique<InvalidValue>();
}
}
- return std::unique_ptr<Value>(new StringValue(value));
+ return std::make_unique<StringValue>(value);
}
@@ -557,11 +554,8 @@ IdValueNode::traceValue(const DocumentId& id, std::ostream& out) const
case BUCKET:
{
document::BucketId bucket(_bucketIdFactory.getBucketId(id));
- std::unique_ptr<Value> result(
- new IntegerValue(bucket.getId(), true));
- out << "Found id.bucket specification. Resolved to "
- << bucket.toString() << ".\n";
- return result;
+ out << "Found id.bucket specification. Resolved to " << bucket.toString() << ".\n";
+ return std::make_unique<IntegerValue>(bucket.getId(), true);
}
case NS:
value = id.getScheme().getNamespace();
@@ -577,7 +571,7 @@ IdValueNode::traceValue(const DocumentId& id, std::ostream& out) const
out << "Resolved id.type to value\"" << value << "\".\n";
} else {
out << "Could not resolve type of doc " << id << ".\n";
- return std::unique_ptr<Value>(new InvalidValue);
+ return std::make_unique<InvalidValue>();
}
break;
case SPEC:
@@ -595,7 +589,7 @@ IdValueNode::traceValue(const DocumentId& id, std::ostream& out) const
<< ") to \"" << value << "\".\n";
} else {
out << "Can't resolve group of doc \"" << id << "\".\n";
- return std::unique_ptr<Value>(new InvalidValue);
+ return std::make_unique<InvalidValue>();
}
break;
case GID:
@@ -604,18 +598,17 @@ IdValueNode::traceValue(const DocumentId& id, std::ostream& out) const
break;
case USER:
if (id.getScheme().hasNumber()) {
- std::unique_ptr<Value> result(
- new IntegerValue(id.getScheme().getNumber(), false));
+ auto result = std::make_unique<IntegerValue>(id.getScheme().getNumber(), false);
out << "Resolved user of doc type " << id.getScheme().getType()
<< " to " << *result << ".\n";
return result;
} else {
out << "Could not resolve user of doc " << id << ".\n";
- return std::unique_ptr<Value>(new InvalidValue);
+ return std::make_unique<InvalidValue>();
}
}
- return std::unique_ptr<Value>(new StringValue(value));
+ return std::make_unique<StringValue>(value);
}
@@ -677,12 +670,9 @@ FunctionValueNode::getValue(std::unique_ptr<Value> val) const
{
StringValue& sval(static_cast<StringValue&>(*val));
if (_function == LOWERCASE) {
- return std::unique_ptr<Value>(new StringValue(
- vespalib::LowerCase::convert(sval.getValue())));
+ return std::make_unique<StringValue>(vespalib::LowerCase::convert(sval.getValue()));
} else if (_function == HASH) {
- return std::unique_ptr<Value>(new IntegerValue(
- hash(sval.getValue().c_str(), sval.getValue().size()),
- false));
+ return std::make_unique<IntegerValue>(hash(sval.getValue().c_str(), sval.getValue().size()), false);
}
break;
}
@@ -691,12 +681,11 @@ FunctionValueNode::getValue(std::unique_ptr<Value> val) const
FloatValue& fval(static_cast<FloatValue&>(*val));
if (_function == HASH) {
FloatValue::ValueType ffval = fval.getValue();
- return std::unique_ptr<Value>(new IntegerValue(
- hash(&ffval, sizeof(ffval)), false));
+ return std::make_unique<IntegerValue>(hash(&ffval, sizeof(ffval)), false);
} else if (_function == ABS) {
FloatValue::ValueType ffval = fval.getValue();
if (ffval < 0) ffval *= -1;
- return std::unique_ptr<Value>(new FloatValue(ffval));
+ return std::make_unique<FloatValue>(ffval);
}
break;
}
@@ -705,12 +694,11 @@ FunctionValueNode::getValue(std::unique_ptr<Value> val) const
IntegerValue& ival(static_cast<IntegerValue&>(*val));
if (_function == HASH) {
IntegerValue::ValueType iival = ival.getValue();
- return std::unique_ptr<Value>(new IntegerValue(
- hash(&iival, sizeof(iival)), false));
+ return std::make_unique<IntegerValue>(hash(&iival, sizeof(iival)), false);
} else if (_function == ABS) {
IntegerValue::ValueType iival = ival.getValue();
if (iival < 0) iival *= -1;
- return std::unique_ptr<Value>(new IntegerValue(iival, false));
+ return std::make_unique<IntegerValue>(iival, false);
}
break;
}
@@ -727,27 +715,23 @@ FunctionValueNode::getValue(std::unique_ptr<Value> val) const
case Value::Invalid: break;
case Value::Null: break;
}
- return std::unique_ptr<Value>(new InvalidValue);
+ return std::make_unique<InvalidValue>();
}
std::unique_ptr<Value>
-FunctionValueNode::traceValue(std::unique_ptr<Value> val,
- std::ostream& out) const
+FunctionValueNode::traceValue(std::unique_ptr<Value> val, std::ostream& out) const
{
switch (val->getType()) {
case Value::String:
{
StringValue& sval(static_cast<StringValue&>(*val));
if (_function == LOWERCASE) {
- std::unique_ptr<Value> result(new StringValue(
- vespalib::LowerCase::convert(sval.getValue())));
+ auto result = std::make_unique<StringValue>(vespalib::LowerCase::convert(sval.getValue()));
out << "Performed lowercase function on '" << sval
<< "' => '" << *result << "'.\n";
return result;
} else if (_function == HASH) {
- std::unique_ptr<Value> result(new IntegerValue(
- hash(sval.getValue().c_str(), sval.getValue().size()),
- false));
+ auto result = std::make_unique<IntegerValue>(hash(sval.getValue().c_str(), sval.getValue().size()), false);
out << "Performed hash on string '" << sval << "' -> "
<< *result << "\n";
return result;
@@ -759,8 +743,7 @@ FunctionValueNode::traceValue(std::unique_ptr<Value> val,
FloatValue& fval(static_cast<FloatValue&>(*val));
if (_function == HASH) {
FloatValue::ValueType ffval = fval.getValue();
- std::unique_ptr<Value> result(new IntegerValue(
- hash(&ffval, sizeof(ffval)), false));
+ auto result = std::make_unique<IntegerValue>(hash(&ffval, sizeof(ffval)), false);
out << "Performed hash on float " << ffval << " -> " << *result
<< "\n";
return result;
@@ -769,7 +752,7 @@ FunctionValueNode::traceValue(std::unique_ptr<Value> val,
if (ffval < 0) ffval *= -1;
out << "Performed abs on float " << fval.getValue() << " -> "
<< ffval << "\n";
- return std::unique_ptr<Value>(new FloatValue(ffval));
+ return std::make_unique<FloatValue>(ffval);
}
break;
}
@@ -778,8 +761,7 @@ FunctionValueNode::traceValue(std::unique_ptr<Value> val,
IntegerValue& ival(static_cast<IntegerValue&>(*val));
if (_function == HASH) {
IntegerValue::ValueType iival = ival.getValue();
- std::unique_ptr<Value> result(new IntegerValue(
- hash(&iival, sizeof(iival)), false));
+ auto result = std::make_unique<IntegerValue>(hash(&iival, sizeof(iival)), false);
out << "Performed hash on float " << iival << " -> " << *result
<< "\n";
return result;
@@ -788,7 +770,7 @@ FunctionValueNode::traceValue(std::unique_ptr<Value> val,
if (iival < 0) iival *= -1;
out << "Performed abs on integer " << ival.getValue() << " -> "
<< iival << "\n";
- return std::unique_ptr<Value>(new IntegerValue(iival, false));
+ return std::make_unique<IntegerValue>(iival, false);
}
break;
}
@@ -800,7 +782,7 @@ FunctionValueNode::traceValue(std::unique_ptr<Value> val,
}
out << "Cannot use function " << _function << " on a value of type "
<< val->getType() << ". Resolving invalid.\n";
- return std::unique_ptr<Value>(new InvalidValue);
+ return std::make_unique<InvalidValue>();
}
@@ -866,8 +848,7 @@ ArithmeticValueNode::getValue(std::unique_ptr<Value> lval,
{
StringValue& slval(static_cast<StringValue&>(*lval));
StringValue& srval(static_cast<StringValue&>(*rval));
- return std::unique_ptr<Value>(new StringValue(
- slval.getValue() + srval.getValue()));
+ return std::make_unique<StringValue>(slval.getValue() + srval.getValue());
}
}
[[fallthrough]];
@@ -894,7 +875,7 @@ ArithmeticValueNode::getValue(std::unique_ptr<Value> lval,
break;
case MOD: assert(0);
}
- return std::unique_ptr<Value>(new IntegerValue(res, false));
+ return std::make_unique<IntegerValue>(res, false);
}
NumberValue* nlval(dynamic_cast<NumberValue*>(lval.get()));
NumberValue* nrval(dynamic_cast<NumberValue*>(rval.get()));
@@ -917,7 +898,7 @@ ArithmeticValueNode::getValue(std::unique_ptr<Value> lval,
break;
case MOD: assert(0);
}
- return std::unique_ptr<Value>(new FloatValue(res));
+ return std::make_unique<FloatValue>(res);
}
}
break;
@@ -929,7 +910,7 @@ ArithmeticValueNode::getValue(std::unique_ptr<Value> lval,
IntegerValue& ilval(static_cast<IntegerValue&>(*lval));
IntegerValue& irval(static_cast<IntegerValue&>(*rval));
if (irval.getValue() != 0) {
- return std::unique_ptr<Value>(new IntegerValue(ilval.getValue() % irval.getValue(), false));
+ return std::make_unique<IntegerValue>(ilval.getValue() % irval.getValue(), false);
} else {
throw vespalib::IllegalArgumentException("Division by zero");
}
@@ -937,7 +918,7 @@ ArithmeticValueNode::getValue(std::unique_ptr<Value> lval,
}
break;
}
- return std::unique_ptr<Value>(new InvalidValue);
+ return std::make_unique<InvalidValue>();
}
std::unique_ptr<Value>
@@ -953,8 +934,7 @@ ArithmeticValueNode::traceValue(std::unique_ptr<Value> lval,
{
StringValue& slval(static_cast<StringValue&>(*lval));
StringValue& srval(static_cast<StringValue&>(*rval));
- std::unique_ptr<Value> result(new StringValue(
- slval.getValue() + srval.getValue()));
+ auto result = std::make_unique<StringValue>(slval.getValue() + srval.getValue());
out << "Appended strings '" << slval << "' + '" << srval
<< "' -> '" << *result << "'.\n";
return result;
@@ -978,7 +958,7 @@ ArithmeticValueNode::traceValue(std::unique_ptr<Value> lval,
case DIV: res = ilval.getValue() / irval.getValue(); break;
case MOD: assert(0);
}
- std::unique_ptr<Value> result(new IntegerValue(res, false));
+ auto result = std::make_unique<IntegerValue>(res, false);
out << "Performed integer operation " << ilval << " "
<< getOperatorName() << " " << irval << " = " << *result
<< "\n";
@@ -999,7 +979,7 @@ ArithmeticValueNode::traceValue(std::unique_ptr<Value> lval,
/ nrval->getCommonValue(); break;
case MOD: assert(0);
}
- std::unique_ptr<Value> result(new FloatValue(res));
+ auto result = std::make_unique<FloatValue>(res);
out << "Performed float operation " << nlval << " "
<< getOperatorName() << " " << nrval << " = " << *result
<< "\n";
@@ -1014,8 +994,7 @@ ArithmeticValueNode::traceValue(std::unique_ptr<Value> lval,
{
IntegerValue& ilval(static_cast<IntegerValue&>(*lval));
IntegerValue& irval(static_cast<IntegerValue&>(*rval));
- std::unique_ptr<Value> result(new IntegerValue(
- ilval.getValue() % irval.getValue(), false));
+ auto result = std::make_unique<IntegerValue>(ilval.getValue() % irval.getValue(), false);
out << "Performed integer operation " << ilval << " "
<< getOperatorName() << " " << irval << " = " << *result
<< "\n";
@@ -1027,7 +1006,7 @@ ArithmeticValueNode::traceValue(std::unique_ptr<Value> lval,
out << "Failed to do operation " << getOperatorName()
<< " on values of type " << lval->getType() << " and "
<< rval->getType() << ". Resolving invalid.\n";
- return std::unique_ptr<Value>(new InvalidValue);
+ return std::make_unique<InvalidValue>();
}
diff --git a/document/src/vespa/document/select/valuenodes.h b/document/src/vespa/document/select/valuenodes.h
index 4ddbee16f8c..02079c0b5df 100644
--- a/document/src/vespa/document/select/valuenodes.h
+++ b/document/src/vespa/document/select/valuenodes.h
@@ -22,7 +22,7 @@ public:
InvalidValueNode(vespalib::stringref name);
std::unique_ptr<Value> getValue(const Context&) const override {
- return std::unique_ptr<Value>(new InvalidValue());
+ return std::make_unique<InvalidValue>();
}
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
@@ -39,7 +39,7 @@ public:
NullValueNode();
std::unique_ptr<Value> getValue(const Context&) const override {
- return std::unique_ptr<Value>(new NullValue());
+ return std::make_unique<NullValue>();
}
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
@@ -60,7 +60,7 @@ public:
const vespalib::string& getValue() const { return _value; }
std::unique_ptr<Value> getValue(const Context&) const override {
- return std::unique_ptr<Value>(new StringValue(_value));
+ return std::make_unique<StringValue>(_value);
}
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
@@ -81,8 +81,8 @@ public:
int64_t getValue() const { return _value; }
- virtual std::unique_ptr<Value> getValue(const Context&) const override {
- return std::unique_ptr<Value>(new IntegerValue(_value, _isBucketValue));
+ std::unique_ptr<Value> getValue(const Context&) const override {
+ return std::make_unique<IntegerValue>(_value, _isBucketValue);
}
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
@@ -99,7 +99,7 @@ public:
int64_t getValue() const;
std::unique_ptr<Value> getValue(const Context&) const override {
- return std::unique_ptr<Value>(new IntegerValue(getValue(), false));
+ return std::make_unique<IntegerValue>(getValue(), false);
}
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
@@ -137,7 +137,7 @@ public:
double getValue() const { return _value; }
std::unique_ptr<Value> getValue(const Context&) const override {
- return std::unique_ptr<Value>(new FloatValue(_value));
+ return std::make_unique<FloatValue>(_value);
}
void print(std::ostream& out, bool verbose, const std::string& indent) const override;
diff --git a/document/src/vespa/document/select/visitor.h b/document/src/vespa/document/select/visitor.h
index c0798c8eb6d..28a91f8d0d4 100644
--- a/document/src/vespa/document/select/visitor.h
+++ b/document/src/vespa/document/select/visitor.h
@@ -12,8 +12,7 @@
#pragma once
-namespace document {
-namespace select {
+namespace document::select {
class And;
class Compare;
@@ -38,61 +37,24 @@ class Visitor {
public:
virtual ~Visitor() {}
- virtual void
- visitAndBranch(const And &) = 0;
-
- virtual void
- visitComparison(const Compare &) = 0;
-
- virtual void
- visitConstant(const Constant &) = 0;
-
- virtual void
- visitInvalidConstant(const InvalidConstant &) = 0;
-
- virtual void
- visitDocumentType(const DocType &) = 0;
-
- virtual void
- visitNotBranch(const Not &) = 0;
-
- virtual void
- visitOrBranch(const Or &) = 0;
-
- virtual void
- visitArithmeticValueNode(const ArithmeticValueNode &) = 0;
-
- virtual void
- visitFunctionValueNode(const FunctionValueNode &) = 0;
-
- virtual void
- visitIdValueNode(const IdValueNode &) = 0;
-
- virtual void
- visitFieldValueNode(const FieldValueNode &) = 0;
-
- virtual void
- visitFloatValueNode(const FloatValueNode &) = 0;
-
- virtual void
- visitVariableValueNode(const VariableValueNode &) = 0;
-
- virtual void
- visitIntegerValueNode(const IntegerValueNode &) = 0;
-
- virtual void
- visitCurrentTimeValueNode(const CurrentTimeValueNode &) = 0;
-
- virtual void
- visitStringValueNode(const StringValueNode &) = 0;
-
- virtual void
- visitNullValueNode(const NullValueNode &) = 0;
-
- virtual void
- visitInvalidValueNode(const InvalidValueNode &) = 0;
+ virtual void visitAndBranch(const And &) = 0;
+ virtual void visitComparison(const Compare &) = 0;
+ virtual void visitConstant(const Constant &) = 0;
+ virtual void visitInvalidConstant(const InvalidConstant &) = 0;
+ virtual void visitDocumentType(const DocType &) = 0;
+ virtual void visitNotBranch(const Not &) = 0;
+ virtual void visitOrBranch(const Or &) = 0;
+ virtual void visitArithmeticValueNode(const ArithmeticValueNode &) = 0;
+ virtual void visitFunctionValueNode(const FunctionValueNode &) = 0;
+ virtual void visitIdValueNode(const IdValueNode &) = 0;
+ virtual void visitFieldValueNode(const FieldValueNode &) = 0;
+ virtual void visitFloatValueNode(const FloatValueNode &) = 0;
+ virtual void visitVariableValueNode(const VariableValueNode &) = 0;
+ virtual void visitIntegerValueNode(const IntegerValueNode &) = 0;
+ virtual void visitCurrentTimeValueNode(const CurrentTimeValueNode &) = 0;
+ virtual void visitStringValueNode(const StringValueNode &) = 0;
+ virtual void visitNullValueNode(const NullValueNode &) = 0;
+ virtual void visitInvalidValueNode(const InvalidValueNode &) = 0;
};
-} // select
-} // document
-
+}