~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/set_var.h

  • Committer: lbieber at stabletransit
  • Date: 2010-10-18 20:26:50 UTC
  • mfrom: (1859.1.4 build)
  • Revision ID: lbieber@drizzle-build-n02.wc1.dfw1.stabletransit.com-20101018202650-hcvsp7yuaf1xy04s
Merge Monty - Adds support for a const std::string sys_var type.
Merge Monty - Make it possible to use sys_var directly from plugins.
Merge Padraig - Replaced a few unit8_t types that were being used as bitmaps with std::bitset

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
class sys_var
97
97
{
98
98
protected:
99
 
  const std::string name; /**< The name of the variable */
 
99
  std::string name; /**< The name of the variable */
100
100
  sys_after_update_func after_update; /**< Function pointer triggered after the variable's value is updated */
101
101
  struct option *option_limits; /**< Updated by by set_var_init() */
102
102
  bool m_allow_empty_value; /**< Does variable allow an empty value? */
109
109
  {}
110
110
  virtual ~sys_var() {}
111
111
 
 
112
  void setName(const std::string &name_in)
 
113
  {
 
114
    name= name_in;
 
115
  }
 
116
 
112
117
  /** 
113
118
   * Returns the name of the variable.
114
119
   *
367
372
  bool is_readonly() const { return true; }
368
373
};
369
374
 
 
375
class sys_var_const_string :
 
376
  public sys_var
 
377
{
 
378
  const std::string &value;
 
379
public:
 
380
  sys_var_const_string(const char *name_arg,
 
381
                       const std::string& value_arg) :
 
382
    sys_var(name_arg),
 
383
    value(value_arg)
 
384
  { }
 
385
 
 
386
  inline void set(char *)
 
387
  { }
 
388
 
 
389
  bool check(Session *, set_var *)
 
390
  {
 
391
    return true;
 
392
  }
 
393
  bool update(Session *, set_var *)
 
394
  {
 
395
    return true;
 
396
  }
 
397
  SHOW_TYPE show_type() { return SHOW_CHAR; }
 
398
  unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
 
399
  {
 
400
    return (unsigned char*)(value.c_str());
 
401
  }
 
402
  bool check_update_type(Item_result)
 
403
  {
 
404
    return true;
 
405
  }
 
406
  bool check_default(sql_var_t) { return true; }
 
407
  bool is_readonly() const { return true; }
 
408
};
 
409
 
 
410
class sys_var_const_string_val :
 
411
  public sys_var
 
412
{
 
413
  const std::string value;
 
414
public:
 
415
  sys_var_const_string_val(const char *name_arg,
 
416
                           const std::string& value_arg) :
 
417
    sys_var(name_arg),
 
418
    value(value_arg)
 
419
  { }
 
420
 
 
421
  inline void set(char *)
 
422
  { }
 
423
 
 
424
  bool check(Session *, set_var *)
 
425
  {
 
426
    return true;
 
427
  }
 
428
  bool update(Session *, set_var *)
 
429
  {
 
430
    return true;
 
431
  }
 
432
  SHOW_TYPE show_type() { return SHOW_CHAR; }
 
433
  unsigned char *value_ptr(Session *, sql_var_t, const LEX_STRING *)
 
434
  {
 
435
    return (unsigned char*)(value.c_str());
 
436
  }
 
437
  bool check_update_type(Item_result)
 
438
  {
 
439
    return true;
 
440
  }
 
441
  bool check_default(sql_var_t) { return true; }
 
442
  bool is_readonly() const { return true; }
 
443
};
 
444
 
370
445
class sys_var_const_str :public sys_var
371
446
{
372
447
  char *value;                                  // Pointer to const value