A non-owning string parameter: a pointer to characters and their count.
It is a parameter only: it must not be stored, returned or kept after the call it is passed to, because it does not own the characters. A temporary (a std::string, a std::vector<char>) lives until the end of the full expression of the call, which is enough for a parameter.
The name dxfcpp::StringParam is part of the API: it is spelled in the signatures of the functions that take a string, including the virtual functions that users override.
Accepted: a literal, a char array, const char * and char *, std::string, std::string_view, and contiguous ranges of char (std::vector<char>, std::array<char, N>, std::span<const char>, std::span<char>). Not accepted: numbers, bool, std::optional, wide and UTF-8 strings, ranges of other types, and types that only convert to std::string by their own operator.
Rules of the length:
- A char array (a literal, a buffer) ends at the first NUL within the array, or at the array's end when there is none: char buf[8] = "ab" is "ab", char full[3] = {'a', 'b', 'c'} is "abc" (nothing is read past the array).
- A std::array<char, N> is a range, not a C array: it keeps its trailing NULs.
- A null pointer is an empty string.
- A std::string, a std::string_view and a range keep their whole size, including embedded NULs; the type never truncates. The boundary with the dxFeed Graal SDK reads the characters up to the first NUL.
Encoding: a string that goes to the dxFeed Graal SDK must be valid UTF-8. A byte that cannot start a sequence, a truncated sequence, an overlong form, an encoded surrogate or a value above U+10FFFF make the function throw InvalidArgumentException, for example DXEndpoint::connect(address): invalid UTF-8 at byte 12: 0xC3 0x28: the function and its parameter, the offset of the first invalid byte from 0 and the bytes of the invalid sequence. For a user name, a password or a token, the message has no bytes. The string fields of events are checked when the events are published, not by their setters, and the message names the event type and the field (TimeAndSale::exchangeSaleConditions: invalid UTF-8 at byte 1: 0xFF); symbols are checked when they are added to a subscription (StringSymbol(symbol): ...).
Passing a bare nullptr to a function that has another overload with a smart pointer parameter is ambiguous (for example Schedule::getInstance): write static_cast<const char *>(nullptr).
data() is not guaranteed to be NUL-terminated. There is no implicit conversion to std::string or std::string_view; use view().