Drizzled Public API Documentation

option_string.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 Vijay Samuel
00005  *  Copyright (C) 2008 MySQL
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020  */
00021 
00022 #ifndef CLIENT_OPTION_STRING_H
00023 #define CLIENT_OPTION_STRING_H
00024 
00025 #include "client_priv.h"
00026 #include <iostream>
00027 #include <string>
00028 #include <cstdlib>
00029 #include <drizzled/gettext.h>
00030 
00031 class OptionString 
00032 {
00033 public:
00034   OptionString(char *in_string,
00035                size_t in_length,
00036                char *in_option,
00037                size_t in_option_length,
00038                OptionString *in_next) :
00039     string(in_string),
00040     length(in_length),
00041     option(in_option),
00042     option_length(in_option_length),
00043     next(in_next)
00044   { }  
00045 
00046   OptionString() :
00047     string(NULL),
00048     length(0),
00049     option(NULL),
00050     option_length(0),
00051     next(NULL)
00052   { }
00053 
00054   ~OptionString()
00055   {
00056     if (getString())
00057       free(getString());
00058     if (getOption())
00059       free(getOption());
00060   }
00061 
00062   char *getString() const
00063   {
00064     return string;
00065   }
00066 
00067   size_t getLength() const
00068   {
00069     return length;
00070   }
00071 
00072   char *getOption() const
00073   {
00074   return option;
00075   }
00076 
00077   size_t getOptionLength() const
00078   {
00079     return option_length;
00080   }
00081 
00082   OptionString *getNext() const
00083   {
00084     return next;
00085   }
00086 
00087   void setString(char *in_string)
00088   {
00089     string= in_string;
00090     length= strlen(in_string);
00091   }
00092 
00093   void setOption(char *in_option)
00094   {
00095     option= strdup(in_option);
00096     option_length= strlen(in_option);
00097   }
00098 
00099   void setNext(OptionString *in_next)
00100   {
00101     next= in_next;
00102   }
00103   
00104 private:
00105   char *string;
00106   size_t length;
00107   char *option;
00108   size_t option_length;
00109   OptionString *next;
00110 };
00111 
00112 #endif /* CLIENT_OPTION_STRING_H */