BLPAPI C++  3.24.6
Name Class Reference

#include <blpapi_name.h>

Public Member Functions

 Name ()
 
 Name (blpapi_Name_t *handle)
 
 Name (const Name &original)
 
 Name (const char *nameString)
 
 ~Name ()
 
Nameoperator= (const Name &rhs)
 
const char * string () const
 
size_t length () const
 
size_t hash () const
 
blpapi_Name_timpl () const
 

Static Public Member Functions

static Name findName (const char *nameString)
 
static bool hasName (const char *nameString)
 

Detailed Description

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.

See Component blpapi_name

Constructor & Destructor Documentation

◆ Name() [1/4]

Name ( )

Construct an uninitialized Name. An uninitialized Name can be assigned to, destroyed, or tested for equality. The behavior for all other operations is undefined.

◆ Name() [2/4]

Name ( blpapi_Name_t handle)
explicit

◆ Name() [3/4]

Name ( const Name original)

Create a Name object having the same value as the specified original.

◆ Name() [4/4]

Name ( const char *  nameString)
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()

~Name ( )

Destroy this object.

Member Function Documentation

◆ findName()

Name findName ( const char *  nameString)
static

If a Name already exists which matches the specified nameString, then return a copy of that Name; otherwise return a Name which will compare equal to a Name created using the default constructor. The behavior is undefined if nameString does not point to a null-terminated string.

◆ hash()

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().

◆ hasName()

bool hasName ( const char *  nameString)
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.

◆ impl()

blpapi_Name_t * impl ( ) const

◆ length()

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.

◆ operator=()

Name & operator= ( const Name rhs)

Assign to this object the value of the specified rhs, and return a reference to this modifiable object.

◆ string()

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.


The documentation for this class was generated from the following file: