MySQL  8.0.18
Source Code Documentation
typelib.h File Reference
#include "my_inttypes.h"

Go to the source code of this file.

Classes

struct  TYPELIB
 

Macros

#define FIND_TYPE_BASIC   0
 
#define FIND_TYPE_NO_PREFIX   (1 << 0)
 makes find_type() require the whole name, no prefix More...
 
#define FIND_TYPE_NO_OVERWRITE   (1 << 1)
 always implicitely on, so unused, but old code may pass it More...
 
#define FIND_TYPE_ALLOW_NUMBER   (1 << 2)
 makes find_type() accept a number More...
 
#define FIND_TYPE_COMMA_TERM   (1 << 3)
 makes find_type() treat ',' as terminator More...
 

Functions

uint64_t find_typeset (const char *x, TYPELIB *typelib, int *error_position)
 Create an integer value to represent the supplied comma-seperated string where each string in the TYPELIB denotes a bit position. More...
 
int find_type_or_exit (const char *x, TYPELIB *typelib, const char *option)
 
int find_type (const char *x, const TYPELIB *typelib, unsigned int flags)
 Search after a string in a list of strings. More...
 
void make_type (char *to, unsigned int nr, TYPELIB *typelib)
 Get name of type nr. More...
 
const char * get_type (TYPELIB *typelib, unsigned int nr)
 Get type. More...
 
TYPELIBcopy_typelib (MEM_ROOT *root, TYPELIB *from)
 Create a copy of a specified TYPELIB structure. More...
 
uint64_t find_set_from_flags (const TYPELIB *lib, size_t default_name, uint64_t cur_set, uint64_t default_set, const char *str, unsigned int length, const char **err_pos, unsigned int *err_len)
 Parse and apply a set of flag assingments. More...
 

Variables

TYPELIB sql_protocol_typelib
 

Macro Definition Documentation

◆ FIND_TYPE_ALLOW_NUMBER

#define FIND_TYPE_ALLOW_NUMBER   (1 << 2)

makes find_type() accept a number

◆ FIND_TYPE_BASIC

#define FIND_TYPE_BASIC   0

◆ FIND_TYPE_COMMA_TERM

#define FIND_TYPE_COMMA_TERM   (1 << 3)

makes find_type() treat ',' as terminator

◆ FIND_TYPE_NO_OVERWRITE

#define FIND_TYPE_NO_OVERWRITE   (1 << 1)

always implicitely on, so unused, but old code may pass it

◆ FIND_TYPE_NO_PREFIX

#define FIND_TYPE_NO_PREFIX   (1 << 0)

makes find_type() require the whole name, no prefix

Function Documentation

◆ copy_typelib()

TYPELIB* copy_typelib ( MEM_ROOT root,
TYPELIB from 
)

Create a copy of a specified TYPELIB structure.

Parameters
rootpointer to a MEM_ROOT object for allocations
frompointer to a source TYPELIB structure
Return values
pointerto the new TYPELIB structure on successful copy
NULLotherwise

◆ find_set_from_flags()

uint64_t find_set_from_flags ( const TYPELIB lib,
size_t  default_name,
uint64_t  cur_set,
uint64_t  default_set,
const char *  str,
uint  length,
const char **  err_pos,
uint err_len 
)

Parse and apply a set of flag assingments.

Parameters
libFlag names
default_nameNumber of "default" in the typelib
cur_setCurrent set of flags (start from this state)
default_setDefault set of flags (use this for assign-default keyword and flag=default assignments)
strString to be parsed
lengthLength of the string
err_posOUT If error, set to point to start of wrong set string NULL on success
err_lenOUT If error, set to the length of wrong set string

Parse a set of flag assignments, that is, parse a string in form:

param_name1=value1,param_name2=value2,...

where the names are specified in the TYPELIB, and each value can be either 'on','off', or 'default'. Setting the same name twice is not allowed.

Besides param=val assignments, we support the "default" keyword (keyword default_name in the typelib). It can be used one time, if specified it causes us to build the new set over the default_set rather than cur_set value.

Note
it's not charset aware
Return values
Parsedset value if (*errpos == NULL), otherwise undefined

◆ find_type()

int find_type ( const char *  x,
const TYPELIB typelib,
uint  flags 
)

Search after a string in a list of strings.

Endspace in x is not compared.

Parameters
xString to find
typelibTYPELIB (struct of pointer to values + count)
flagsflags to tune behaviour: a combination of FIND_TYPE_NO_PREFIX FIND_TYPE_ALLOW_NUMBER FIND_TYPE_COMMA_TERM. FIND_TYPE_NO_OVERWRITE can be passed but is superfluous (is always implicitely on).
Return values
-1Too many matching values
0No matching value
>0Offset+1 in typelib for matched string

◆ find_type_or_exit()

int find_type_or_exit ( const char *  x,
TYPELIB typelib,
const char *  option 
)

◆ find_typeset()

uint64_t find_typeset ( const char *  x,
TYPELIB lib,
int *  err 
)

Create an integer value to represent the supplied comma-seperated string where each string in the TYPELIB denotes a bit position.

Parameters
xstring to decompose
libTYPELIB (struct of pointer to values + count)
errindex (not char position) of string element which was not found or 0 if there was no error
Return values
ainteger representation of the supplied string

◆ get_type()

const char* get_type ( TYPELIB typelib,
uint  nr 
)

Get type.

Note
first type is 0

◆ make_type()

void make_type ( char *  to,
uint  nr,
TYPELIB typelib 
)

Get name of type nr.

Note
first type is 1, 0 = empty field

Variable Documentation

◆ sql_protocol_typelib

TYPELIB sql_protocol_typelib