TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
google::protobuf::internal::RepeatedPtrFieldBase Class Reference

#include <repeated_field.h>

Protected Member Functions

 RepeatedPtrFieldBase ()
 
template<typename TypeHandler >
void Destroy ()
 
bool empty () const
 
int size () const
 
template<typename TypeHandler >
const TypeHandler::TypeGet (int index) const
 
template<typename TypeHandler >
TypeHandler::TypeMutable (int index)
 
template<typename TypeHandler >
TypeHandler::TypeAdd ()
 
template<typename TypeHandler >
void RemoveLast ()
 
template<typename TypeHandler >
void Clear ()
 
template<typename TypeHandler >
void MergeFrom (const RepeatedPtrFieldBase &other)
 
template<typename TypeHandler >
void CopyFrom (const RepeatedPtrFieldBase &other)
 
void CloseGap (int start, int num)
 
void Reserve (int new_size)
 
int Capacity () const
 
void *constraw_data () const
 
void ** raw_mutable_data () const
 
template<typename TypeHandler >
TypeHandler::Type ** mutable_data ()
 
template<typename TypeHandler >
const TypeHandler::Type *constdata () const
 
void Swap (RepeatedPtrFieldBase *other)
 
void SwapElements (int index1, int index2)
 
template<typename TypeHandler >
int SpaceUsedExcludingSelf () const
 
template<typename TypeHandler >
TypeHandler::TypeAddFromCleared ()
 
template<typename TypeHandler >
void AddAllocated (typename TypeHandler::Type *value)
 
template<typename TypeHandler >
TypeHandler::TypeReleaseLast ()
 
int ClearedCount () const
 
template<typename TypeHandler >
void AddCleared (typename TypeHandler::Type *value)
 
template<typename TypeHandler >
TypeHandler::TypeReleaseCleared ()
 

Private Member Functions

 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS (RepeatedPtrFieldBase)
 

Static Private Member Functions

template<typename TypeHandler >
static TypeHandler::Typecast (void *element)
 
template<typename TypeHandler >
static const TypeHandler::Typecast (const void *element)
 

Private Attributes

void ** elements_
 
int current_size_
 
int allocated_size_
 
int total_size_
 

Static Private Attributes

static const int kInitialSize = 0
 

Friends

class GeneratedMessageReflection
 
class ExtensionSet
 

Constructor & Destructor Documentation

google::protobuf::internal::RepeatedPtrFieldBase::RepeatedPtrFieldBase ( )
inlineprotected
860  : elements_(NULL),
861  current_size_(0),
862  allocated_size_(0),
864 }
int total_size_
Definition: repeated_field.h:344
arena_t NULL
Definition: jemalloc_internal.h:624
void ** elements_
Definition: repeated_field.h:341
int current_size_
Definition: repeated_field.h:342
static const int kInitialSize
Definition: repeated_field.h:339
int allocated_size_
Definition: repeated_field.h:343

Member Function Documentation

template<typename TypeHandler >
TypeHandler::Type * google::protobuf::internal::RepeatedPtrFieldBase::Add ( )
inlineprotected
900  {
902  return cast<TypeHandler>(elements_[current_size_++]);
903  }
905  typename TypeHandler::Type* result = TypeHandler::New();
906  ++allocated_size_;
907  elements_[current_size_++] = result;
908  return result;
909 }
int total_size_
Definition: repeated_field.h:344
void ** elements_
Definition: repeated_field.h:341
int current_size_
Definition: repeated_field.h:342
int allocated_size_
Definition: repeated_field.h:343
Type
Type of JSON value.
Definition: rapidjson.h:642

+ Here is the call graph for this function:

template<typename TypeHandler >
void google::protobuf::internal::RepeatedPtrFieldBase::AddAllocated ( typename TypeHandler::Type value)
protected
994  {
995  // Make room for the new pointer.
996  if (current_size_ == total_size_) {
997  // The array is completely full with no cleared objects, so grow it.
998  Reserve(total_size_ + 1);
999  ++allocated_size_;
1000  } else if (allocated_size_ == total_size_) {
1001  // There is no more space in the pointer array because it contains some
1002  // cleared objects awaiting reuse. We don't want to grow the array in this
1003  // case because otherwise a loop calling AddAllocated() followed by Clear()
1004  // would leak memory.
1005  TypeHandler::Delete(cast<TypeHandler>(elements_[current_size_]));
1006  } else if (current_size_ < allocated_size_) {
1007  // We have some cleared objects. We don't care about their order, so we
1008  // can just move the first one to the end to make space.
1010  ++allocated_size_;
1011  } else {
1012  // There are no cleared objects.
1013  ++allocated_size_;
1014  }
1015 
1017 }
int total_size_
Definition: repeated_field.h:344
void ** elements_
Definition: repeated_field.h:341
int current_size_
Definition: repeated_field.h:342
int allocated_size_
Definition: repeated_field.h:343
const FieldDescriptor value
Definition: descriptor.h:1522

+ Here is the call graph for this function:

template<typename TypeHandler >
void google::protobuf::internal::RepeatedPtrFieldBase::AddCleared ( typename TypeHandler::Type value)
inlineprotected
1039  {
1042 }
int total_size_
Definition: repeated_field.h:344
void ** elements_
Definition: repeated_field.h:341
int allocated_size_
Definition: repeated_field.h:343
const FieldDescriptor value
Definition: descriptor.h:1522

+ Here is the call graph for this function:

template<typename TypeHandler >
TypeHandler::Type * google::protobuf::internal::RepeatedPtrFieldBase::AddFromCleared ( )
inlineprotected
984  {
986  return cast<TypeHandler>(elements_[current_size_++]);
987  } else {
988  return NULL;
989  }
990 }
arena_t NULL
Definition: jemalloc_internal.h:624
void ** elements_
Definition: repeated_field.h:341
int current_size_
Definition: repeated_field.h:342
int allocated_size_
Definition: repeated_field.h:343
int google::protobuf::internal::RepeatedPtrFieldBase::Capacity ( ) const
inlineprotected
941  {
942  return total_size_;
943 }
int total_size_
Definition: repeated_field.h:344
template<typename TypeHandler >
static TypeHandler::Type* google::protobuf::internal::RepeatedPtrFieldBase::cast ( void *  element)
inlinestaticprivate
347  {
348  return reinterpret_cast<typename TypeHandler::Type*>(element);
349  }
Type
Type of JSON value.
Definition: rapidjson.h:642
template<typename TypeHandler >
static const TypeHandler::Type* google::protobuf::internal::RepeatedPtrFieldBase::cast ( const void *  element)
inlinestaticprivate
351  {
352  return reinterpret_cast<const typename TypeHandler::Type*>(element);
353  }
Type
Type of JSON value.
Definition: rapidjson.h:642
template<typename TypeHandler >
void google::protobuf::internal::RepeatedPtrFieldBase::Clear ( )
protected
918  {
919  for (int i = 0; i < current_size_; i++) {
920  TypeHandler::Clear(cast<TypeHandler>(elements_[i]));
921  }
922  current_size_ = 0;
923 }
void ** elements_
Definition: repeated_field.h:341
int current_size_
Definition: repeated_field.h:342
int google::protobuf::internal::RepeatedPtrFieldBase::ClearedCount ( ) const
inlineprotected
1033  {
1034  return allocated_size_ - current_size_;
1035 }
int current_size_
Definition: repeated_field.h:342
int allocated_size_
Definition: repeated_field.h:343
void google::protobuf::internal::RepeatedPtrFieldBase::CloseGap ( int  start,
int  num 
)
inlineprotected
292  {
293  // Close up a gap of "num" elements starting at offset "start".
294  for (int i = start + num; i < allocated_size_; ++i)
295  elements_[i - num] = elements_[i];
296  current_size_ -= num;
297  allocated_size_ -= num;
298  }
void ** elements_
Definition: repeated_field.h:341
int current_size_
Definition: repeated_field.h:342
int allocated_size_
Definition: repeated_field.h:343
template<typename TypeHandler >
void google::protobuf::internal::RepeatedPtrFieldBase::CopyFrom ( const RepeatedPtrFieldBase other)
inlineprotected
935  {
936  if (&other == this) return;
937  RepeatedPtrFieldBase::Clear<TypeHandler>();
938  RepeatedPtrFieldBase::MergeFrom<TypeHandler>(other);
939 }
template<typename TypeHandler >
const TypeHandler::Type *const * google::protobuf::internal::RepeatedPtrFieldBase::data ( ) const
inlineprotected
962  {
963  // TODO(kenton): Breaks C++ aliasing rules. We should probably remove this
964  // method entirely.
965  return reinterpret_cast<const typename TypeHandler::Type* const*>(elements_);
966 }
void ** elements_
Definition: repeated_field.h:341
#define const
Definition: zconf.h:217
Type
Type of JSON value.
Definition: rapidjson.h:642
template<typename TypeHandler >
void google::protobuf::internal::RepeatedPtrFieldBase::Destroy ( )
protected
867  {
868  for (int i = 0; i < allocated_size_; i++) {
869  TypeHandler::Delete(cast<TypeHandler>(elements_[i]));
870  }
871  delete [] elements_;
872 }
void ** elements_
Definition: repeated_field.h:341
int allocated_size_
Definition: repeated_field.h:343
bool google::protobuf::internal::RepeatedPtrFieldBase::empty ( ) const
inlineprotected
874  {
875  return current_size_ == 0;
876 }
int current_size_
Definition: repeated_field.h:342
template<typename TypeHandler >
const TypeHandler::Type & google::protobuf::internal::RepeatedPtrFieldBase::Get ( int  index) const
inlineprotected
884  {
885  GOOGLE_DCHECK_GE(index, 0);
886  GOOGLE_DCHECK_LT(index, size());
887  return *cast<TypeHandler>(elements_[index]);
888 }
void ** elements_
Definition: repeated_field.h:341
#define GOOGLE_DCHECK_GE
Definition: common.h:758
#define GOOGLE_DCHECK_LT
Definition: common.h:755
int size() const
Definition: repeated_field.h:878

+ Here is the call graph for this function:

google::protobuf::internal::RepeatedPtrFieldBase::GOOGLE_DISALLOW_EVIL_CONSTRUCTORS ( RepeatedPtrFieldBase  )
private
template<typename TypeHandler >
void google::protobuf::internal::RepeatedPtrFieldBase::MergeFrom ( const RepeatedPtrFieldBase other)
inlineprotected
926  {
927  GOOGLE_CHECK_NE(&other, this);
928  Reserve(current_size_ + other.current_size_);
929  for (int i = 0; i < other.current_size_; i++) {
930  TypeHandler::Merge(other.template Get<TypeHandler>(i), Add<TypeHandler>());
931  }
932 }
int current_size_
Definition: repeated_field.h:342
#define GOOGLE_CHECK_NE(A, B)
Definition: common.h:717

+ Here is the call graph for this function:

template<typename TypeHandler >
TypeHandler::Type * google::protobuf::internal::RepeatedPtrFieldBase::Mutable ( int  index)
inlineprotected
893  {
894  GOOGLE_DCHECK_GE(index, 0);
895  GOOGLE_DCHECK_LT(index, size());
896  return cast<TypeHandler>(elements_[index]);
897 }
void ** elements_
Definition: repeated_field.h:341
#define GOOGLE_DCHECK_GE
Definition: common.h:758
#define GOOGLE_DCHECK_LT
Definition: common.h:755
int size() const
Definition: repeated_field.h:878

+ Here is the call graph for this function:

template<typename TypeHandler >
TypeHandler::Type ** google::protobuf::internal::RepeatedPtrFieldBase::mutable_data ( )
inlineprotected
954  {
955  // TODO(kenton): Breaks C++ aliasing rules. We should probably remove this
956  // method entirely.
957  return reinterpret_cast<typename TypeHandler::Type**>(elements_);
958 }
void ** elements_
Definition: repeated_field.h:341
Type
Type of JSON value.
Definition: rapidjson.h:642
void *const * google::protobuf::internal::RepeatedPtrFieldBase::raw_data ( ) const
inlineprotected
945  {
946  return elements_;
947 }
void ** elements_
Definition: repeated_field.h:341
void ** google::protobuf::internal::RepeatedPtrFieldBase::raw_mutable_data ( ) const
inlineprotected
949  {
950  return elements_;
951 }
void ** elements_
Definition: repeated_field.h:341
template<typename TypeHandler >
TypeHandler::Type * google::protobuf::internal::RepeatedPtrFieldBase::ReleaseCleared ( )
inlineprotected
1045  {
1047  return cast<TypeHandler>(elements_[--allocated_size_]);
1048 }
void ** elements_
Definition: repeated_field.h:341
int current_size_
Definition: repeated_field.h:342
int allocated_size_
Definition: repeated_field.h:343
#define GOOGLE_DCHECK_GT
Definition: common.h:757
template<typename TypeHandler >
TypeHandler::Type * google::protobuf::internal::RepeatedPtrFieldBase::ReleaseLast ( )
inlineprotected
1020  {
1022  typename TypeHandler::Type* result =
1023  cast<TypeHandler>(elements_[--current_size_]);
1024  --allocated_size_;
1025  if (current_size_ < allocated_size_) {
1026  // There are cleared elements on the end; replace the removed element
1027  // with the last allocated element.
1029  }
1030  return result;
1031 }
void ** elements_
Definition: repeated_field.h:341
int current_size_
Definition: repeated_field.h:342
int allocated_size_
Definition: repeated_field.h:343
#define GOOGLE_DCHECK_GT
Definition: common.h:757
Type
Type of JSON value.
Definition: rapidjson.h:642
template<typename TypeHandler >
void google::protobuf::internal::RepeatedPtrFieldBase::RemoveLast ( )
inlineprotected
912  {
914  TypeHandler::Clear(cast<TypeHandler>(elements_[--current_size_]));
915 }
void ** elements_
Definition: repeated_field.h:341
int current_size_
Definition: repeated_field.h:342
#define GOOGLE_DCHECK_GT
Definition: common.h:757
void google::protobuf::internal::RepeatedPtrFieldBase::Reserve ( int  new_size)
protected

+ Here is the caller graph for this function:

int google::protobuf::internal::RepeatedPtrFieldBase::size ( ) const
inlineprotected
878  {
879  return current_size_;
880 }
int current_size_
Definition: repeated_field.h:342

+ Here is the caller graph for this function:

template<typename TypeHandler >
int google::protobuf::internal::RepeatedPtrFieldBase::SpaceUsedExcludingSelf ( ) const
inlineprotected
974  {
975  int allocated_bytes =
976  (elements_ != NULL) ? total_size_ * sizeof(elements_[0]) : 0;
977  for (int i = 0; i < allocated_size_; ++i) {
978  allocated_bytes += TypeHandler::SpaceUsed(*cast<TypeHandler>(elements_[i]));
979  }
980  return allocated_bytes;
981 }
int total_size_
Definition: repeated_field.h:344
arena_t NULL
Definition: jemalloc_internal.h:624
void ** elements_
Definition: repeated_field.h:341
int allocated_size_
Definition: repeated_field.h:343
void google::protobuf::internal::RepeatedPtrFieldBase::Swap ( RepeatedPtrFieldBase other)
protected
void google::protobuf::internal::RepeatedPtrFieldBase::SwapElements ( int  index1,
int  index2 
)
inlineprotected
968  {
969  using std::swap; // enable ADL with fallback
970  swap(elements_[index1], elements_[index2]);
971 }
void ** elements_
Definition: repeated_field.h:341

Friends And Related Function Documentation

friend class ExtensionSet
friend
friend class GeneratedMessageReflection
friend

Member Data Documentation

int google::protobuf::internal::RepeatedPtrFieldBase::allocated_size_
private
int google::protobuf::internal::RepeatedPtrFieldBase::current_size_
private
void** google::protobuf::internal::RepeatedPtrFieldBase::elements_
private
const int google::protobuf::internal::RepeatedPtrFieldBase::kInitialSize = 0
staticprivate
int google::protobuf::internal::RepeatedPtrFieldBase::total_size_
private

The documentation for this class was generated from the following file: