Functions

src/hybrid_36.h File Reference

Go to the source code of this file.

Functions

const char * hy36encode (unsigned width, int value, char *result)
 hybrid-36 encoder: converts integer value to string result
const char * hy36decode (unsigned width, const char *s, unsigned s_size, int *result)
 hybrid-36 decoder: converts string s to integer result

Function Documentation

const char* hy36decode ( unsigned  width,
const char *  s,
unsigned  s_size,
int *  result 
)

hybrid-36 decoder: converts string s to integer result

width: must be 4 (e.g. for residue sequence numbers) or 5 (e.g. for atom serial numbers)

s: string to be converted does not have to be null-terminated

s_size: size of s must be equal to width, or an error message is returned otherwise

result: integer holding the conversion result

return value: pointer to error message, if any, or 0 on success

Example usage (from C++): int result; const char* errmsg = hy36decode(width, "A1T5", 4, &result); if (errmsg) throw std::runtime_error(errmsg);

const char* hy36encode ( unsigned  width,
int  value,
char *  result 
)

hybrid-36 encoder: converts integer value to string result

width: must be 4 (e.g. for residue sequence numbers) or 5 (e.g. for atom serial numbers)

value: integer value to be converted

result: pointer to char array of size width+1 or greater on return result is null-terminated

return value: pointer to error message, if any, or 0 on success

Example usage (from C++): char result[4+1]; const char* errmsg = hy36encode(4, 12345, result); if (errmsg) throw std::runtime_error(errmsg);

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines