00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #pragma once
00023
00024 #include "client_priv.h"
00025 #include <iosfwd>
00026 #include <string>
00027 #include <cstdlib>
00028 #include <drizzled/gettext.h>
00029
00030 class OptionString
00031 {
00032 public:
00033 OptionString(char *in_string,
00034 size_t in_length,
00035 char *in_option,
00036 size_t in_option_length,
00037 OptionString *in_next) :
00038 string(in_string),
00039 length(in_length),
00040 option(in_option),
00041 option_length(in_option_length),
00042 next(in_next)
00043 { }
00044
00045 OptionString() :
00046 string(NULL),
00047 length(0),
00048 option(NULL),
00049 option_length(0),
00050 next(NULL)
00051 { }
00052
00053 ~OptionString()
00054 {
00055 if (getString())
00056 free(getString());
00057 if (getOption())
00058 free(getOption());
00059 }
00060
00061 char *getString() const
00062 {
00063 return string;
00064 }
00065
00066 size_t getLength() const
00067 {
00068 return length;
00069 }
00070
00071 char *getOption() const
00072 {
00073 return option;
00074 }
00075
00076 size_t getOptionLength() const
00077 {
00078 return option_length;
00079 }
00080
00081 OptionString *getNext() const
00082 {
00083 return next;
00084 }
00085
00086 void setString(char *in_string)
00087 {
00088 string= in_string;
00089 length= strlen(in_string);
00090 }
00091
00092 void setOption(char *in_option)
00093 {
00094 option= strdup(in_option);
00095 option_length= strlen(in_option);
00096 }
00097
00098 void setNext(OptionString *in_next)
00099 {
00100 next= in_next;
00101 }
00102
00103 private:
00104 char *string;
00105 size_t length;
00106 char *option;
00107 size_t option_length;
00108 OptionString *next;
00109 };