Eneboo - Documentación para desarrolladores
src/libpq/include/utils/varbit.h
Ir a la documentación de este archivo.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * varbit.h
00004  *        Functions for the SQL datatypes BIT() and BIT VARYING().
00005  *
00006  * Code originally contributed by Adriaan Joubert.
00007  *
00008  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
00009  * Portions Copyright (c) 1994, Regents of the University of California
00010  *
00011  * $PostgreSQL: pgsql/src/include/utils/varbit.h,v 1.21 2004/12/31 22:03:46 pgsql Exp $
00012  *
00013  *-------------------------------------------------------------------------
00014  */
00015 #ifndef VARBIT_H
00016 #define VARBIT_H
00017 
00018 #include "fmgr.h"
00019 
00020 /*
00021  * Modeled on struct varlena from postgres.h, but data type is bits8.
00022  */
00023 typedef struct
00024 {
00025         int32           vl_len;                 /* standard varlena header (total size in
00026                                                                  * bytes) */
00027         int32           bit_len;                /* number of valid bits */
00028         bits8           bit_dat[1];             /* bit string, most sig. byte first */
00029 } VarBit;
00030 
00031 /*
00032  * fmgr interface macros
00033  *
00034  * BIT and BIT VARYING are toastable varlena types.  They are the same
00035  * as far as representation goes, so we just have one set of macros.
00036  */
00037 #define DatumGetVarBitP(X)                 ((VarBit *) PG_DETOAST_DATUM(X))
00038 #define DatumGetVarBitPCopy(X)     ((VarBit *) PG_DETOAST_DATUM_COPY(X))
00039 #define VarBitPGetDatum(X)                 PointerGetDatum(X)
00040 #define PG_GETARG_VARBIT_P(n)      DatumGetVarBitP(PG_GETARG_DATUM(n))
00041 #define PG_GETARG_VARBIT_P_COPY(n) DatumGetVarBitPCopy(PG_GETARG_DATUM(n))
00042 #define PG_RETURN_VARBIT_P(x)      return VarBitPGetDatum(x)
00043 
00044 /* Header overhead *in addition to* VARHDRSZ */
00045 #define VARBITHDRSZ                     sizeof(int32)
00046 /* Number of bits in this bit string */
00047 #define VARBITLEN(PTR)          (((VarBit *) (PTR))->bit_len)
00048 /* Pointer to the first byte containing bit string data */
00049 #define VARBITS(PTR)            (((VarBit *) (PTR))->bit_dat)
00050 /* Number of bytes in the data section of a bit string */
00051 #define VARBITBYTES(PTR)        (VARSIZE(PTR) - VARHDRSZ - VARBITHDRSZ)
00052 /* Padding of the bit string at the end (in bits) */
00053 #define VARBITPAD(PTR)          (VARBITBYTES(PTR)*BITS_PER_BYTE - VARBITLEN(PTR))
00054 /* Number of bytes needed to store a bit string of a given length */
00055 #define VARBITTOTALLEN(BITLEN)  (((BITLEN) + BITS_PER_BYTE-1)/BITS_PER_BYTE + \
00056                                                                  VARHDRSZ + VARBITHDRSZ)
00057 /* pointer beyond the end of the bit string (like end() in STL containers) */
00058 #define VARBITEND(PTR)          (((bits8 *) (PTR)) + VARSIZE(PTR))
00059 /* Mask that will cover exactly one byte, i.e. BITS_PER_BYTE bits */
00060 #define BITMASK 0xFF
00061 #define BITHIGH 0x80
00062 
00063 
00064 extern Datum bit_in(PG_FUNCTION_ARGS);
00065 extern Datum bit_out(PG_FUNCTION_ARGS);
00066 extern Datum bit_recv(PG_FUNCTION_ARGS);
00067 extern Datum bit_send(PG_FUNCTION_ARGS);
00068 extern Datum varbit_in(PG_FUNCTION_ARGS);
00069 extern Datum varbit_out(PG_FUNCTION_ARGS);
00070 extern Datum varbit_recv(PG_FUNCTION_ARGS);
00071 extern Datum varbit_send(PG_FUNCTION_ARGS);
00072 extern Datum bit(PG_FUNCTION_ARGS);
00073 extern Datum varbit(PG_FUNCTION_ARGS);
00074 extern Datum biteq(PG_FUNCTION_ARGS);
00075 extern Datum bitne(PG_FUNCTION_ARGS);
00076 extern Datum bitlt(PG_FUNCTION_ARGS);
00077 extern Datum bitle(PG_FUNCTION_ARGS);
00078 extern Datum bitgt(PG_FUNCTION_ARGS);
00079 extern Datum bitge(PG_FUNCTION_ARGS);
00080 extern Datum bitcmp(PG_FUNCTION_ARGS);
00081 extern Datum bitand(PG_FUNCTION_ARGS);
00082 extern Datum bitor(PG_FUNCTION_ARGS);
00083 extern Datum bitxor(PG_FUNCTION_ARGS);
00084 extern Datum bitnot(PG_FUNCTION_ARGS);
00085 extern Datum bitshiftleft(PG_FUNCTION_ARGS);
00086 extern Datum bitshiftright(PG_FUNCTION_ARGS);
00087 extern Datum bitcat(PG_FUNCTION_ARGS);
00088 extern Datum bitsubstr(PG_FUNCTION_ARGS);
00089 extern Datum bitlength(PG_FUNCTION_ARGS);
00090 extern Datum bitoctetlength(PG_FUNCTION_ARGS);
00091 extern Datum bitfromint4(PG_FUNCTION_ARGS);
00092 extern Datum bittoint4(PG_FUNCTION_ARGS);
00093 extern Datum bitfromint8(PG_FUNCTION_ARGS);
00094 extern Datum bittoint8(PG_FUNCTION_ARGS);
00095 extern Datum bitposition(PG_FUNCTION_ARGS);
00096 
00097 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'