lexify.h

00001 /*<std-header orig-src='shore' incl-file-exclusion='LEXIFY_H'>
00002 
00003  $Id: lexify.h,v 1.17 2010/06/08 22:28:55 nhall Exp $
00004 
00005 SHORE -- Scalable Heterogeneous Object REpository
00006 
00007 Copyright (c) 1994-99 Computer Sciences Department, University of
00008                       Wisconsin -- Madison
00009 All Rights Reserved.
00010 
00011 Permission to use, copy, modify and distribute this software and its
00012 documentation is hereby granted, provided that both the copyright
00013 notice and this permission notice appear in all copies of the
00014 software, derivative works or modified versions, and any portions
00015 thereof, and that both notices appear in supporting documentation.
00016 
00017 THE AUTHORS AND THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY
00018 OF WISCONSIN - MADISON ALLOW FREE USE OF THIS SOFTWARE IN ITS
00019 "AS IS" CONDITION, AND THEY DISCLAIM ANY LIABILITY OF ANY KIND
00020 FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
00021 
00022 This software was developed with support by the Advanced Research
00023 Project Agency, ARPA order number 018 (formerly 8230), monitored by
00024 the U.S. Army Research Laboratory under contract DAAB07-91-C-Q518.
00025 Further funding for this work was provided by DARPA through
00026 Rome Research Laboratory Contract No. F30602-97-2-0247.
00027 
00028 */
00029 
00030 #ifndef LEXIFY_H
00031 #define LEXIFY_H
00032 
00033 #include "w_defines.h"
00034 
00035 /*  -- do not edit anything above this line --   </std-header>*/
00036 
00037 /* Routines for translating integers and floating point numbers
00038  * into a form that allows lexicographic
00039  * comparison in an architecturally-neutral form.
00040  *
00041  * Original work for IEEE double-precision values by
00042  *     Marvin Solomon (solomon@cs.wisc.edu) Feb, 1997.
00043  * Extended for integer and IEEE single-precision values by
00044  *     Nancy Hall Feb, 1997.
00045  *
00046  */
00047 
00048 #ifdef __GNUG__
00049 #   pragma interface 
00050 #endif
00051 
00052 namespace ssm_sort {
00053     class sort_keys_t; // forward
00054 }
00055 
00056 /**\brief Class containing basic types used by sort 
00057  * and by B+-Tree key-management. 
00058  */
00059 class sortorder : private smlevel_0 {
00060     friend class ssm_sort::sort_keys_t;
00061     typedef w_base_t::f4_t f4_t;
00062     typedef w_base_t::f8_t f8_t;
00063 
00064     typedef w_base_t::uint1_t uint1_t;
00065     typedef w_base_t::uint2_t uint2_t;
00066     typedef w_base_t::uint4_t uint4_t;
00067     typedef w_base_t::uint8_t uint8_t;
00068 
00069     typedef w_base_t::int1_t int1_t;
00070     typedef w_base_t::int2_t int2_t;
00071     typedef w_base_t::int4_t int4_t;
00072     typedef w_base_t::int8_t int8_t;
00073 public:
00074     /**\enum keytype 
00075      *\brief Enumerator that describes the basic fixed-length and 
00076      * variable-length
00077      * (sub-)key types that are used in B+-Trees and 
00078      * can be used in sorting.
00079      * \details
00080      * - kt_i1 signed 1-byte integer values
00081      * - kt_u1 unsigned 1-byte integer values
00082      * - kt_i2 signed 2-byte integer values 
00083      * - kt_u2 unsigned 2-byte integer values 
00084      * - kt_i4 signed 4-byte integer values 
00085      * - kt_u4 unsigned 4-byte integer values 
00086      * - kt_f4 IEEE single precision floating point values 
00087      * - kt_f8 IEEE double precision floating point values 
00088      * - kt_b unsigned byte string 
00089      */
00090     enum keytype {
00091         kt_nosuch,
00092         /* signed, unsigned 1-byte integer values */
00093         kt_i1, kt_u1, 
00094         /* signed, unsigned 2-byte integer values */
00095         kt_i2, kt_u2, 
00096         /* signed, unsigned 4-byte integer values */
00097         kt_i4, kt_u4, 
00098         /* signed, unsigned 64-bit integer values */
00099         kt_i8, kt_u8,
00100         /* IEEE single, double precision floating point values */
00101         kt_f4, kt_f8, 
00102         /* unsigned byte string */
00103         kt_b,
00104         /* not used here */
00105         kt_spatial 
00106     };
00107 
00108     NORET sortorder();
00109     NORET ~sortorder();
00110 
00111     /**\brief Convert to lexicographic form.
00112      * @param[in] kp    Describes the type and length
00113      *                  of the string to be converted.
00114      * @param[in] d     The string to be converted.
00115      * @param[out] res  The result.
00116      *
00117      * Invokes a predefined LEXFUNC for the know keytype.
00118      * Returns true if it worked, false otherwise.
00119      *
00120      */
00121     bool lexify(const key_type_s *kp, const void *d, void *res); 
00122 
00123     /**\brief Convert from lexicographic form.
00124      * @param[in] kp    Describes the type and length
00125      *                  of the string to be converted.
00126      * @param[in] str     The string in lexicographic form to be converted.
00127      * @param[out] res  The result.
00128      *
00129      * Invokes a predefined inverse LEXFUNC for the known keytype.
00130      * Returns true if it worked, false otherwise
00131      */
00132     bool unlexify(const key_type_s *kp, const void *str, void *res) ;
00133 
00134 private:
00135     void int_lexify( const void *d, bool is_signed, int len, 
00136         void *res, int perm[]);
00137     void int_unlexify( const void *str, bool is_signed, int len, 
00138         void *res, int perm[]);
00139 
00140 public: 
00141     /**\cond skip */
00142     void float_lexify(w_base_t::f4_t d, void *res, int perm[]) ;
00143     void float_unlexify( const void *str, int perm[], w_base_t::f4_t *result); 
00144     void dbl_lexify(w_base_t::f8_t d, void *res, int perm[]) ;
00145     void dbl_unlexify( const void *str, int perm[], w_base_t::f8_t *result);
00146 
00147     void Ibyteorder(int permutation[8]) ;
00148     void Ibyteorder(int *permutation, int size);
00149     void Fbyteorder(int permutation[4]) ;
00150     void Dbyteorder(int permutation[8]) ;
00151 
00152     /**\endcond skip */
00153     /**\brief Convert from a key_type_s to a keytype enumerator value */
00154     static keytype convert(const key_type_s *k);
00155 
00156 private:
00157     int I1perm[1];
00158     int I2perm[2];
00159     int I4perm[4];
00160     int I8perm[8];
00161     int Fperm[4];
00162     int Dperm[8];
00163 };
00164 
00165 extern class sortorder SortOrder;
00166 
00167 /*<std-footer incl-file-exclusion='LEXIFY_H'>  -- do not edit anything below this line -- */
00168 
00169 #endif          /*</std-footer>*/

Generated on Wed Jul 7 17:22:32 2010 for Shore Storage Manager by  doxygen 1.4.7