mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 04:04:19 +00:00
Made Vector have a size() function, to make it more STL-alike.
Bug: 17316346 Change-Id: I52377b7fa51adccadc4e867d45666e683bc2c1ae Tested: on Linux.
This commit is contained in:
@@ -247,12 +247,15 @@ public:
|
||||
typedef VectorIterator<T, false> iterator;
|
||||
typedef VectorIterator<T, true> const_iterator;
|
||||
|
||||
uoffset_t Length() const { return EndianScalar(length_); }
|
||||
uoffset_t size() const { return EndianScalar(length_); }
|
||||
|
||||
// Deprecated: use size(). Here for backwards compatibility.
|
||||
uoffset_t Length() const { return size(); }
|
||||
|
||||
typedef typename IndirectHelper<T>::return_type return_type;
|
||||
|
||||
return_type Get(uoffset_t i) const {
|
||||
assert(i < Length());
|
||||
assert(i < size());
|
||||
return IndirectHelper<T>::Read(Data(), i);
|
||||
}
|
||||
|
||||
@@ -727,7 +730,7 @@ class Verifier {
|
||||
// Special case for string contents, after the above has been called.
|
||||
bool VerifyVectorOfStrings(const Vector<Offset<String>> *vec) const {
|
||||
if (vec) {
|
||||
for (uoffset_t i = 0; i < vec->Length(); i++) {
|
||||
for (uoffset_t i = 0; i < vec->size(); i++) {
|
||||
if (!Verify(vec->Get(i))) return false;
|
||||
}
|
||||
}
|
||||
@@ -737,7 +740,7 @@ class Verifier {
|
||||
// Special case for table contents, after the above has been called.
|
||||
template<typename T> bool VerifyVectorOfTables(const Vector<Offset<T>> *vec) {
|
||||
if (vec) {
|
||||
for (uoffset_t i = 0; i < vec->Length(); i++) {
|
||||
for (uoffset_t i = 0; i < vec->size(); i++) {
|
||||
if (!vec->Get(i)->Verify(*this)) return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ template<typename T> void PrintVector(const Vector<T> &v, Type type,
|
||||
std::string &text = *_text;
|
||||
text += "[";
|
||||
text += NewLine(opts);
|
||||
for (uoffset_t i = 0; i < v.Length(); i++) {
|
||||
for (uoffset_t i = 0; i < v.size(); i++) {
|
||||
if (i) {
|
||||
text += ",";
|
||||
text += NewLine(opts);
|
||||
@@ -91,7 +91,7 @@ template<typename T> void PrintVector(const Vector<T> &v, Type type,
|
||||
static void EscapeString(const String &s, std::string *_text) {
|
||||
std::string &text = *_text;
|
||||
text += "\"";
|
||||
for (uoffset_t i = 0; i < s.Length(); i++) {
|
||||
for (uoffset_t i = 0; i < s.size(); i++) {
|
||||
char c = s.Get(i);
|
||||
switch (c) {
|
||||
case '\n': text += "\\n"; break;
|
||||
|
||||
Reference in New Issue
Block a user