Drizzled Public API Documentation

gman_servers_set.cc

00001 /* Copyright (C) 2009 Sun Microsystems, Inc.
00002 
00003    This program is free software; you can redistribute it and/or modify
00004    it under the terms of the GNU General Public License as published by
00005    the Free Software Foundation; version 2 of the License.
00006 
00007    This program is distributed in the hope that it will be useful,
00008    but WITHOUT ANY WARRANTY; without even the implied warranty of
00009    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010    GNU General Public License for more details.
00011 
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software
00014    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00015 
00016 #include <config.h>
00017 #include "gman_servers_set.h"
00018 #include "function_map.h"
00019 
00020 using namespace std;
00021 using namespace drizzled;
00022 
00023 String *Item_func_gman_servers_set::val_str(String *str)
00024 {
00025   String *servers;
00026   String *function;
00027 
00028   if (arg_count < 1 || arg_count > 2 || !(servers= args[0]->val_str(str)))
00029   {
00030     null_value= 1;
00031     return NULL;
00032   }
00033 
00034   function= (arg_count == 2) ? args[1]->val_str(str) : NULL;
00035 
00036   if (!GetFunctionMap().add(string(function == NULL ? "" : function->ptr()),
00037                             string(servers->ptr())))
00038   {
00039     null_value= 1;
00040     return NULL;
00041   }
00042 
00043   null_value= 0;
00044 
00045   buffer.realloc(servers->length());
00046   strcpy(buffer.ptr(), servers->ptr());
00047   buffer.length(servers->length());
00048   return &buffer;
00049 }