class Map

August 13, 2019 ยท View on GitHub

Member values

Member nameData typeDescription
handleMapHandleMap handle (do not set on createMap() call)
namestringMap friendly name
elementsMapElementArray of map elements

Member functions

Function nameReturn typeInput typeDescription
has_handle() constboolvoidReturns true if handle is set.
handle()const MapHandle&voidReturns the current value of handle. If handle is not set, returns a MapHandle with none of its fields set (possibly handle::default_instance()).
mutable_handle()MapHandle *voidReturns a pointer to the mutable MapHandle object that stores the field's value. If the field was not set prior to the call, then the returned MapHandle will have none of its fields set (i.e. it will be identical to a newly-allocated MapHandle). After calling this, has_handle() will return true and handle() will return a reference to the same instance of MapHandle.
clear_handle()voidvoidClears the value of the field. After calling this, has_handle() will return false and handle() will return the default value.
set_allocated_handle()voidMapHandle *Sets the MapHandle object to the field and frees the previous field value if it exists. If the MapHandle pointer is not NULL, the message takes ownership of the allocated MapHandle object and has_ MapHandle() will return true. Otherwise, if the handle is NULL, the behavior is the same as calling clear_handle().
release_handle()MapHandle *voidReleases the ownership of the field and returns the pointer of the MapHandle object. After calling this, caller takes the ownership of the allocated MapHandle object, has_handle() will return false, and handle() will return the default value.
name()const string&voidReturns the current value of name. If name is not set, returns the empty string/empty bytes.
set_name()voidconst string&Sets the value of name. After calling this, name() will return a copy of value.
set_name()voidstring&&(C++11 and beyond): Sets the value of name, moving from the passed string. After calling this, name() will return a copy of value.
set_name()voidconst char*Sets the value of name using a C-style null-terminated string. After calling this, name() will return a copy of value.
mutable_name()string *voidReturns a pointer to the mutable string object that stores name's value. If the field was not set prior to the call, then the returned string will be empty. After calling this, name() will return whatever value is written into the given string.
clear_name()voidvoidClears the value of name. After calling this, name() will return the empty string/empty bytes.
set_allocated_name()voidstring*Sets the string object to the field and frees the previous field value if it exists. If the string pointer is not NULL, the message takes ownership of the allocated string object. The message is free to delete the allocated string object at any time, so references to the object may be invalidated. Otherwise, if the value is NULL, the behavior is the same as calling clear_name().
release_name()string *voidReleases the ownership of name and returns the pointer of the string object. After calling this, caller takes the ownership of the allocated string object and name() will return the empty string/empty bytes.
elements_size() constintvoidReturns the number of elements currently in the field.
elements() constconst MapElementint indexReturns the element at the given zero-based index. Calling this method with index outside of [0, elements_size()) yields undefined behavior.
mutable_elements()MapElement*int indexReturns a pointer to the mutable MapElement object that stores the value of the element at the given zero-based index. Calling this method with index outside of [0, elements_size()) yields undefined behavior.
add_elements()MapElement*voidAdds a new element and returns a pointer to it. The returned MapElement is mutable and will have none of its fields set (i.e. it will be identical to a newly-allocated MapElement).
clear_elements()voidvoidRemoves all elements from the field. After calling this, elements_size() will return zero.
elements() constconst RepeatedPtrField< MapElement>&voidReturns the underlying RepeatedPtrField that stores the field's elements. This container class provides STL-like iterators and other methods.
mutable_elements()RepeatedPtrField< MapElement>*voidReturns a pointer to the underlying mutable RepeatedPtrField that stores the field's elements. This container class provides STL-like iterators and other methods.

Parent topic: Base (C++)