summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-07-27 14:15:30 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2017-07-31 17:27:03 +0200
commit2c6c59936b99a18d364d46aeee2974aeef25774b (patch)
tree3b83251c858cd21fce6392183b16b9fa0591209f /document
parent157ff8c0b62477efeea1947b80ad62c54a51decc (diff)
Make FieldPath non-copyable.
Diffstat (limited to 'document')
-rw-r--r--document/src/tests/documentselectparsertest.cpp16
-rw-r--r--document/src/vespa/document/base/fieldpath.cpp21
-rw-r--r--document/src/vespa/document/base/fieldpath.h6
-rw-r--r--document/src/vespa/document/datatype/mapdatatype.cpp2
-rw-r--r--document/src/vespa/document/select/valuenodes.cpp4
-rw-r--r--document/src/vespa/document/select/valuenodes.h4
6 files changed, 29 insertions, 24 deletions
diff --git a/document/src/tests/documentselectparsertest.cpp b/document/src/tests/documentselectparsertest.cpp
index b6bfaece448..c5715ae5114 100644
--- a/document/src/tests/documentselectparsertest.cpp
+++ b/document/src/tests/documentselectparsertest.cpp
@@ -50,7 +50,7 @@ class DocumentSelectParserTest : public CppUnit::TestFixture {
const std::string& doctype, const std::string& id, uint32_t hint,
const std::string& hstr);
- select::FieldValueNode
+ std::unique_ptr<select::FieldValueNode>
parseFieldValue(const std::string expression);
template <typename ContainsType>
@@ -1220,30 +1220,30 @@ void DocumentSelectParserTest::testUtf8()
// PARSE("testdoctype1.hstringval =~ \"H.kon\"", *_doc[_doc.size()-1], True);
}
-select::FieldValueNode
+std::unique_ptr<select::FieldValueNode>
DocumentSelectParserTest::parseFieldValue(const std::string expression) {
- return dynamic_cast<const select::FieldValueNode &>(
- *dynamic_cast<const select::Compare &>(*_parser->parse(expression)).getLeft().clone());
+ return std::unique_ptr<select::FieldValueNode>(dynamic_cast<select::FieldValueNode *>(
+ dynamic_cast<const select::Compare &>(*_parser->parse(expression)).getLeft().clone().release()));
}
void DocumentSelectParserTest::testThatSimpleFieldValuesHaveCorrectFieldName() {
CPPUNIT_ASSERT_EQUAL(
vespalib::string("headerval"),
- parseFieldValue("testdoctype1.headerval").getRealFieldName());
+ parseFieldValue("testdoctype1.headerval")->getRealFieldName());
}
void DocumentSelectParserTest::testThatComplexFieldValuesHaveCorrectFieldNames() {
CPPUNIT_ASSERT_EQUAL(
vespalib::string("headerval"),
- parseFieldValue("testdoctype1.headerval{test}").getRealFieldName());
+ parseFieldValue("testdoctype1.headerval{test}")->getRealFieldName());
CPPUNIT_ASSERT_EQUAL(
vespalib::string("headerval"),
- parseFieldValue("testdoctype1.headerval[42]").getRealFieldName());
+ parseFieldValue("testdoctype1.headerval[42]")->getRealFieldName());
CPPUNIT_ASSERT_EQUAL(
vespalib::string("headerval"),
- parseFieldValue("testdoctype1.headerval.meow.meow{test}").getRealFieldName());
+ parseFieldValue("testdoctype1.headerval.meow.meow{test}")->getRealFieldName());
}
} // document
diff --git a/document/src/vespa/document/base/fieldpath.cpp b/document/src/vespa/document/base/fieldpath.cpp
index abed9ec4816..469b3edc206 100644
--- a/document/src/vespa/document/base/fieldpath.cpp
+++ b/document/src/vespa/document/base/fieldpath.cpp
@@ -54,13 +54,13 @@ FieldPathEntry::FieldPathEntry(const Field &fieldRef) :
{ }
FieldPathEntry::FieldPathEntry(const DataType & dataType, const DataType& fillType,
- const FieldValueCP & lookupKey) :
+ FieldValue::UP lookupKey) :
_type(MAP_KEY),
_name("value"),
_field(),
_dataType(&dataType),
_lookupIndex(0),
- _lookupKey(lookupKey),
+ _lookupKey(lookupKey.release()),
_variableName(),
_fillInVal()
{
@@ -70,10 +70,15 @@ FieldPathEntry::FieldPathEntry(const DataType & dataType, const DataType& fillTy
void FieldPathEntry::setFillValue(const DataType & dataType)
{
const DataType * dt = & dataType;
- while (dt->inherits(CollectionDataType::classId) || dt->inherits(MapDataType::classId)) {
- dt = dt->inherits(CollectionDataType::classId)
- ? &static_cast<const CollectionDataType *>(dt)->getNestedType()
- : &static_cast<const MapDataType *>(dt)->getValueType();
+
+ while (true) {
+ if (dt->inherits(CollectionDataType::classId)) {
+ dt = &static_cast<const CollectionDataType *>(dt)->getNestedType();
+ } else if (dt->inherits(MapDataType::classId)) {
+ dt = &static_cast<const MapDataType *>(dt)->getValueType();
+ } else {
+ break;
+ }
}
if (dt->inherits(PrimitiveDataType::classId)) {
_fillInVal.reset(dt->createFieldValue().release());
@@ -174,8 +179,8 @@ FieldPath::FieldPath()
: _path()
{ }
-FieldPath::FieldPath(const FieldPath &) = default;
-FieldPath & FieldPath::operator=(const FieldPath &) = default;
+//FieldPath::FieldPath(const FieldPath &) = default;
+//FieldPath & FieldPath::operator=(const FieldPath &) = default;
FieldPath::~FieldPath() { }
FieldPath::iterator FieldPath::insert(iterator pos, FieldPathEntry && entry) { return _path.insert(pos, std::move(entry)); }
diff --git a/document/src/vespa/document/base/fieldpath.h b/document/src/vespa/document/base/fieldpath.h
index 5c0a3553e3b..2cb230d1388 100644
--- a/document/src/vespa/document/base/fieldpath.h
+++ b/document/src/vespa/document/base/fieldpath.h
@@ -53,7 +53,7 @@ public:
/**
Creates a field path entry for a map or wset key lookup.
*/
- FieldPathEntry(const DataType & dataType, const DataType& fillType, const FieldValueCP & lookupKey);
+ FieldPathEntry(const DataType & dataType, const DataType& fillType, std::unique_ptr<FieldValue> lookupKey);
/**
Creates a field path entry for a map key or value only traversal.
@@ -117,8 +117,8 @@ public:
typedef std::unique_ptr<FieldPath> UP;
FieldPath();
- FieldPath(const FieldPath &);
- FieldPath & operator=(const FieldPath &);
+ FieldPath(const FieldPath &) = delete;
+ FieldPath & operator=(const FieldPath &) = delete;
FieldPath(FieldPath &&) = default;
FieldPath & operator=(FieldPath &&) = default;
~FieldPath();
diff --git a/document/src/vespa/document/datatype/mapdatatype.cpp b/document/src/vespa/document/datatype/mapdatatype.cpp
index 2d77a6b3eef..ee345040a24 100644
--- a/document/src/vespa/document/datatype/mapdatatype.cpp
+++ b/document/src/vespa/document/datatype/mapdatatype.cpp
@@ -71,7 +71,7 @@ MapDataType::buildFieldPathImpl(FieldPath & path, const DataType &dataType,
} else {
FieldValue::UP fv = keyType.createFieldValue();
*fv = keyValue;
- path.insert(path.begin(), FieldPathEntry(valueType, dataType, vespalib::CloneablePtr<FieldValue>(fv.release())));
+ path.insert(path.begin(), FieldPathEntry(valueType, dataType, std::move(fv)));
}
} else if (memcmp(remainFieldName.c_str(), "key", 3) == 0) {
size_t endPos = 3;
diff --git a/document/src/vespa/document/select/valuenodes.cpp b/document/src/vespa/document/select/valuenodes.cpp
index b6c2bf551c0..39688e2fc7b 100644
--- a/document/src/vespa/document/select/valuenodes.cpp
+++ b/document/src/vespa/document/select/valuenodes.cpp
@@ -195,8 +195,8 @@ FieldValueNode::FieldValueNode(const vespalib::string& doctype,
{
}
-FieldValueNode::FieldValueNode(const FieldValueNode &) = default;
-FieldValueNode & FieldValueNode::operator = (const FieldValueNode &) = default;
+//FieldValueNode::FieldValueNode(const FieldValueNode &) = default;
+//FieldValueNode & FieldValueNode::operator = (const FieldValueNode &) = default;
FieldValueNode::~FieldValueNode() {}
vespalib::string
diff --git a/document/src/vespa/document/select/valuenodes.h b/document/src/vespa/document/select/valuenodes.h
index 104fd446aed..0464159b85f 100644
--- a/document/src/vespa/document/select/valuenodes.h
+++ b/document/src/vespa/document/select/valuenodes.h
@@ -157,8 +157,8 @@ class FieldValueNode : public ValueNode
public:
FieldValueNode(const vespalib::string& doctype, const vespalib::string& fieldExpression);
- FieldValueNode(const FieldValueNode &);
- FieldValueNode & operator = (const FieldValueNode &);
+ FieldValueNode(const FieldValueNode &) = delete;
+ FieldValueNode & operator = (const FieldValueNode &) = delete;
FieldValueNode(FieldValueNode &&) = default;
FieldValueNode & operator = (FieldValueNode &&) = default;
~FieldValueNode();