Query modules C++ API
This is the API documentation for mgp.hpp
, which contains declarations of all
functions in the C++ API for implementing query module procedures and functions.
The source file can be found in the Memgraph installation directory, under
/usr/include/memgraph
.
To see how to implement query modules in C++, take a look at the example we provided.
If you install any C++ modules after running Memgraph, youβll need to load them into Memgraph or restart Memgraph in order to use them.
Functions and proceduresβ
With this API itβs possible to extend your Cypher queries with functions and procedures with
AddProcedure
and AddFunction
.
The API needs memory access to add procedures and functions; this can be done with mgp::memory = memory;
.
Functions are simple operations that return a single value and can be used in any expression or predicate.
Procedures are more complex computations that may modify the graph, and their output is available to
later processing steps in your query. A procedure may only be run from CALL
clauses.
The output is a stream of records that is made accessible with a YIELD
clause.
AddProcedureβ
Add a procedure to your query module. The procedure is registered as [QUERY_MODULE_NAME].[PROC_NAME]
and can be used in Cypher queries.
void AddProcedure(
mgp_proc_cb callback,
std::string_view name,
ProcedureType proc_type,
std::vector<Parameter> parameters,
std::vector<Return> returns,
mgp_module *module,
mgp_memory *memory);
Inputβ
callback
: procedure callbackname
: procedure nameproc_type
: procedure type (read/write)parameters
: vector (list) of procedure parametersreturns
: vector (list) of procedure return valuesmodule
: the query module that the procedure is added tomemory
: access to memory
ProcedureTypeβ
Enum class for Cypher procedure types.
ProcedureType::Read
: read procedureProcedureType::Write
: write procedure
AddFunctionβ
Add a function to your query module. The function is registered as [QUERY_MODULE_NAME].[FUNC_NAME]
and can be used in Cypher queries.
void AddFunction(
mgp_func_cb callback,
std::string_view name,
std::vector<Parameter> parameters,
std::vector<Return> returns,
mgp_module *module,
mgp_memory *memory);
Inputβ
callback
: function callbackname
: function nameparameters
: vector (list) of function parametersreturns
: vector (list) of function return valuesmodule
: the query module that the procedure is added tomemory
: access to memory
Parameterβ
Represents a procedure/function parameter. Parameters are defined by their name, type, and (if optional) default value.
Constructorsβ
Creates a non-optional parameter with the given name
and type
.
Parameter(std::string_view name, Type type)
Creates an optional Boolean parameter with the given name
and default_value
.
Parameter(std::string_view name, Type type, bool default_value)
Creates an optional integer parameter with the given name
and default_value
.
Parameter(std::string_view name, Type type, int default_value)
Creates an optional floating-point parameter with the given name
and default_value
.
Parameter(std::string_view name, Type type, double default_value)
Creates an optional string parameter with the given name
and default_value
.
Parameter(std::string_view name, Type type, std::string_view default_value)
Parameter(std::string_view name, Type type, const char *default_value)
Creates a non-optional list parameter with the given name
and item_type
.
The list_type
parameter is organized as follows: {Type::List, Type::[ITEM_TYPE]}
.
Parameter(std::string_view name, std::pair<Type, Type> list_type)
Creates an optional list parameter with the given name
, item_type
, and default_value
.
The list_type
parameter is organized as follows: {Type::List, Type::[ITEM_TYPE]}
.
Parameter(std::string_view name, std::pair<Type, Type> list_type, Value default_value)
Member variablesβ
Name | Type | Description |
---|---|---|
name | std::string_view | parameter name |
type_ | Type | parameter type |
list_item_type_ | Type | (list parameters) item type |
optional | bool | whether the parameter is optional |
default_value | Value | (optional parameters) default value |
Returnβ
Represents a procedure/function return value. Values are defined by their name and type.
Constructorsβ
Creates a return value with the given name
and type
.
Return(std::string_view name, Type type)
Creates a return value with the given name
and list_type
.
The list_type
parameter is organized as follows: {Type::List, Type::[ITEM_TYPE]}
.
Return(std::string_view name, std::pair<Type, Type> list_type)
Member variablesβ
Name | Type | Description |
---|---|---|
name | std::string_view | return name |
type_ | Type | return type |
list_item_type_ | Type | (list values) item type |
RecordFactoryβ
Factory class for Record
.
Constructorsβ
explicit RecordFactory(mgp_result *result)
Member functionsβ
Name | Description |
---|---|
NewRecord | Adds a new result record. |
SetErrorMessage | Sets the given error message. |
NewRecordβ
Adds a new result record.
const Record NewRecord() const
SetErrorMessageβ
Sets the given error message.
void SetErrorMessage(const std::string_view error_msg) const
void SetErrorMessage(const char *error_msg) const
Recordβ
Represents a record - the building block of Cypher procedure results. Each result is a stream of records, and a functionβs record is a sequence of (field name: output value) pairs.
Constructorsβ
explicit Record(mgp_result_record *record)
Member functionsβ
Name | Description |
---|---|
Insert | Inserts a value of given type under field field_name . |
Insertβ
Inserts a value of given type under field field_name
.
void Insert(const char *field_name, bool value)
void Insert(const char *field_name, std::int64_t value)
void Insert(const char *field_name, double value)
void Insert(const char *field_name, std::string_view value)
void Insert(const char *field_name, const char *value)
void Insert(const char *field_name, const List &value)
void Insert(const char *field_name, const Map &value)
void Insert(const char *field_name, const Node &value)
void Insert(const char *field_name, const Relationship &value)
void Insert(const char *field_name, const Path &value)
void Insert(const char *field_name, const Date &value)
void Insert(const char *field_name, const LocalTime value)
void Insert(const char *field_name, const LocalDateTime value)
void Insert(const char *field_name, const Duration value)
Resultβ
Represents a result - the single return value of a Cypher function.
Constructorsβ
explicit Result(mgp_func_result *result)
Member functionsβ
Name | Description |
---|---|
SetValue | Sets a return value of given type. |
SetErrorMessage | Sets the given error message. |
SetValueβ
Sets a return value of given type.
void SetValue(bool value)
void SetValue(std::int64_t value)
void SetValue(double value)
void SetValue(std::string_view value)
void SetValue(const char *value)
void SetValue(const List &value)
void SetValue(const Map &value)
void SetValue(const Node &value)
void SetValue(const Relationship &value)
void SetValue(const Path &value)
void SetValue(const Date &value)
void SetValue(const LocalTime value)
void SetValue(const LocalDateTime value)
void SetValue(const Duration value)
SetErrorMessageβ
Sets the given error message.
void SetErrorMessage(const std::string_view error_msg) const
void SetErrorMessage(const char *error_msg) const
Graph APIβ
This section covers the interface for working with the Memgraph DB graph using the C++ API. A description of data types is available here.
Graphβ
Constructorsβ
explicit Graph(mgp_graph *graph)
Member functionsβ
Name | Description |
---|---|
Order | Returns the graph order (number of nodes). |
Size | Returns the graph size (number of relationships). |
Nodes (GraphNodes ) | Returns an iterable structure of the graphβs nodes. |
Relationships | Returns an iterable structure of the graphβs relationships. |
GetNodeById | Returns the graph node with the given ID. |
ContainsNode | Returns whether the graph contains the given node (accepts node or its ID). |
ContainsRelationship | Returns whether the graph contains the given relationship (accepts relationship or its ID). |
IsMutable | Returns whether the graph is mutable. |
CreateNode | Creates a node and adds it to the graph. |
DeleteNode | Deletes a node from the graph. |
DetachDeleteNode | Deletes a node and all its incident edges from the graph. |
CreateRelationship | Creates a relationship of type type between nodes from and to and adds it to the graph. |
DeleteRelationship | Deletes a relationship from the graph. |
Orderβ
Returns the graph order (number of nodes).
int64_t Order() const
Sizeβ
Returns the graph size (number of relationships).
int64_t Size() const
Nodes (GraphNodes)β
Returns an iterable structure of the graphβs nodes.
GraphNodes Nodes() const
Relationshipsβ
Returns an iterable structure of the graphβs relationships.
GraphRelationships Relationships() const
GetNodeByIdβ
Returns the graph node with the given ID.
Node GetNodeById(const Id node_id) const
ContainsNodeβ
Returns whether the graph contains a node with the given ID.
bool ContainsNode(const Id node_id) const
Returns whether the graph contains the given node.
bool ContainsNode(const Node &node) const
ContainsRelationshipβ
bool ContainsRelationship(const Id relationship_id) const
bool ContainsRelationship(const Relationship &relationship) const
IsMutableβ
Returns whether the graph is mutable.
bool IsMutable() const
CreateNodeβ
Creates a node and adds it to the graph.
Node CreateNode();
DeleteNodeβ
Deletes a node from the graph.
void DeleteNode(const Node &node)
DetachDeleteNodeβ
Deletes a node and all its incident edges from the graph.
void DetachDeleteNode(const Node &node)
CreateRelationshipβ
Creates a relationship of type type
between nodes from
and to
and adds it to the graph.
Relationship CreateRelationship(const Node &from, const Node &to, const std::string_view type)
DeleteRelationshipβ
Deletes a relationship from the graph.
void DeleteRelationship(const Relationship &relationship)
GraphNodesβ
Auxiliary class providing an iterable view of the nodes contained in the graph.
GraphNodes
values may only be used for iteration to obtain the values stored within.
Constructorsβ
explicit GraphNodes(mgp_vertices_iterator *nodes_iterator)
Member variablesβ
Name | Type | Description |
---|---|---|
Iterator | GraphNodes::Iterator | Const forward iterator for GraphNodes . |
Member functionsβ
Name | Description |
---|---|
begin end cbegin cend | Returns the beginning/end of the GraphNodes iterator. |
GraphRelationshipsβ
Auxiliary class providing an iterable view of the relationships contained in the graph.
GraphRelationships
values may only be used for iteration to obtain the values stored within.
Constructorsβ
explicit GraphRelationships(mgp_graph *graph)
Member variablesβ
Name | Type | Description |
---|---|---|
Iterator | GraphRelationships::Iterator | Const forward iterator for GraphRelationships . |
Member functionsβ
Name | Description |
---|---|
begin end cbegin cend | Returns the beginning/end of the GraphRelationship iterator. |
Nodeβ
Represents a node (vertex) of the Memgraph graph.
Constructorsβ
Creates a Node from the copy of the given mgp_vertex
.
explicit Node(mgp_vertex *ptr)
explicit Node(const mgp_vertex *const_ptr)
Copy and move constructors:
Node(const Node &other) noexcept
Node(Node &&other) noexcept
Member functionsβ
Name | Description |
---|---|
Id | Returns the nodeβs ID. |
Labels | Returns an iterable & indexable structure of the nodeβs labels. |
HasLabel | Returns whether the node has the given label . |
Properties | Returns an iterable & indexable structure of the nodeβs properties. |
InRelationships | Returns an iterable structure of the nodeβs inbound relationships. |
OutRelationships | Returns an iterable structure of the nodeβs outbound relationships. |
AddLabel | Adds a label to the node. |
SetProperty | Set value of node's property |
GetProperty | Get value of node's property |
Idβ
Returns the nodeβs ID.
mgp::Id Id() const
Labelsβ
Returns an iterable & indexable structure of the nodeβs labels.
class Labels Labels() const
HasLabelβ
Returns whether the node has the given label
.
bool HasLabel(std::string_view label) const
Propertiesβ
Returns an iterable & indexable structure of the nodeβs properties.
std::map<std::string, mgp::Value> Properties() const
GetPropertyβ
Gets value of node's property.
mgp::value GetProperty(const std::string& property) const
SetPropertyβ
Sets value of node's property.
void SetProperty(std::string key, std::string value) const
InRelationshipsβ
Returns an iterable structure of the nodeβs inbound relationships.
Relationships InRelationships() const
OutRelationshipsβ
Returns an iterable structure of the nodeβs outbound relationships.
Relationships OutRelationships() const
AddLabelβ
Adds a label to the node.
void AddLabel(const std::string_view label)
Operatorsβ
Name | Description |
---|---|
operator[] | Returns the value of the nodeβs property_name property. |
operator== operator!= operator< | comparison operators |
operator[]β
Returns the value of the nodeβs property_name
property.
const Value operator[](std::string_view property_name) const
Relationshipβ
Represents a relationship (edge) of the Memgraph graph.
Constructorsβ
Creates a Relationship from the copy of the given mgp_edge
.
explicit Relationship(mgp_edge *ptr)
explicit Relationship(const mgp_edge *const_ptr)
Copy and move constructors:
Relationship(const Relationship &other) noexcept
Relationship(Relationship &&other) noexcept
Member functionsβ
Name | Description |
---|---|
Id | Returns the relationshipβs ID. |
Type | Returns the relationshipβs type. |
Properties | Returns an iterable & indexable structure of the relationshipβs properties. |
SetProperty | Set value of relationship's property |
GetProperty | Get value of relationship's property |
From | Returns the relationshipβs source node. |
To | Returns the relationshipβs destination node. |
Idβ
Returns the relationshipβs ID.
mgp::Id Id() const
Typeβ
Returns the relationshipβs type.
std::string_view Type() const
Propertiesβ
Returns an iterable & indexable structure of the relationshipβs properties.
std::map<std::string, mgp::Value> Properties() const
GetPropertyβ
Gets value of the relationship's property.
mgp::value GetProperty(const std::string& property) const
SetPropertyβ
Sets value of the relationship's property.
void SetProperty(std::string key, std::string value) const
Fromβ
Returns the relationshipβs source node.
Node From() const
Toβ
Returns the relationshipβs source node.
Node To() const
Operatorsβ
Name | Description |
---|---|
operator[] | Returns the value of the relationshipβs property_name property. |
operator== operator!= operator< | comparison operators |
operator[]β
Returns the value of the relationshipβs property_name
property.
const Value operator[](std::string_view property_name) const
Relationshipsβ
Auxiliary class providing an iterable view of the relationships adjacent to a node.
Relationships
values may only be used for iteration to obtain the values stored within.
Constructorsβ
explicit Relationships(mgp_edges_iterator *relationships_iterator)
Member variablesβ
Name | Type | Description |
---|---|---|
Iterator | Relationships::Iterator | Const forward iterator for Relationships . |
Member functionsβ
Name | Description |
---|---|
begin end cbegin cend | Returns the beginning/end of the Relationships iterator. |
Idβ
Represents the unique ID possessed by all Memgraph nodes and relationships.
Member functionsβ
Name | Description |
---|---|
FromUint | Constructs an Id object from uint64_t . |
FromInt | Constructs an Id object from int64_t . |
AsUint | Returns the ID value as uint64_t . |
AsInt | Returns the ID value as int64_t . |
FromUintβ
Constructs an Id
object from uint64_t
.
static Id FromUint(uint64_t id)
FromIntβ
Constructs an Id
object from int64_t
.
static Id FromInt(int64_t id)
AsUintβ
Returns the ID value as uint64_t
.
int64_t AsUint() const
AsIntβ
Returns the ID value as int64_t
.
int64_t AsInt() const
Operatorsβ
Name | Description |
---|---|
operator== operator!= operator< | comparison operators |
Labelsβ
Represents a view of node labels.
Constructorsβ
explicit Labels(mgp_vertex *node_ptr)
Copy and move constructors:
Labels(const Labels &other) noexcept
Labels(Labels &&other) noexcept
Member variablesβ
Name | Type | Description |
---|---|---|
Iterator | Labels::Iterator | Const forward iterator for Labels . |
Member functionsβ
Name | Description |
---|---|
Size | Returns the number of the labels, i.e. the size of their list. |
begin end cbegin cend | Returns the beginning/end of the Labels iterator. |
Sizeβ
Returns the number of the labels, i.e. the size of their list.
size_t Size() const
Operatorsβ
Name | Description |
---|---|
operator[] | Returns the nodeβs label at position index . |
operator[]β
Returns the nodeβs label at position index
.
std::string_view operator[](size_t index) const
Dateβ
Represents a date with a year, month, and day.
Constructorsβ
Creates a Date object from the copy of the given mgp_date
.
explicit Date(mgp_date *ptr)
explicit Date(const mgp_date *const_ptr)
Creates a Date object from the given string representing a date in the ISO 8601 format
(YYYY-MM-DD
, YYYYMMDD
, or YYYY-MM
).
explicit Date(std::string_view string)
Creates a Date object with the given year
, month
, and day
properties.
Date(int year, int month, int day)
Copy and move constructors:
Date(const Date &other) noexcept
Date(Date &&other) noexcept
Member functionsβ
Name | Description |
---|---|
Now | Returns the current Date . |
Year | Returns the dateβs year property. |
Month | Returns the dateβs month property. |
Day | Returns the dateβs day property. |
Timestamp | Returns the dateβs timestamp (microseconds since Unix epoch). |
Nowβ
Returns the current Date
.
static Date Now()
Yearβ
Returns the dateβs year
property.
int Year() const
Monthβ
Returns the dateβs month
property.
int Month() const
Dayβ
Returns the dateβs day
property.
int Day() const
Timestampβ
Returns the dateβs timestamp (microseconds since Unix epoch).
int64_t Timestamp() const
Operatorsβ
Name | Description |
---|---|
operator+ operator- | arithmetic operators |
operator== operator< | comparison operators |
operator-β
Date operator-(const Duration &dur) const
Duration operator-(const Date &other) const
operator[]β
Returns the value of the relationshipβs property_name
property.
const Value operator[](std::string_view property_name) const
LocalTimeβ
Represents a time within the day without timezone information.
Constructorsβ
Creates a LocalTime object from the copy of the given mgp_local_time
.
explicit LocalTime(mgp_local_time *ptr)
explicit LocalTime(const mgp_local_time *const_ptr)
Creates a LocalTime object from the given string representing a date in the ISO 8601 format
([T]hh:mm:ss
, [T]hh:mm
, [T]hhmmss
, [T]hhmm
, or [T]hh
).
explicit LocalTime(std::string_view string)
Creates a LocalTime object with the given hour
, minute
, second
, millisecond
, and microsecond
properties.
LocalTime(int hour, int minute, int second, int millisecond, int microsecond)
Copy and move constructors:
LocalTime(const LocalTime &other) noexcept
LocalTime(LocalTime &&other) noexcept
Member functionsβ
Name | Description |
---|---|
Now | Returns the current LocalTime . |
Hour | Returns the objectβs hour property. |
Minute | Returns the objectβs minute property. |
Second | Returns the objectβs second property. |
Millisecond | Returns the objectβs millisecond property. |
Microsecond | Returns the objectβs microsecond property. |
Timestamp | Returns the objectβs timestamp (microseconds since Unix epoch). |
Nowβ
Returns the current LocalTime
.
static LocalTime Now()
Hourβ
Returns the objectβs hour
property.
int Hour() const
Minuteβ
Returns the objectβs minute
property.
int Minute() const
Secondβ
Returns the objectβs second
property.
int Second() const
Millisecondβ
Returns the objectβs millisecond
property.
int Millisecond() const
Microsecondβ
Returns the objectβs microsecond
property.
int Microsecond() const
Timestampβ
Returns the objectβs timestamp (microseconds since Unix epoch).
int64_t Timestamp() const
Operatorsβ
Name | Description |
---|---|
operator+ operator- | arithmetic operators |
operator== operator< | comparison operators |
operator-β
LocalTime operator-(const Duration &dur) const
Duration operator-(const LocalDateTime &other) const
LocalDateTimeβ
Temporal type representing a date and a local time.
Constructorsβ
Creates a LocalDateTime object from the copy of the given mgp_local_date_time
.
explicit LocalDateTime(mgp_local_date_time *ptr)
explicit LocalDateTime(const mgp_local_date_time *const_ptr)
Creates a LocalDateTime object from the given string representing a date in the ISO 8601 format
(YYYY-MM-DDThh:mm:ss
, YYYY-MM-DDThh:mm
, YYYYMMDDThhmmss
, YYYYMMDDThhmm
, or YYYYMMDDThh
).
explicit LocalDateTime(std::string_view string)
Creates a LocalDateTime object with the given year
, month
, day
, hour
, minute
, second
, millisecond
,
and microsecond
properties.
LocalDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond)
Copy and move constructors:
LocalDateTime(const LocalDateTime &other) noexcept
LocalDateTime(LocalDateTime &&other) noexcept
Member functionsβ
Name | Description |
---|---|
Now | Returns the current LocalDateTime . |
Year | Returns the objectβs year property. |
Month | Returns the objectβs month property. |
Day | Returns the objectβs day property. |
Hour | Returns the objectβs hour property. |
Minute | Returns the objectβs minute property. |
Second | Returns the objectβs second property. |
Millisecond | Returns the objectβs millisecond property. |
Microsecond | Returns the objectβs microsecond property. |
Timestamp | Returns the objectβs timestamp (microseconds since Unix epoch). |
Nowβ
Returns the current LocalDateTime
.
static LocalDateTime Now()
Yearβ
Returns the objectβs year
property.
int Year() const
Monthβ
Returns the objectβs month
property.
int Month() const
Dayβ
Returns the objectβs day
property.
int Day() const
Hourβ
Returns the objectβs hour
property.
int Hour() const
Minuteβ
Returns the objectβs minute
property.
int Minute() const
Secondβ
Returns the objectβs second
property.
int Second() const
Millisecondβ
Returns the objectβs millisecond
property.
int Millisecond() const
Microsecondβ
Returns the objectβs microsecond
property.
int Microsecond() const
Timestampβ
Returns the dateβs timestamp (microseconds since Unix epoch).
int64_t Timestamp() const
Operatorsβ
Name | Description |
---|---|
operator+ operator- | arithmetic operators |
operator== operator< | comparison operators |
operator-β
LocalDateTime operator-(const Duration &dur) const
Duration operator-(const LocalDateTime &other) const
Durationβ
Represents a period of time in Memgraph.
Constructorsβ
Creates a Duration object from the copy of the given mgp_duration
.
explicit Duration(mgp_duration *ptr)
explicit Duration(const mgp_duration *const_ptr)
Creates a Duration object from the given string in the following format: P[nD]T[nH][nM][nS]
, where (1)
n
stands for a number, (2) capital letters are used as a separator, (3) each field in []
is optional,
and (4) only the last field may be a non-integer.
explicit Duration(std::string_view string)
Creates a Duration object from the given number of microseconds.
explicit Duration(int64_t microseconds)
Creates a Duration object with the given day
, hour
, minute
, second
, millisecond
, and microsecond
properties.
Duration(double day, double hour, double minute, double second, double millisecond, double microsecond)
Copy and move constructors:
Duration(const Duration &other) noexcept
Duration(Duration &&other) noexcept
Member functionsβ
Name | Description |
---|---|
Microseconds | Returns the duration as microseconds. |
Microsecondsβ
Returns the duration as microseconds.
int64_t Microseconds() const
Operatorsβ
Name | Description |
---|---|
operator+ operator- | arithmetic operators |
operator== operator< | comparison operators |
operator-β
Duration operator-(const Duration &other) const
Duration operator-() const
Pathβ
A path is a data structure consisting of alternating nodes and relationships, with the start and end points of a path necessarily being nodes.
Constructorsβ
Creates a Path from the copy of the given mgp_path
.
explicit Path(mgp_path *ptr)
explicit Path(const mgp_path *const_ptr)
Creates a Path starting with the given start_node
.
explicit Path(const Node &start_node)
Copy and move constructors:
Path(const Path &other) noexcept
Path(Path &&other) noexcept
Member functionsβ
Name | Description |
---|---|
Length | Returns the path length (number of relationships). |
GetNodeAt | Returns the node at the given index . The index must be less than or equal to length of the path. |
GetRelationshipAt | Returns the relationship at the given index . The index must be less than length of the path. |
Expand | Adds a relationship continuing from the last node on the path. |
Lengthβ
Returns the path length (number of relationships).
size_t Length() const
GetNodeAtβ
Returns the node at the given index
. The index
must be less than or equal to length of the path.
Node GetNodeAt(size_t index) const
GetRelationshipAtβ
Returns the relationship at the given index
. The index
must be less than the length of the path.
Relationship GetRelationshipAt(size_t index) const
Expandβ
Adds a relationship continuing from the last node on the path.
void Expand(const Relationship &relationship)
Operatorsβ
Name | Description |
---|---|
operator== operator!= | comparison operators |
Listβ
A list containing any number of values of any supported type.
Constructorsβ
Creates a List from the copy of the given mgp_list
.
explicit List(mgp_list *ptr)
explicit List(const mgp_list *const_ptr)
Creates an empty List.
explicit List()
Creates a List with the given capacity
.
explicit List(size_t capacity)
Creates a List from the given vector.
explicit List(const std::vector<Value> &values)
explicit List(std::vector<Value> &&values)
Creates a List from the given initializer_list.
explicit List(const std::initializer_list<Value> list)
Copy and move constructors:
List(const List &other) noexcept
List(List &&other) noexcept
Member variablesβ
Name | Type | Description |
---|---|---|
Iterator | List::Iterator | Const forward iterator for List containers. |
Member functionsβ
Name | Description |
---|---|
Size | Returns the size of the list. |
Empty | Returns whether the list is empty. |
Append | Appends the given value to the list. |
AppendExtend | Extends the list and appends the given value to it. |
begin end cbegin cend | Returns the beginning/end of the List iterator. |
Sizeβ
Returns the size of the list.
size_t Size() const
Emptyβ
Returns whether the list is empty.
bool Empty() const
Appendβ
Appends the given value
to the list. The value
is copied.
void Append(const Value &value)
Appends the given value
to the list. Takes ownership of value
by moving it.
The behavior of accessing value
after performing this operation is undefined.
void Append(Value &&value)
AppendExtendβ
Extends the list and appends the given value
to it. The value
is copied.
void AppendExtend(const Value &value)
Extends the list and appends the given value
to it. Takes ownership of value
by moving it.
The behavior of accessing value
after performing this operation is undefined.
void AppendExtend(Value &&value)
Operatorsβ
Name | Description |
---|---|
operator[] | Returns the value at the given index . |
operator== operator!= | comparison operators |
operator[]β
Returns the value at the given index
.
const Value operator[](size_t index) const
Mapβ
A map of key-value pairs where keys are strings, and values can be of any supported type. The pairs are represented as MapItems.
Constructorsβ
Creates a Map from the copy of the given mgp_map
.
explicit Map(mgp_map *ptr)
explicit Map(const mgp_map *const_ptr)
Creates an empty Map.
explicit Map()
Creates a Map from the given STL map.
explicit Map(const std::map<std::string_view, Value> &items)
explicit Map(std::map<std::string_view, Value> &&items)
Creates a Map from the given initializer_list (map items correspond to initializer list pairs).
Map(const std::initializer_list<std::pair<std::string_view, Value>> items)
Copy and move constructors:
Map(const Map &other) noexcept
Map(Map &&other) noexcept
Member variablesβ
Name | Type | Description |
---|---|---|
Iterator | List::Iterator | Const forward iterator for List containers. |
Member functionsβ
Name | Description |
---|---|
Size | Returns the size of the map. |
Empty | Returns whether the map is empty. |
At | Returns the value at the given key . |
Insert | Inserts the given key -value pair into the map. |
begin end cbegin cend | Returns the beginning/end of the Map iterator. |
Sizeβ
Returns the size of the map.
size_t Size() const
Emptyβ
Returns whether the map is empty.
bool Empty() const
Atβ
Returns the value at the given key
.
Value const At(std::string_view key) const
Insertβ
Inserts the given key
-value
pair into the map. The value
is copied.
void Insert(std::string_view key, const Value &value)
Inserts the given key
-value
pair into the map. Takes ownership of value
by moving it.
The behavior of accessing value
after performing this operation is undefined.
void Insert(std::string_view key, Value &&value)
Operatorsβ
Name | Description |
---|---|
operator[] | Returns the value at the given key . |
operator== operator!= | comparison operators |
operator[]β
Returns the value at the given key
.
const Value operator[](std::string_view key) const
MapItemβ
Auxiliary data structure representing key-value pairs where keys are strings, and values can be of any supported type.
Member variablesβ
Name | Type | Description |
---|---|---|
key | std::string_view | Key for accessing the value stored in a MapItem . |
value | Value | The stored value. |
Operatorsβ
Name | Description |
---|---|
operator== operator!= operator< | comparison operators |
Valueβ
Represents a value of any type supported by Memgraph. The data types are described here.
Constructorsβ
Creates a Value from the copy of the given mgp_value
.
explicit Value(mgp_value *ptr)
Creates a null Value.
explicit Value()
Basic type constructors:
explicit Value(const bool value)
explicit Value(const int64_t value)
explicit Value(const double value)
explicit Value(const char *value)
explicit Value(const std::string_view value)
Container type constructors:
explicit Value(const List &value)
explicit Value(List &&value)
explicit Value(const Map &value)
explicit Value(Map &&value)
Graph element type constructors:
explicit Value(const Node &value)
explicit Value(Node &&value)
explicit Value(const Relationship &value)
explicit Value(Relationship &&value)
explicit Value(const Path &value)
explicit Value(Path &&value)
Temporal type constructors:
explicit Value(const Date &value)
explicit Value(Date &&value)
explicit Value(const LocalTime &value)
explicit Value(LocalTime &&value)
explicit Value(const LocalDateTime &value)
explicit Value(LocalDateTime &&value)
explicit Value(const Duration &value)
explicit Value(Duration &&value)
Copy and move constructors:
Value(const Value &other) noexcept
Value(Value &&other) noexcept
Member functionsβ
Name | Description |
---|---|
ptr | Returns the pointer to the stored value. |
Type | Returns the type of the value. |
Value[TYPE] | Returns a value of given type. |
Is[TYPE] | Returns whether the value is of given type. |
Typeβ
Returns the C API pointer to the stored value.
mgp_value *ptr() const
Typeβ
Returns the type of the value, i.e. the type stored in the Value
object.
mgp::Type Type() const
Value[TYPE]β
Depending on the exact function called, returns a typed value of the appropriate type.
Throws an exception if the type stored in the Value
object is not compatible with the function called.
bool ValueBool() const
int64_t ValueInt() const
double ValueDouble const
double ValueNumeric const
std::string_view ValueString() const
const List ValueList() const
const Map ValueMap() const
const Node ValueNode() const
const Relationship ValueRelationship() const
const Path ValuePath() const
const Date ValueDate() const
const LocalTime ValueLocalTime() const
const LocalDateTime ValueLocalDateTime() const
const Map ValueMap() const
Is[TYPE]β
Returns whether the value stored in the Value
object is of the type in the call.
bool IsNull() const
bool IsBool() const
bool IsInt() const
bool IsDouble() const
bool IsNumeric() const
bool IsString() const
bool IsList() const
bool IsMap() const
bool IsNode() const
bool IsRelationship() const
bool IsPath() const
bool IsDate() const
bool IsLocalTime() const
bool IsLocalDateTime() const
bool IsDuration() const
Operatorsβ
Name | Description |
---|---|
operator== operator!= | comparison operators |
Typeβ
Enumerates the data types supported by Memgraph and its C++ API. The types are listed and described on this page.
Type::Null
Type::Bool
Type::Int
Type::Double
Type::String
Type::List
Type::Map
Type::Node
Type::Relationship
Type::Path
Type::Date
Type::LocalTime
Type::LocalDateTime
Type::Duration
Exceptionsβ
During operation, the following exceptions may be thrown.
Exception | Message |
---|---|
ValueException | various (handles unknown/unexpected types) |
NotFoundException | Node with ID [ID] not found! |
NotEnoughMemoryException | Not enough memory! |
UnknownException | Unknown exception! |
AllocationException | Could not allocate memory! |
InsufficientBufferException | Buffer is not sufficient to process procedure! |
IndexException | Index value out of bounds! |
OutOfRangeException | Index out of range! |
LogicException | Logic exception, check the procedure signature! |
DeletedObjectException | Object is deleted! |
InvalidArgumentException | Invalid argument! |
InvalidIDException | Invalid ID! |
KeyAlreadyExistsException | Key you are trying to set already exists! |
ImmutableObjectException | Object you are trying to change is immutable! |
ValueConversionException | Error in value conversion! |
SerializationException | Error in serialization! |