An immutable wrapper around a constant array of C-style strings to represent the fully qualified name of a symbol in compiled Bond bytecode.
More...
#include <bond/types/qualifiedname.h>
An immutable wrapper around a constant array of C-style strings to represent the fully qualified name of a symbol in compiled Bond bytecode.
The number of elements in the wrapped array is not stored; instead, the array must be terminated with a nullptr. QualifiedName does not perform any allocations; it contains a pointer to an existing array of strings whose lifetime must supersede that of the QualifiedName.
◆ QualifiedName() [1/2]
Bond::QualifiedName::QualifiedName |
( |
| ) |
|
|
inline |
Constructs an empty QualifiedName. After construction, GetElement(0) returns nullptr.
◆ QualifiedName() [2/2]
Bond::QualifiedName::QualifiedName |
( |
const char *const * |
elements | ) |
|
|
inlineexplicit |
Constructs a QualifiedName with the given array of C-style strings.
- Parameters
-
elements | Pointer to an array of string which are the elements of the qualified name. The last element of the array must be nullptr. |
◆ Compare() [1/2]
int Bond::QualifiedName::Compare |
( |
const char * |
other | ) |
const |
Does an element-wise lexicographic comparison of this QualifiedName with a string.
This function returns the same value that the other overload of this function would return if the string passed in were to be treated as a QualifiedName whose elements are separated by the '.' character.
- Parameters
-
- Returns
- A negative value, positive value or 0 if this QualifiedName is lexicographically less than greater than or equal to the other one.
◆ Compare() [2/2]
int Bond::QualifiedName::Compare |
( |
const QualifiedName & |
other | ) |
const |
Does an element-wise lexicographic comparison of this QualifiedName with another one.
The algorithm iterates over each element of both QualifiedNames and calls strcmp() for each pair of elements. If strcmp() returns a non-zero value, that value is returned immediately. If the end of this QualifiedName is reached first, a negative value is returned. If the end of the other QualifiedName is reached first, a positive value is returned. If the end of both is reached at the same time, the value 0 is returned.
- Parameters
-
- Returns
- A negative value, positive value or 0 if this QualifiedName is lexicographically less than greater than or equal to the other one.
◆ GetElement()
const char * Bond::QualifiedName::GetElement |
( |
size_t |
i | ) |
const |
|
inline |
Returns the string at the given index in the array of qualified name elements.
It it safe to call this function with the values in the range [0-n] where n is the first value for which this function returns nullptr.
- Parameters
-
i | The index of the element to be retrieved. |
◆ operator<() [1/2]
bool Bond::QualifiedName::operator< |
( |
const char * |
other | ) |
const |
|
inline |
Does an element-wise lexicographic comparison of this QualifiedName with a string. and returns whether this one is less.
- Parameters
-
- Returns
- The result of the expression:
Compare(other) < 0
.
◆ operator<() [2/2]
bool Bond::QualifiedName::operator< |
( |
const QualifiedName & |
other | ) |
const |
|
inline |
Does an element-wise lexicographic comparison of this QualifiedName with another one and returns whether this one is less.
- Parameters
-
- Returns
- The result of the expression:
Compare(other) < 0
.
◆ operator==() [1/2]
bool Bond::QualifiedName::operator== |
( |
const char * |
other | ) |
const |
|
inline |
Does an element-wise lexicographic comparison of this QualifiedName with a string. and returns whether they are equal.
- Parameters
-
- Returns
- The result of the expression:
Compare(other) == 0
.
◆ operator==() [2/2]
bool Bond::QualifiedName::operator== |
( |
const QualifiedName & |
other | ) |
const |
|
inline |
Does an element-wise lexicographic comparison of this QualifiedName with another one and returns whether they are equal.
- Parameters
-
- Returns
- The result of the expression:
Compare(other) == 0
.
◆ PrintTo()
void Bond::QualifiedName::PrintTo |
( |
OutputStream & |
stream | ) |
const |
Writes the qualified name to the provided output stream with the elements separated by a '.' character.
- Parameters
-
stream | The stream to which the characters are written. |
The documentation for this class was generated from the following file:
- include/bond/types/qualifiedname.h