(key_obj !=
NULL) {
86}
else if(key_obj !=
NULL) {
93 const char* ch_end =
key.data() +
key.length();
98 unsignedkey_version = (unsigned) atoi(ver_str);
105key_obj->
m_Id= (unsigned) atoi(id_str);
108 if(key_version == 1) {
110 const char*
consthostname = ch;
111 while(ch != ch_end && *ch !=
'_')
113 if(ch == ch_end || *ch !=
'_')
115 if(key_obj !=
NULL)
116key_obj->
m_Host.assign(hostname, ch - hostname);
121 if(key_obj !=
NULL) {
122key_obj->
m_Port= (
unsignedshort) atoi(port_str);
125}
else if(key_version == 3) {
128 if(key_obj !=
NULL) {
140 const char*
constrandom_str = ch;
141 while(ch != ch_end &&
isdigit(*ch))
144 if(key_obj !=
NULL) {
159 intunderscores_to_skip = 0;
165++underscores_to_skip;
168 if(++ch == ch_end || *ch !=
'_')
170 const char* ext_value = ++ch;
171 while(ch < ch_end && (*ch !=
'_'|| --underscores_to_skip >= 0))
173 if(key_obj !=
NULL)
180 while(ext_value < ch)
181 switch(*ext_value++) {
183 if(ext_value == ch ||
184*ext_value < 'a' || *ext_value >
'z')
188 if(ext_value == ch ||
189*ext_value < 'a' || *ext_value >
'z')
193}
while(ch < ch_end);
198 #ifndef NO_COMPOUND_ID_SUPPORT 199 if(id_pool !=
NULL) {
205 if(key_obj !=
NULL)
211 if(key_obj !=
NULL)
212key_obj->
m_Id= (unsigned) field.
GetID();
217 if(key_obj !=
NULL)
221 if(key_obj !=
NULL)
224 if(key_obj !=
NULL) {
232 if(key_obj !=
NULL)
237 if(key_obj !=
NULL)
240 if(key_obj !=
NULL) {
275 const string& service_name)
277 autoc = 1 +
count(service_name.begin(), service_name.end(),
'_');
278blob_id.append(c,
'_');
279blob_id.append(
"S_", 2);
280blob_id.append(service_name);
291blob_id.append(
"_F_", 3);
293blob_id.insert(0, 1,
'/');
294blob_id.insert(0, service_name);
301blob_id.append(1,
'1');
303blob_id.append(1,
'N');
309 Assign(key_str, id_pool);
317 if(!
ParseBlobKey(key_str.c_str(), key_str.size(),
this, id_pool)) {
319 "Invalid blob key format: '"<<
326 stringserver_address(host);
327server_address.append(1,
':');
330 crc32.AddChars(server_address.data(), server_address.size());
331 return crc32.GetChecksum();
340 unsigned intrnd_num,
341time_t creation_time)
350 key->append(1,
'_');
354 key->append(1,
'_');
361 key->append(1,
'_');
366 key->append(1,
'_');
368(
Uint8) (creation_time ? creation_time : ::time(
NULL)));
371 key->append(1,
'_');
376 #ifndef NO_COMPOUND_ID_SUPPORT 386 stringhost(key_obj.
GetHost());
Checksum and hash calculation classes.
CChecksum â Checksum calculator.
Exception class for use by CCompoundIDPool, CCompoundID, and CCompoundIDField.
Compound ID field â an element of the compound ID that has a type and a value.
Uint4 GetRandom() const
Return the random number value that this field contains.
Uint2 GetPort() const
Return the network port number that this field contains.
Uint4 GetIPv4Address() const
Return the 32-bit IP address that this field contains.
string GetServiceName() const
Return the LBSM service name that this field contains.
string GetHost() const
Return the host name or address that this field contains.
Int8 GetTimestamp() const
Return the UNIX timestamp that this field contains.
Uint8 GetID() const
Return the ID value that this field contains.
Uint8 GetFlags() const
Return the combination of binary flags stored in this field.
Pool of recycled CCompoundID objects.
CCompoundID NewID(ECompoundIDClass new_id_class)
Create and return a new CCompoundID objects.
CCompoundID FromString(const string &cid)
Unpack the base64-encoded ID and return a CCompoundID object for field extraction.
Base64-encoded ID string that contains extractable typed fields.
void AppendRandom(Uint4 random_number)
Append an eCIT_Random field at the end of this compound ID.
CCompoundIDField GetFirst(ECompoundIDFieldType field_type)
Return the first field of the specified type or NULL if this compound ID contains no fields of such t...
string ToString()
Pack the ID and return its string representation.
void AppendTimestamp(Int8 timestamp)
Append an eCIT_Timestamp field at the end of this compound ID.
void AppendID(Uint8 id)
Append an eCIT_ID field at the end of this compound ID.
void AppendIPv4SockAddr(Uint4 ipv4_address, Uint2 port_number)
Append an eCIT_IPv4SockAddr field at the end of this compound ID.
void AppendPort(Uint2 port_number)
Append an eCIT_Port field at the end of this compound ID.
void AppendFlags(Uint8 flags)
Append an eCIT_Flags field at the end of this compound ID.
void AppendHost(const string &host)
Append an eCIT_Host field at the end of this compound ID.
ECompoundIDClass GetClass() const
One of the registered ID classes.
void AppendServiceName(const string &service_name)
Append an eCIT_ServiceName field at the end of this compound ID.
NetCache internal exception.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
The NCBI C++ standard methods for dealing with std::string.
#define NCBI_THROW_FMT(exception_class, err_code, message)
The same as NCBI_THROW but with message processed as output to ostream.
void Assign(const string &key_str, CCompoundIDPool::TInstance id_pool=NULL)
Parse the specified blob ID and initializes this object.
static Uint4 CalculateChecksum(const string &host, unsigned short port)
Calculate and return the CRC32 checksum generated from the string "host:port".
static void GenerateBlobKey(string *key, unsigned int id, const string &host, unsigned short port, unsigned int ver, unsigned int rnd_num, time_t creation_time=0)
Generate blob key string.
void SetFlag(ENCKeyFlag flag)
static string KeyToCompoundID(const string &key_str, CCompoundIDPool id_pool)
unsigned TNCKeyFlags
Binary OR of ENCKeyFlag.
static bool ParseBlobKey(const char *key_str, size_t key_len, CNetCacheKey *key_obj, CCompoundIDPool::TInstance id_pool=NULL)
Parse blob key string into a CNetCacheKey structure.
CNetCacheKey()
Create an empty object for later use with ParseBlobKey() or Assign().
unsigned short m_Port
TCP/IP port number.
unsigned short GetPort() const
Uint4 GetRandomPart() const
unsigned m_HostPortCRC32
CRC32 checksum of the host:port combination.
unsigned m_Version
Key version.
string m_Host
server name
TNCKeyFlags GetFlags() const
const string & GetHost() const
time_t GetCreationTime() const
const string & GetServiceName() const
static unsigned int GetBlobId(const string &key_str)
Parse blob key, extract id.
unsigned int m_Id
BLOB id.
static void AddExtensions(string &blob_id, const string &service_name, TNCKeyFlags flags, unsigned ver=1)
Unconditionally append a service name to the specified string.
@ fNCKey_NoServerCheck
Disable the check for whether the server IP is still in service.
@ fNCKey_SingleServer
Mark this blob as not mirrored.
uint32_t Uint4
4-byte (32-bit) unsigned integer
uint64_t Uint8
8-byte (64-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static CNCBI_IPAddr gethostbyname(const string &host, ESwitch log=eOff)
Return 0 or empty address on error.
static bool isip(const string &host, bool fullquad=false)
For IPv4 only.
static string ntoa(const CNCBI_IPAddr &addr)
BSD-like API.
static string PrintableString(const CTempString str, TPrintableMode mode=fNewLine_Quote|fNonAscii_Passthru)
Get a printable version of the specified string.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)
Convert UInt to string.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
static bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
static string UInt8ToString(Uint8 value, TNumToStringFlags flags=0, int base=10)
Convert UInt8 to string.
unsigned int
A callback function used to compare two keys in a database.
const struct ncbi::grid::netcache::search::fields::KEY key
Multi-threading â mutexes; rw-locks; semaphore.
NetCache API exception declarations.
#define KEY_PREFIX_LENGTH
#define PARSE_NUMERIC_KEY_PART(part_name)
#define KEY_EXTENSION_MARKER_LENGTH
#define PARSE_KEY_PART(part_name, test_function)
static void AppendServiceNameExtension(string &blob_id, const string &service_name)
static const CTempString s_KeyPrefix("NCID_",(sizeof("NCID_") - 1))
#define KEY_EXTENSION_MARKER
Meaningful information encoded in the NetCache key.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4