00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <config.h>
00018
00019 #include <drizzled/typelib.h>
00020 #include <drizzled/charset.h>
00021
00022 namespace drizzled {
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 uint32_t TYPELIB::find_type(const char *find, uint32_t length, bool part_match) const
00041 {
00042 uint32_t found_count=0, found_pos=0;
00043 const char* end= find + length;
00044 const char* i;
00045 const char* j;
00046 for (uint32_t pos= 0 ; (j= type_names[pos++]); )
00047 {
00048 for (i= find ; i != end && system_charset_info->toupper(*i) == system_charset_info->toupper(*j); i++, j++)
00049 {
00050 }
00051 if (i == end)
00052 {
00053 if (not *j)
00054 return pos;
00055 found_count++;
00056 found_pos= pos;
00057 }
00058 }
00059 return found_count == 1 && part_match ? found_pos : 0;
00060 }
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080 uint32_t TYPELIB::find_type2(const char *x, uint32_t length, const charset_info_st *cs) const
00081 {
00082 if (!count)
00083 return 0;
00084 const char *j;
00085 for (int pos=0 ; (j= type_names[pos]) ; pos++)
00086 {
00087 if (!my_strnncoll(cs, (const unsigned char*) x, length,
00088 (const unsigned char*) j, type_lengths[pos]))
00089 return pos + 1;
00090 }
00091 return 0;
00092 }
00093
00094 }