Drizzled Public API Documentation

uuid.h
00001 /* - mode: c++ c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2010 Brian Aker
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #pragma once
00022 
00023 #include <drizzled/field.h>
00024 #include <string>
00025 
00026 #include <drizzled/type/uuid.h>
00027 
00028 namespace drizzled
00029 {
00030 namespace field
00031 {
00032 
00033 class Uuid :public Field {
00034   const charset_info_st *field_charset;
00035   bool is_set;
00036 
00037 public:
00038   Uuid(unsigned char *ptr_arg,
00039        uint32_t len_arg,
00040        unsigned char *null_ptr_arg,
00041        unsigned char null_bit_arg,
00042        const char *field_name_arg);
00043 
00044   enum_field_types type() const { return DRIZZLE_TYPE_UUID; }
00045   enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
00046   bool zero_pack() const { return 0; }
00047   int  reset(void) { memset(ptr, 0, type::Uuid::LENGTH); return 0; }
00048   uint32_t pack_length() const { return type::Uuid::LENGTH; }
00049   uint32_t key_length() const { return type::Uuid::LENGTH; }
00050 
00051   int store(const char *to, uint32_t length, const charset_info_st * const charset);
00052   int store(int64_t nr, bool unsigned_val);
00053   double val_real() const;
00054   int64_t val_int() const;
00055   String *val_str(String*,String *) const;
00056   int store_decimal(const drizzled::type::Decimal*);
00057 
00058   Item_result result_type () const { return STRING_RESULT; }
00059   int cmp(const unsigned char*, const unsigned char*);
00060   void sort_string(unsigned char*, uint32_t);
00061   uint32_t max_display_length() { return type::Uuid::DISPLAY_LENGTH; }
00062 
00063   int  store(double ) { return 0; }
00064   inline String *val_str(String *str) { return val_str(str, str); }
00065   uint32_t size_of() const { return sizeof(*this); }
00066 
00067   bool get_date(type::Time &ltime, uint32_t) const;
00068   bool get_time(type::Time &ltime) const;
00069 
00070 #ifdef NOT_YET
00071   void generate();
00072   void set(const unsigned char *arg);
00073 #endif
00074 
00075   static size_t max_string_length()
00076   {
00077     return type::Uuid::LENGTH;
00078   }
00079 };
00080 
00081 } /* namespace field */
00082 } /* namespace drizzled */
00083 
00084