map.h

#include <google/protobuf/map.h>
namespace google::protobuf

This file defines the map container and its helpers to support protobuf maps.

The Map and MapIterator types are provided by this header file. Please avoid using other types defined here, unless they are public types within Map or MapIterator, such as Map::value_type.

Classes in this file

google::protobuf::Map is an associative container type used to store protobuf map fields.
Iterators.
MapKey is an union type for representing any possible map key.
MapValueRef points to a map value.
This is the class for google::protobuf::Map's internal value_type.
google::protobuf::Map is an associative container type used to store protobuf map fields.
Iterators.

template class Map

#include <google/protobuf/map.h>
namespace google::protobuf

template <typename , typename >

google::protobuf::Map is an associative container type used to store protobuf map fields.

Each Map instance may or may not use a different hash function, a different iteration order, and so on. E.g., please don't examine implementation details to decide if the following would work: Map<int, int> m0, m1; m0[[]0] = m1[[]0] = m0[[]1] = m1[[]1] = 0; assert(m0.begin()->first == m1.begin()->first); // Bug!

Map's interface is similar to std::unordered_map, except that Map is not designed to play well with exceptions.

Members

typedef
Key key_type
typedef
T mapped_type
typedef
MapPair< Key, T > value_type
typedef
value_type * pointer
typedef
const value_type * const_pointer
typedef
value_type & reference
typedef
const value_type & const_reference
typedef
size_t size_type
typedef
hash< Key > hasher
InnerMap *
elements_
DeprecatedInnerMap *
deprecated_elements_
explicit
Map(bool old_style = false)
explicit
Map(Arena * arena, bool old_style = false)
Map(const Map & other)
template
Map(const InputIt & first, const InputIt & last, bool old_style = false)
~Map()
iterator
begin()
iterator
end()
const_iterator
begin() const
const_iterator
end() const
const_iterator
cbegin() const
const_iterator
cend() const
size_type
size() const
Capacity.
bool
empty() const
T &
operator[](const key_type & key)
Element access.
const T &
at(const key_type & key) const
T &
at(const key_type & key)
size_type
count(const key_type & key) const
Lookup.
const_iterator
find(const key_type & key) const
iterator
find(const key_type & key)
std::pair< const_iterator, const_iterator >
equal_range(const key_type & key) const
std::pair< iterator, iterator >
equal_range(const key_type & key)
std::pair< iterator, bool >
insert(const value_type & value)
insert
template void
insert(InputIt first, InputIt last)
size_type
erase(const key_type & key)
Erase and clear.
iterator
erase(iterator pos)
void
erase(iterator first, iterator last)
void
clear()
Map &
operator=(const Map & other)
Assign.
void
swap(Map & other)
hasher
hash_function() const
Access to hasher. more...

hasher Map::hash_function() const

Access to hasher.

Currently this returns a copy, but it may be modified to return a const reference in the future.

class Map::const_iterator: public iterator_base

#include <google/protobuf/map.h>
namespace google::protobuf

Members

const_iterator()
explicit
const_iterator(const DeprecatedInnerIt & dit)
explicit
const_iterator(const InnerIt & it)
const_iterator(const const_iterator & other)
const_reference
operator*() const
const_pointer
operator->() const
const_iterator &
operator++()
const_iterator
operator++(int )

class Map::iterator: public iterator_base

#include <google/protobuf/map.h>
namespace google::protobuf

Members

iterator()
explicit
iterator(const DeprecatedInnerIt & dit)
explicit
iterator(const InnerIt & it)
reference
operator*() const
pointer
operator->() const
iterator &
operator++()
iterator
operator++(int )
operator const_iterator() const
Allow implicit conversion to const_iterator.

class Map::iterator_base

#include <google/protobuf/map.h>
namespace google::protobuf

Iterators.

Known subclasses:

Members

enum
IteratorStyle
We support "old style" and "new style" iterators for now. more...
explicit
iterator_base(IteratorStyle style)
bool
OldStyle() const
bool
UnknownStyle() const
bool
SameStyle(const iterator_base & other) const

enum iterator_base::IteratorStyle {
  kUnknown,
  kOld,
  kNew
}

We support "old style" and "new style" iterators for now.

This is temporary. Also, for "iterator()" we have an unknown category. TODO(gpike): get rid of this.

kUnknown
kOld
kNew

template struct is_proto_enum

#include <google/protobuf/map.h>
namespace google::protobuf

template <typename >

Members

class MapKey

#include <google/protobuf/map.h>
namespace google::protobuf

MapKey is an union type for representing any possible map key.

Members

MapKey()
MapKey(const MapKey & other)
~MapKey()
FieldDescriptor::CppType
type() const
void
SetInt64Value(int64 value)
void
SetUInt64Value(uint64 value)
void
SetInt32Value(int32 value)
void
SetUInt32Value(uint32 value)
void
SetBoolValue(bool value)
void
SetStringValue(const string & val)
int64
GetInt64Value() const
uint64
GetUInt64Value() const
int32
GetInt32Value() const
uint32
GetUInt32Value() const
bool
GetBoolValue() const
const string &
GetStringValue() const
bool
operator<(const MapKey & other) const
bool
operator==(const MapKey & other) const
void
CopyFrom(const MapKey & other)

class MapValueRef

#include <google/protobuf/map.h>
namespace google::protobuf

MapValueRef points to a map value.

Members

MapValueRef()
void
SetInt64Value(int64 value)
void
SetUInt64Value(uint64 value)
void
SetInt32Value(int32 value)
void
SetUInt32Value(uint32 value)
void
SetBoolValue(bool value)
void
SetEnumValue(int value)
TODO(jieluo) - Checks that enum is member.
void
SetStringValue(const string & value)
void
SetFloatValue(float value)
void
SetDoubleValue(double value)
int64
GetInt64Value() const
uint64
GetUInt64Value() const
int32
GetInt32Value() const
uint32
GetUInt32Value() const
bool
GetBoolValue() const
int
GetEnumValue() const
const string &
GetStringValue() const
float
GetFloatValue() const
double
GetDoubleValue() const
const Message &
GetMessageValue() const
Message *
MutableMessageValue()

template class MapPair

#include <google/protobuf/map.h>
namespace google::protobuf

template <typename , typename >

This is the class for google::protobuf::Map's internal value_type.

Instead of using std::pair as value_type, we use this class which provides us more control of its process of construction and destruction.

Members

typedef
const Key first_type
typedef
T second_type
const Key
first
T
second
MapPair(const Key & other_first, const T & other_second)
explicit
MapPair(const Key & other_first)
MapPair(const MapPair & other)
~MapPair()
template
operator std::pair< T1, T2 >() const
Implicitly convertible to std::pair of compatible types.

template class Map

#include <google/protobuf/map.h>
namespace google::protobuf

template <typename , typename >

google::protobuf::Map is an associative container type used to store protobuf map fields.

Each Map instance may or may not use a different hash function, a different iteration order, and so on. E.g., please don't examine implementation details to decide if the following would work: Map<int, int> m0, m1; m0[[]0] = m1[[]0] = m0[[]1] = m1[[]1] = 0; assert(m0.begin()->first == m1.begin()->first); // Bug!

Map's interface is similar to std::unordered_map, except that Map is not designed to play well with exceptions.

Members

typedef
Key key_type
typedef
T mapped_type
typedef
MapPair< Key, T > value_type
typedef
value_type * pointer
typedef
const value_type * const_pointer
typedef
value_type & reference
typedef
const value_type & const_reference
typedef
size_t size_type
typedef
hash< Key > hasher
InnerMap *
elements_
DeprecatedInnerMap *
deprecated_elements_
explicit
Map(bool old_style = false)
explicit
Map(Arena * arena, bool old_style = false)
Map(const Map & other)
template
Map(const InputIt & first, const InputIt & last, bool old_style = false)
~Map()
iterator
begin()
iterator
end()
const_iterator
begin() const
const_iterator
end() const
const_iterator
cbegin() const
const_iterator
cend() const
size_type
size() const
Capacity.
bool
empty() const
T &
operator[](const key_type & key)
Element access.
const T &
at(const key_type & key) const
T &
at(const key_type & key)
size_type
count(const key_type & key) const
Lookup.
const_iterator
find(const key_type & key) const
iterator
find(const key_type & key)
std::pair< const_iterator, const_iterator >
equal_range(const key_type & key) const
std::pair< iterator, iterator >
equal_range(const key_type & key)
std::pair< iterator, bool >
insert(const value_type & value)
insert
template void
insert(InputIt first, InputIt last)
size_type
erase(const key_type & key)
Erase and clear.
iterator
erase(iterator pos)
void
erase(iterator first, iterator last)
void
clear()
Map &
operator=(const Map & other)
Assign.
void
swap(Map & other)
hasher
hash_function() const
Access to hasher. more...

hasher Map::hash_function() const

Access to hasher.

Currently this returns a copy, but it may be modified to return a const reference in the future.

class Map::const_iterator: public iterator_base

#include <google/protobuf/map.h>
namespace google::protobuf

Members

const_iterator()
explicit
const_iterator(const DeprecatedInnerIt & dit)
explicit
const_iterator(const InnerIt & it)
const_iterator(const const_iterator & other)
const_reference
operator*() const
const_pointer
operator->() const
const_iterator &
operator++()
const_iterator
operator++(int )

class Map::iterator: public iterator_base

#include <google/protobuf/map.h>
namespace google::protobuf

Members

iterator()
explicit
iterator(const DeprecatedInnerIt & dit)
explicit
iterator(const InnerIt & it)
reference
operator*() const
pointer
operator->() const
iterator &
operator++()
iterator
operator++(int )
operator const_iterator() const
Allow implicit conversion to const_iterator.

class Map::iterator_base

#include <google/protobuf/map.h>
namespace google::protobuf

Iterators.

Known subclasses:

Members

enum
IteratorStyle
We support "old style" and "new style" iterators for now. more...
explicit
iterator_base(IteratorStyle style)
bool
OldStyle() const
bool
UnknownStyle() const
bool
SameStyle(const iterator_base & other) const

enum iterator_base::IteratorStyle {
  kUnknown,
  kOld,
  kNew
}

We support "old style" and "new style" iterators for now.

This is temporary. Also, for "iterator()" we have an unknown category. TODO(gpike): get rid of this.

kUnknown
kOld
kNew