diff options
Diffstat (limited to 'document')
27 files changed, 66 insertions, 53 deletions
diff --git a/document/src/tests/primitivefieldvaluetest.cpp b/document/src/tests/primitivefieldvaluetest.cpp index c4cdc16c3ba..3ccb5aa714b 100644 --- a/document/src/tests/primitivefieldvaluetest.cpp +++ b/document/src/tests/primitivefieldvaluetest.cpp @@ -195,7 +195,7 @@ void deserialize(const ByteBuffer &buffer, T &value) { CPPUNIT_ASSERT_EQUAL(size_t(3), value2.getValueRef().size()); // Zero termination - CPPUNIT_ASSERT(*(value2.getValueRef().c_str() + value2.getValueRef().size()) == '\0'); + CPPUNIT_ASSERT(*(value2.getValueRef().data() + value2.getValueRef().size()) == '\0'); } } @@ -226,7 +226,7 @@ PrimitiveFieldValueTest::testRaw() value.toXml(" ")); value.setValue("grmpf", 4); - CPPUNIT_ASSERT(strncmp("grmpf", value.getValueRef().c_str(), + CPPUNIT_ASSERT(strncmp("grmpf", value.getValueRef().data(), value.getValueRef().size()) == 0); } diff --git a/document/src/vespa/document/base/documentid.cpp b/document/src/vespa/document/base/documentid.cpp index d2eae01922d..c3ba8fea29d 100644 --- a/document/src/vespa/document/base/documentid.cpp +++ b/document/src/vespa/document/base/documentid.cpp @@ -18,7 +18,7 @@ DocumentId::DocumentId() DocumentId::DocumentId(vespalib::stringref id) : Printable(), _globalId(), - _id(IdString::createIdString(id.c_str(), id.size()).release()) + _id(IdString::createIdString(id.data(), id.size()).release()) { } diff --git a/document/src/vespa/document/base/documentid.h b/document/src/vespa/document/base/documentid.h index 4611de73741..a4b01cdad82 100644 --- a/document/src/vespa/document/base/documentid.h +++ b/document/src/vespa/document/base/documentid.h @@ -41,10 +41,15 @@ public: * Parse the given document identifier given as string, and create an * identifier object from it. * + * Precondition: `id` MUST be null-terminated. + * * @throws IdParseException If the identifier given is invalid. */ explicit DocumentId(vespalib::stringref id); + /** + * Precondition: `id` MUST be null-terminated. + */ void set(vespalib::stringref id); /** diff --git a/document/src/vespa/document/base/field.cpp b/document/src/vespa/document/base/field.cpp index 5a3fe6c1935..7ce766c47c6 100644 --- a/document/src/vespa/document/base/field.cpp +++ b/document/src/vespa/document/base/field.cpp @@ -78,7 +78,7 @@ Field::calculateIdV7() ost << getName(); ost << _dataType->getId(); - int newId = vespalib::BobHash::hash(ost.str().c_str(), ost.str().length(), 0); + int newId = vespalib::BobHash::hash(ost.str().data(), ost.str().length(), 0); // Highest bit is reserved to tell 7-bit id's from 31-bit ones if (newId < 0) newId = -newId; validateId(newId); @@ -91,7 +91,7 @@ Field::validateId(int newId) { throw vespalib::IllegalArgumentException(vespalib::make_string( "Attempt to set the id of %s to %d failed, values from " "100 to 127 are reserved for internal use", - getName().c_str(), newId)); + vespalib::string(getName()).c_str(), newId)); } if ((newId & 0x80000000) != 0) // Highest bit must not be set @@ -99,7 +99,7 @@ Field::validateId(int newId) { throw vespalib::IllegalArgumentException(vespalib::make_string( "Attempt to set the id of %s to %d" " failed, negative id values are illegal", - getName().c_str(), newId)); + vespalib::string(getName()).c_str(), newId)); } } diff --git a/document/src/vespa/document/base/fieldpath.cpp b/document/src/vespa/document/base/fieldpath.cpp index 6625f9ae2a5..d1603ca5c09 100644 --- a/document/src/vespa/document/base/fieldpath.cpp +++ b/document/src/vespa/document/base/fieldpath.cpp @@ -139,7 +139,7 @@ FieldPathEntry::visitMembers(vespalib::ObjectVisitor &visitor) const vespalib::string FieldPathEntry::parseKey(vespalib::stringref & key) { vespalib::string v; - const char *c = key.c_str(); + const char *c = key.data(); const char *e = c + key.size(); for(;(c < e) && isspace(c[0]); c++); if ((c < e) && (c[0] == '{')) { @@ -156,7 +156,8 @@ vespalib::string FieldPathEntry::parseKey(vespalib::stringref & key) if ((c < e) && (c[0] == '"')) { c++; } else { - throw IllegalArgumentException(make_string("Escaped key '%s' is incomplete. No matching '\"'", key.c_str()), VESPA_STRLOC); + throw IllegalArgumentException(make_string("Escaped key '%s' is incomplete. No matching '\"'", + vespalib::string(key).c_str()), VESPA_STRLOC); } } else { const char * start = c; @@ -169,10 +170,12 @@ vespalib::string FieldPathEntry::parseKey(vespalib::stringref & key) if ((c < e) && (c[0] == '}')) { key = c+1; } else { - throw IllegalArgumentException(make_string("Key '%s' is incomplete. No matching '}'", key.c_str()), VESPA_STRLOC); + throw IllegalArgumentException(make_string("Key '%s' is incomplete. No matching '}'", + vespalib::string(key).c_str()), VESPA_STRLOC); } } else { - throw IllegalArgumentException(make_string("key '%s' does not start with '{'", key.c_str()), VESPA_STRLOC); + throw IllegalArgumentException(make_string("key '%s' does not start with '{'", + vespalib::string(key).c_str()), VESPA_STRLOC); } return v; } diff --git a/document/src/vespa/document/base/idstring.cpp b/document/src/vespa/document/base/idstring.cpp index 9c64ac6a648..175fb653542 100644 --- a/document/src/vespa/document/base/idstring.cpp +++ b/document/src/vespa/document/base/idstring.cpp @@ -84,9 +84,9 @@ void reportTooShortDocId(const char * id, size_t sz) uint64_t getAsNumber(const stringref & s, const char* part) { char* errPos = NULL; - uint64_t value = strtoull(s.c_str(), &errPos, 10); + uint64_t value = strtoull(s.data(), &errPos, 10); - if (s.c_str() + s.size() != errPos) { + if (s.data() + s.size() != errPos) { reportError(s, part); } return value; @@ -96,9 +96,9 @@ void getOrderDocBits(const stringref& scheme, uint16_t & widthBits, uint16_t & divisionBits) { const char* parenPos = reinterpret_cast<const char*>( - memchr(scheme.c_str(), '(', scheme.size())); + memchr(scheme.data(), '(', scheme.size())); const char* endParenPos = reinterpret_cast<const char*>( - memchr(scheme.c_str(), ')', scheme.size())); + memchr(scheme.data(), ')', scheme.size())); if (parenPos == NULL || endParenPos == NULL || endParenPos < parenPos) { reportError(scheme); @@ -198,13 +198,13 @@ IdString::Offsets::Offsets(uint32_t maxComponents, uint32_t namespaceOffset, con { _offsets[0] = namespaceOffset; size_t index(1); - const char * s(id.c_str() + namespaceOffset); - const char * e(id.c_str() + id.size()); + const char * s(id.data() + namespaceOffset); + const char * e(id.data() + id.size()); for(s=fmemchr(s, e); (s != NULL) && (index < maxComponents); s = fmemchr(s+1, e)) { - _offsets[index++] = s - id.c_str() + 1; + _offsets[index++] = s - id.data() + 1; } _numComponents = index; for (;index < VESPA_NELEMS(_offsets); index++) { @@ -276,14 +276,14 @@ union LocationUnion { IdString::LocationType makeLocation(const stringref &s) { LocationUnion location; - fastc_md5sum(reinterpret_cast<const unsigned char*>(s.c_str()), s.size(), location._key); + fastc_md5sum(reinterpret_cast<const unsigned char*>(s.data()), s.size(), location._key); return location._location[0]; } uint64_t parseNumber(const stringref &number) { char* errPos = NULL; errno = 0; - uint64_t n = strtoul(number.c_str(), &errPos, 10); + uint64_t n = strtoul(number.data(), &errPos, 10); if (*errPos) { throw IdParseException( "'n'-value must be a 64-bit number. It was " + @@ -396,7 +396,7 @@ GroupDocIdString::locationFromGroupName(vespalib::stringref name) } OrderDocIdString::OrderDocIdString(const stringref & rawId) : - IdString(4, static_cast<const char *>(memchr(rawId.c_str(), ':', rawId.size())) - rawId.c_str() + 1, rawId), + IdString(4, static_cast<const char *>(memchr(rawId.data(), ':', rawId.size())) - rawId.data() + 1, rawId), _widthBits(0), _divisionBits(0), _ordering(getAsNumber(rawId.substr(offset(2), offset(3) - offset(2) - 1), "ordering")) diff --git a/document/src/vespa/document/base/idstring.h b/document/src/vespa/document/base/idstring.h index 05554a68ba3..b1a14cfec94 100644 --- a/document/src/vespa/document/base/idstring.h +++ b/document/src/vespa/document/base/idstring.h @@ -24,7 +24,7 @@ public: static const vespalib::string & getTypeName(Type t); /** @throws document::IdParseException If parsing of id scheme failed. */ - static IdString::UP createIdString(const vespalib::stringref & id) { return createIdString(id.c_str(), id.size()); } + static IdString::UP createIdString(const vespalib::stringref & id) { return createIdString(id.data(), id.size()); } static IdString::UP createIdString(const char *id, size_t sz); ~IdString() {} diff --git a/document/src/vespa/document/datatype/arraydatatype.cpp b/document/src/vespa/document/datatype/arraydatatype.cpp index 5ced6053b05..b49599ac620 100644 --- a/document/src/vespa/document/datatype/arraydatatype.cpp +++ b/document/src/vespa/document/datatype/arraydatatype.cpp @@ -60,7 +60,8 @@ ArrayDataType::onBuildFieldPath(FieldPath & path, const vespalib::stringref & re if (remainFieldName[1] == '$') { path.insert(path.begin(), std::make_unique<FieldPathEntry>(getNestedType(), remainFieldName.substr(2, endPos - 2))); } else { - path.insert(path.begin(), std::make_unique<FieldPathEntry>(getNestedType(), atoi(remainFieldName.substr(1, endPos - 1).c_str()))); + // FIXME C++17 range-safe from_chars() instead of atoi() + path.insert(path.begin(), std::make_unique<FieldPathEntry>(getNestedType(), atoi(remainFieldName.substr(1, endPos - 1).data()))); } } } else { diff --git a/document/src/vespa/document/datatype/datatype.h b/document/src/vespa/document/datatype/datatype.h index 247d72db665..5857157c218 100644 --- a/document/src/vespa/document/datatype/datatype.h +++ b/document/src/vespa/document/datatype/datatype.h @@ -125,6 +125,7 @@ public: * This takes a . separated fieldname and gives you back the path of * fields you have to apply to get to your leaf. * @param remainFieldName. The remaining part of the fieldname that you want the path of. + * MUST be null-terminated. * @return pointer to field path or null if an error occured */ void buildFieldPath(FieldPath & fieldPath, const vespalib::stringref & remainFieldName) const; diff --git a/document/src/vespa/document/datatype/documenttype.cpp b/document/src/vespa/document/datatype/documenttype.cpp index c7eaf42b50b..31485aa42b6 100644 --- a/document/src/vespa/document/datatype/documenttype.cpp +++ b/document/src/vespa/document/datatype/documenttype.cpp @@ -96,7 +96,7 @@ DocumentType::addField(const Field& field) } else if (!_ownedFields.get()) { throw vespalib::IllegalStateException(make_string( "Cannot add field %s to a DocumentType that does not " - "own its fields.", field.getName().c_str()), VESPA_STRLOC); + "own its fields.", vespalib::string(field.getName()).c_str()), VESPA_STRLOC); } _ownedFields->addField(field); } diff --git a/document/src/vespa/document/datatype/mapdatatype.cpp b/document/src/vespa/document/datatype/mapdatatype.cpp index 5c940b1af6e..4598b96d970 100644 --- a/document/src/vespa/document/datatype/mapdatatype.cpp +++ b/document/src/vespa/document/datatype/mapdatatype.cpp @@ -73,7 +73,7 @@ MapDataType::buildFieldPathImpl(FieldPath & path, const DataType &dataType, *fv = keyValue; path.insert(path.begin(), std::make_unique<FieldPathEntry>(valueType, dataType, std::move(fv))); } - } else if (memcmp(remainFieldName.c_str(), "key", 3) == 0) { + } else if (memcmp(remainFieldName.data(), "key", 3) == 0) { size_t endPos = 3; if (remainFieldName[endPos] == '.') { endPos++; @@ -82,7 +82,7 @@ MapDataType::buildFieldPathImpl(FieldPath & path, const DataType &dataType, keyType.buildFieldPath(path, remainFieldName.substr(endPos)); path.insert(path.begin(), std::make_unique<FieldPathEntry>(dataType, keyType, valueType, true, false)); - } else if (memcmp(remainFieldName.c_str(), "value", 5) == 0) { + } else if (memcmp(remainFieldName.data(), "value", 5) == 0) { size_t endPos = 5; if (remainFieldName[endPos] == '.') { endPos++; diff --git a/document/src/vespa/document/datatype/referencedatatype.cpp b/document/src/vespa/document/datatype/referencedatatype.cpp index d02793edd3a..8f0c6a0a4c3 100644 --- a/document/src/vespa/document/datatype/referencedatatype.cpp +++ b/document/src/vespa/document/datatype/referencedatatype.cpp @@ -36,7 +36,7 @@ ReferenceDataType* ReferenceDataType::clone() const { void ReferenceDataType::onBuildFieldPath(FieldPath &, const vespalib::stringref& remainingFieldName) const { if ( ! remainingFieldName.empty() ) { throw IllegalArgumentException(make_string("Reference data type does not support further field recursion: '%s'", - remainingFieldName.c_str()), VESPA_STRLOC); + vespalib::string(remainingFieldName).c_str()), VESPA_STRLOC); } } diff --git a/document/src/vespa/document/datatype/structdatatype.cpp b/document/src/vespa/document/datatype/structdatatype.cpp index 0abde69c2a1..1303f16c43b 100644 --- a/document/src/vespa/document/datatype/structdatatype.cpp +++ b/document/src/vespa/document/datatype/structdatatype.cpp @@ -83,7 +83,7 @@ StructDataType::addField(const Field& field) vespalib::string error = containsConflictingField(field); if (error != "") { throw IllegalArgumentException(make_string("Failed to add field '%s' to struct '%s': %s", - field.getName().c_str(), getName().c_str(), + vespalib::string(field.getName()).c_str(), getName().c_str(), error.c_str()), VESPA_STRLOC); } if (hasField(field.getName())) { diff --git a/document/src/vespa/document/datatype/structureddatatype.cpp b/document/src/vespa/document/datatype/structureddatatype.cpp index 41c0cd6f4e7..604b4cad045 100644 --- a/document/src/vespa/document/datatype/structureddatatype.cpp +++ b/document/src/vespa/document/datatype/structureddatatype.cpp @@ -80,7 +80,8 @@ StructuredDataType::onBuildFieldPath(FieldPath & path, const vespalib::stringref path.insert(path.begin(), std::make_unique<FieldPathEntry>(fp)); } else { throw FieldNotFoundException(currFieldName, make_string("Invalid field path '%s', no field named '%s'", - remainFieldName.c_str(), currFieldName.c_str())); + vespalib::string(remainFieldName).c_str(), + vespalib::string(currFieldName).c_str())); } } diff --git a/document/src/vespa/document/fieldvalue/arrayfieldvalue.cpp b/document/src/vespa/document/fieldvalue/arrayfieldvalue.cpp index f3239553fa9..a09d5a25dd2 100644 --- a/document/src/vespa/document/fieldvalue/arrayfieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/arrayfieldvalue.cpp @@ -186,9 +186,6 @@ ArrayFieldValue::iterateSubset(int startPos, int endPos, { fieldvalue::ModificationStatus retVal = ModificationStatus::NOT_MODIFIED; - LOG(spam, "iterateSubset(start=%d, end=%d, variable='%s')", - startPos, endPos, variable.c_str()); - std::vector<int> indicesToRemove; for (int i = startPos; i <= endPos && i < static_cast<int>(_array->size()); ++i) { diff --git a/document/src/vespa/document/fieldvalue/document.cpp b/document/src/vespa/document/fieldvalue/document.cpp index 47366b388a9..51ba135b826 100644 --- a/document/src/vespa/document/fieldvalue/document.cpp +++ b/document/src/vespa/document/fieldvalue/document.cpp @@ -32,12 +32,13 @@ void documentTypeError(const vespalib::stringref & name) __attribute__((noinline void throwTypeMismatch(vespalib::stringref type, vespalib::stringref docidType) __attribute__((noinline)); void documentTypeError(const vespalib::stringref & name) { - throw IllegalArgumentException(make_string("Cannot generate a document with non-document type %s.", name.c_str()), VESPA_STRLOC); + throw IllegalArgumentException(make_string("Cannot generate a document with non-document type %s.", + vespalib::string(name).c_str()), VESPA_STRLOC); } void throwTypeMismatch(vespalib::stringref type, vespalib::stringref docidType) { throw IllegalArgumentException(make_string("Trying to create a document with type %s that don't match the id (type %s).", - type.c_str(), docidType.c_str()), + vespalib::string(type).c_str(), vespalib::string(docidType).c_str()), VESPA_STRLOC); } diff --git a/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp b/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp index 747c789c6cd..5614330a495 100644 --- a/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp @@ -79,7 +79,7 @@ LiteralFieldValueB::fastCompare(const FieldValue& other) const void LiteralFieldValueB::printXml(XmlOutputStream& out) const { - out << XmlContentWrapper(_value.c_str(), _value.size()); + out << XmlContentWrapper(_value.data(), _value.size()); } void @@ -106,7 +106,7 @@ LiteralFieldValueB::getAsString() const std::pair<const char*, size_t> LiteralFieldValueB::getAsRaw() const { - return std::make_pair(_value.c_str(), _value.size()); + return std::make_pair(_value.data(), _value.size()); } void diff --git a/document/src/vespa/document/fieldvalue/literalfieldvalue.h b/document/src/vespa/document/fieldvalue/literalfieldvalue.h index d72e734b6a6..2f9050eb13c 100644 --- a/document/src/vespa/document/fieldvalue/literalfieldvalue.h +++ b/document/src/vespa/document/fieldvalue/literalfieldvalue.h @@ -54,7 +54,7 @@ public: _value = _backing; _altered = true; } - size_t hash() const override final { return vespalib::hashValue(_value.c_str()); } + size_t hash() const override final { return vespalib::hashValue(_value.data(), _value.size()); } void setValue(const char* val, size_t size) { setValue(stringref(val, size)); } int compare(const FieldValue& other) const override; @@ -76,7 +76,7 @@ public: protected: void syncBacking() const __attribute__((noinline)); void sync() const { - if (__builtin_expect(_backing.c_str() != _value.c_str(), false)) { + if (__builtin_expect(_backing.data() != _value.data(), false)) { syncBacking(); } } diff --git a/document/src/vespa/document/fieldvalue/numericfieldvalue.hpp b/document/src/vespa/document/fieldvalue/numericfieldvalue.hpp index 881cdb4a7e3..c3ef6781706 100644 --- a/document/src/vespa/document/fieldvalue/numericfieldvalue.hpp +++ b/document/src/vespa/document/fieldvalue/numericfieldvalue.hpp @@ -84,9 +84,10 @@ NumericFieldValue<Number>::operator=(const vespalib::stringref & value) // so detect these in front. if ((value.size() > 2) && (value[0] == '0') && ((value[1] | 0x20) == 'x')) { char* endp; - // It is safe to assume that all hex numbers can be contained within - // 64 bit unsigned value. - unsigned long long val = strtoull(value.c_str(), &endp, 16); + // It is safe to assume that all hex numbers can be contained within + // 64 bit unsigned value. + // FIXME C++17 range-safe from_chars() instead of strtoull() + unsigned long long val = strtoull(value.data(), &endp, 16); if (*endp == '\0') { // Allow numbers to be specified in range max signed to max // unsigned. These become negative numbers. diff --git a/document/src/vespa/document/fieldvalue/rawfieldvalue.cpp b/document/src/vespa/document/fieldvalue/rawfieldvalue.cpp index 6e415471cd0..5d4abe658c1 100644 --- a/document/src/vespa/document/fieldvalue/rawfieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/rawfieldvalue.cpp @@ -15,13 +15,13 @@ void RawFieldValue::printXml(XmlOutputStream& out) const { out << XmlBase64Content() - << XmlContentWrapper(_value.c_str(), _value.size()); + << XmlContentWrapper(_value.data(), _value.size()); } void RawFieldValue::print(std::ostream& out, bool, const std::string&) const { - StringUtil::printAsHex(out, _value.c_str(), _value.size()); + StringUtil::printAsHex(out, _value.data(), _value.size()); } } // document diff --git a/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp b/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp index 92d4e4788fb..c193b0919ea 100644 --- a/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp @@ -71,7 +71,7 @@ void StructuredFieldValue::setFieldValue(const Field & field, const FieldValue & throw IllegalArgumentException( "Cannot assign value of type " + value.getDataType()->toString() + "with value : '" + value.toString() - + "' to field " + field.getName().c_str() + " of type " + + "' to field " + field.getName() + " of type " + field.getDataType().toString() + ".", VESPA_STRLOC); } setFieldValue(field, FieldValue::UP(value.clone())); diff --git a/document/src/vespa/document/select/simpleparser.cpp b/document/src/vespa/document/select/simpleparser.cpp index 462243f342c..349c1c17362 100644 --- a/document/src/vespa/document/select/simpleparser.cpp +++ b/document/src/vespa/document/select/simpleparser.cpp @@ -24,7 +24,7 @@ bool icmp(char c, char l) bool IdSpecParser::parse(const vespalib::stringref & s) { bool retval(false); - size_t pos(eatWhite(s.c_str(), s.size())); + size_t pos(eatWhite(s.data(), s.size())); if (pos+1 < s.size()) { if (icmp(s[pos], 'i') && icmp(s[pos+1],'d')) { pos += 2; @@ -77,7 +77,7 @@ bool IdSpecParser::parse(const vespalib::stringref & s) bool OperatorParser::parse(const vespalib::stringref & s) { bool retval(false); - size_t pos(eatWhite(s.c_str(), s.size())); + size_t pos(eatWhite(s.data(), s.size())); if (pos+1 < s.size()) { retval = true; if (s[pos] == '=') { @@ -122,7 +122,7 @@ bool StringParser::parse(const vespalib::stringref & s) { bool retval(false); setRemaining(s); - size_t pos(eatWhite(s.c_str(), s.size())); + size_t pos(eatWhite(s.data(), s.size())); if (pos + 1 < s.size()) { if (s[pos++] == '"') { vespalib::string str; @@ -146,7 +146,7 @@ bool StringParser::parse(const vespalib::stringref & s) bool IntegerParser::parse(const vespalib::stringref & s) { bool retval(false); - size_t pos(eatWhite(s.c_str(), s.size())); + size_t pos(eatWhite(s.data(), s.size())); if (pos < s.size()) { char * err(NULL); errno = 0; diff --git a/document/src/vespa/document/serialization/vespadocumentserializer.cpp b/document/src/vespa/document/serialization/vespadocumentserializer.cpp index 08fddbaad41..a309fdd3500 100644 --- a/document/src/vespa/document/serialization/vespadocumentserializer.cpp +++ b/document/src/vespa/document/serialization/vespadocumentserializer.cpp @@ -513,7 +513,10 @@ void VespaDocumentSerializer::write(const MapValueUpdate &value) namespace { -void writeStringWithZeroTermination(nbostream & os, stringref s) +// We must ensure that string passed is always zero-terminated, so take in +// string instead of stringref. No extra allocs; function only ever called with +// string arguments. +void writeStringWithZeroTermination(nbostream & os, const vespalib::string& s) { uint32_t sz(s.size() + 1); os << sz; diff --git a/document/src/vespa/document/update/addvalueupdate.cpp b/document/src/vespa/document/update/addvalueupdate.cpp index 051ffcf8b2a..e5a99b49a9e 100644 --- a/document/src/vespa/document/update/addvalueupdate.cpp +++ b/document/src/vespa/document/update/addvalueupdate.cpp @@ -43,7 +43,7 @@ AddValueUpdate::checkCompatibility(const Field& field) const const CollectionDataType& type(static_cast<const CollectionDataType&>(field.getDataType())); if (!type.getNestedType().isValueType(*_value)) { throw IllegalArgumentException("Cannot add value of type " + _value->getDataType()->toString() + - " to field " + field.getName().c_str() + " of container type " + + " to field " + field.getName() + " of container type " + field.getDataType().toString(), VESPA_STRLOC); } } else { diff --git a/document/src/vespa/document/update/arithmeticvalueupdate.cpp b/document/src/vespa/document/update/arithmeticvalueupdate.cpp index 9ae7dd17a52..7363899d5cf 100644 --- a/document/src/vespa/document/update/arithmeticvalueupdate.cpp +++ b/document/src/vespa/document/update/arithmeticvalueupdate.cpp @@ -35,7 +35,7 @@ ArithmeticValueUpdate::checkCompatibility(const Field& field) const if ( ! field.getDataType().inherits(NumericDataType::classId)) { throw IllegalArgumentException(vespalib::make_string( "Can not perform arithmetic update on non-numeric field '%s'.", - field.getName().c_str()), VESPA_STRLOC); + vespalib::string(field.getName()).c_str()), VESPA_STRLOC); } } diff --git a/document/src/vespa/document/update/mapvalueupdate.cpp b/document/src/vespa/document/update/mapvalueupdate.cpp index 3fc9c8cbea5..cc0aec3618a 100644 --- a/document/src/vespa/document/update/mapvalueupdate.cpp +++ b/document/src/vespa/document/update/mapvalueupdate.cpp @@ -46,7 +46,7 @@ MapValueUpdate::checkCompatibility(const Field& field) const if (_key->getClass().id() != IntFieldValue::classId) { throw IllegalArgumentException(vespalib::make_string( "Key for field '%s' is of wrong type (expected '%s', was '%s').", - field.getName().c_str(), DataType::INT->toString().c_str(), + vespalib::string(field.getName()).c_str(), DataType::INT->toString().c_str(), _key->getDataType()->toString().c_str()), VESPA_STRLOC); } } else if (field.getDataType().getClass().id() == WeightedSetDataType::classId) { @@ -54,7 +54,7 @@ MapValueUpdate::checkCompatibility(const Field& field) const if (!type.getNestedType().isValueType(*_key)) { throw IllegalArgumentException(vespalib::make_string( "Key for field '%s' is of wrong type (expected '%s', was '%s').", - field.getName().c_str(), DataType::INT->toString().c_str(), + vespalib::string(field.getName()).c_str(), DataType::INT->toString().c_str(), _key->getDataType()->toString().c_str()), VESPA_STRLOC); } } else { diff --git a/document/src/vespa/document/update/removevalueupdate.cpp b/document/src/vespa/document/update/removevalueupdate.cpp index 28c69652a0e..fdbee3cb394 100644 --- a/document/src/vespa/document/update/removevalueupdate.cpp +++ b/document/src/vespa/document/update/removevalueupdate.cpp @@ -44,7 +44,7 @@ RemoveValueUpdate::checkCompatibility(const Field& field) const throw IllegalArgumentException( "Cannot remove value of type " + _key->getDataType()->toString() + " from field " - + field.getName().c_str() + " of container type " + + field.getName() + " of container type " + field.getDataType().toString(), VESPA_STRLOC); } } else { |