Replace deprecated Vector::Length() with Vector::size() (#5131)

- enable FLATBUFFERS_ATTRIBUTE if C++17 or higher
This commit is contained in:
Vladimir Glavnyy
2019-01-25 04:33:19 +07:00
committed by Wouter van Oortmerssen
parent 3f388ec747
commit fcacb46d01
6 changed files with 16 additions and 16 deletions

View File

@@ -119,7 +119,7 @@ bool Print<const void *>(const void *val, Type type, int indent,
break;
case BASE_TYPE_STRING: {
auto s = reinterpret_cast<const String *>(val);
if (!EscapeString(s->c_str(), s->Length(), _text, opts.allow_non_utf8,
if (!EscapeString(s->c_str(), s->size(), _text, opts.allow_non_utf8,
opts.natural_utf8)) {
return false;
}

View File

@@ -94,7 +94,7 @@ std::string MakeCamel(const std::string &in, bool first) {
void DeserializeDoc( std::vector<std::string> &doc,
const Vector<Offset<String>> *documentation) {
if (documentation == nullptr) return;
for (uoffset_t index = 0; index < documentation->Length(); index++)
for (uoffset_t index = 0; index < documentation->size(); index++)
doc.push_back(documentation->Get(index)->str());
}
@@ -2755,8 +2755,8 @@ bool StructDef::Deserialize(Parser &parser, const reflection::Object *object) {
predecl = false;
sortbysize = attributes.Lookup("original_order") == nullptr && !fixed;
std::vector<uoffset_t> indexes =
std::vector<uoffset_t>(object->fields()->Length());
for (uoffset_t i = 0; i < object->fields()->Length(); i++)
std::vector<uoffset_t>(object->fields()->size());
for (uoffset_t i = 0; i < object->fields()->size(); i++)
indexes[object->fields()->Get(i)->id()] = i;
for (size_t i = 0; i < indexes.size(); i++) {
auto field = object->fields()->Get(indexes[i]);

View File

@@ -299,13 +299,13 @@ class ResizeContext {
void SetString(const reflection::Schema &schema, const std::string &val,
const String *str, std::vector<uint8_t> *flatbuf,
const reflection::Object *root_table) {
auto delta = static_cast<int>(val.size()) - static_cast<int>(str->Length());
auto delta = static_cast<int>(val.size()) - static_cast<int>(str->size());
auto str_start = static_cast<uoffset_t>(
reinterpret_cast<const uint8_t *>(str) - vector_data(*flatbuf));
auto start = str_start + static_cast<uoffset_t>(sizeof(uoffset_t));
if (delta) {
// Clear the old string, since we don't want parts of it remaining.
memset(vector_data(*flatbuf) + start, 0, str->Length());
memset(vector_data(*flatbuf) + start, 0, str->size());
// Different size, we must expand (or contract).
ResizeContext(schema, start, delta, flatbuf, root_table);
// Set the new length.