BLPAPI C++
3.23.2
|
#include <blpapi_name.h>
Public Member Functions | |
Name () | |
Name (blpapi_Name_t *handle) | |
Name (const Name &original) | |
Name (const char *nameString) | |
~Name () | |
Name & | operator= (const Name &rhs) |
const char * | string () const |
size_t | length () const |
size_t | hash () const |
blpapi_Name_t * | impl () const |
Static Public Member Functions | |
static Name | findName (const char *nameString) |
static bool | hasName (const char *nameString) |
Name
represents a string in a form which provides O(1) hashing and comparison, independent of the string length.
Name
objects are used to identify and access the classes which define a schema - SchemaTypeDefinition
, SchemaElementDefinition
, Constant
, and ConstantList
. They are also used to access the values in Element
objects and Message
objects.
The Name
class is an efficient substitute for a string when used as a key, providing constant-time hashing and comparison. Two Name
objects constructed from strings for which strcmp()
would return 0 will always compare equal.
The ordering of Name
objects (as defined by operator<(Name,Name)
) is consistent during a particular instance of a single application. However, the ordering is not lexical and is not necessarily consistent with the ordering of the same Name
objects in any other process.
Name
objects should be initialized once and then reused. Creating a Name
object from a const char*
involves a search in a container requiring multiple string comparison operations.
Note: Each Name
instance refers to an entry in a global static table. Name
instances for identical strings will refer to the same data. There is no provision for removing entries from the static table so Name
objects should be used only when the set of input strings is bounded.
For example, creating a Name
for every possible field name and type in a data model is reasonable (in fact, the API will do this whenever it receives schema information). Converting sequence numbers from incoming messages to strings and creating a Name
from each one of those strings, however, will cause the static table to grow in an unbounded manner, and is tantamount to a memory leak.
Name | ( | ) |
Name | ( | blpapi_Name_t * | handle | ) |
|
explicit |
Construct a Name
from the specified nameString
. The behavior is undefined unless nameString
is a null-terminated string. Note that any null-terminated string can be specified, including an empty string. Note also that constructing a Name
from a const char *
is a relatively expensive operation. If a Name
will be used repeatedly it is preferable to create it once and re-use (or copy) the object.
~Name | ( | ) |
Destroy this object.
|
static |
size_t hash | ( | ) | const |
Return an integral value such that for two Name
objects a
and b
, if a == b
then a.hash() == b.hash()
, and if a != b
then it is unlikely that a.hash() == b.hash()
.
|
static |
Return true
if a Name
has been created which matches the specified nameString
; otherwise return false
. The behavior is undefined if nameString
does not point to a null-terminated string.
blpapi_Name_t * impl | ( | ) | const |
size_t length | ( | ) | const |
Return the length of the string value of this Name
, (excluding a terminating null). Note that name.length()
is logically equivalent to strlen(name.string())
, however the former is potentially more efficient.
Assign to this object the value of the specified rhs
, and return a reference to this modifiable object.
const char * string | ( | ) | const |
Return a pointer to the null-terminated string value of this Name
. The pointer returned will be valid at least until main() exits.