Functions
PLMD::h36 Namespace Reference

Tiny namespace for hybrid36 format. More...

Functions

static const char * decode_pure (const int *digits_values, unsigned digits_size, const char *s, unsigned s_size, int *result)
 
static const char * digits_lower ()
 
static const char * digits_upper ()
 
static void encode_pure (const char *digits, unsigned digits_size, unsigned width, int value, char *result)
 
static void fill_with_stars (unsigned width, char *result)
 
const char * hy36decode (unsigned width, const char *s, unsigned s_size, int *result)
 
const char * hy36encode (unsigned width, int value, char *result)
 
static const char * invalid_number_literal ()
 
static const char * unsupported_width ()
 
static const char * value_out_of_range ()
 

Detailed Description

Tiny namespace for hybrid36 format.

This namespace includes freely available tools for h36 format.

Function Documentation

◆ decode_pure()

static const char* PLMD::h36::decode_pure ( const int *  digits_values,
unsigned  digits_size,
const char *  s,
unsigned  s_size,
int *  result 
)
static

◆ digits_lower()

static const char* PLMD::h36::digits_lower ( )
static

◆ digits_upper()

static const char* PLMD::h36::digits_upper ( )
static

C port of the hy36encode() and hy36decode() functions in the hybrid_36.py Python prototype/reference implementation. See the Python script for more information.

This file has no external dependencies, NOT even standard C headers. Optionally, use hybrid_36_c.h, or simply copy the declarations into your code.

This file is unrestricted Open Source (cctbx.sf.net). Please send corrections and enhancements to cctbx.nosp@m.@cci.nosp@m..lbl..nosp@m.gov .

See also: http://cci.lbl.gov/hybrid_36/

Ralf W. Grosse-Kunstleve, Feb 2007.

◆ encode_pure()

static void PLMD::h36::encode_pure ( const char *  digits,
unsigned  digits_size,
unsigned  width,
int  value,
char *  result 
)
static

◆ fill_with_stars()

static void PLMD::h36::fill_with_stars ( unsigned  width,
char *  result 
)
static

◆ hy36decode()

const char * PLMD::h36::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);

◆ hy36encode()

const char * PLMD::h36::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);

◆ invalid_number_literal()

static const char* PLMD::h36::invalid_number_literal ( )
static

◆ unsupported_width()

static const char* PLMD::h36::unsupported_width ( )
static

◆ value_out_of_range()

static const char* PLMD::h36::value_out_of_range ( )
static