~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/option_string.h

  • Committer: Daniel Nichter
  • Date: 2011-10-23 16:01:37 UTC
  • mto: This revision was merged to the branch mainline in revision 2448.
  • Revision ID: daniel@percona.com-20111023160137-7ac3blgz8z4tf8za
Add Administration Getting Started and Logging.  Capitalize SQL clause keywords.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2010 Vijay Samuel
 
5
 *  Copyright (C) 2008 MySQL
 
6
 *
 
7
 *  This program is free software; you can redistribute it and/or modify
 
8
 *  it under the terms of the GNU General Public License as published by
 
9
 *  the Free Software Foundation; either version 2 of the License, or
 
10
 *  (at your option) any later version.
 
11
 *
 
12
 *  This program is distributed in the hope that it will be useful,
 
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 *  GNU General Public License for more details.
 
16
 *
 
17
 *  You should have received a copy of the GNU General Public License
 
18
 *  along with this program; if not, write to the Free Software
 
19
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
20
 */
 
21
 
 
22
#pragma once
 
23
 
 
24
#include "client_priv.h"
 
25
#include <iosfwd>
 
26
#include <string>
 
27
#include <cstdlib>
 
28
#include <drizzled/gettext.h>
 
29
 
 
30
class OptionString 
 
31
{
 
32
public:
 
33
  OptionString(char *in_string,
 
34
               size_t in_length,
 
35
               char *in_option,
 
36
               size_t in_option_length,
 
37
               OptionString *in_next) :
 
38
    string(in_string),
 
39
    length(in_length),
 
40
    option(in_option),
 
41
    option_length(in_option_length),
 
42
    next(in_next)
 
43
  { }  
 
44
 
 
45
  OptionString() :
 
46
    string(NULL),
 
47
    length(0),
 
48
    option(NULL),
 
49
    option_length(0),
 
50
    next(NULL)
 
51
  { }
 
52
 
 
53
  ~OptionString()
 
54
  {
 
55
    if (getString())
 
56
      free(getString());
 
57
    if (getOption())
 
58
      free(getOption());
 
59
  }
 
60
 
 
61
  char *getString() const
 
62
  {
 
63
    return string;
 
64
  }
 
65
 
 
66
  size_t getLength() const
 
67
  {
 
68
    return length;
 
69
  }
 
70
 
 
71
  char *getOption() const
 
72
  {
 
73
  return option;
 
74
  }
 
75
 
 
76
  size_t getOptionLength() const
 
77
  {
 
78
    return option_length;
 
79
  }
 
80
 
 
81
  OptionString *getNext() const
 
82
  {
 
83
    return next;
 
84
  }
 
85
 
 
86
  void setString(char *in_string)
 
87
  {
 
88
    string= in_string;
 
89
    length= strlen(in_string);
 
90
  }
 
91
 
 
92
  void setOption(char *in_option)
 
93
  {
 
94
    option= strdup(in_option);
 
95
    option_length= strlen(in_option);
 
96
  }
 
97
 
 
98
  void setNext(OptionString *in_next)
 
99
  {
 
100
    next= in_next;
 
101
  }
 
102
  
 
103
private:
 
104
  char *string;
 
105
  size_t length;
 
106
  char *option;
 
107
  size_t option_length;
 
108
  OptionString *next;
 
109
};