1
/* - mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2010 Brian Aker
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
#include "drizzled/util/tablename_to_filename.h"
26
#include "drizzled/internal/my_sys.h"
33
static const char hexchars[]= "0123456789abcdef";
37
Translate a table name to a cursor name (WL #1324).
40
tablename_to_filename()
42
to OUT The cursor name
45
true if errors happen. false on success.
47
bool tablename_to_filename(const std::string &from, std::string &to)
50
std::string::const_iterator iter= from.begin();
51
for (; iter != from.end(); ++iter)
55
if ((isdigit(*iter)) ||
67
to.push_back(tolower(*iter));
72
/* We need to escape this char in a way that can be reversed */
74
to.push_back(hexchars[(*iter >> 4) & 15]);
75
to.push_back(hexchars[(*iter) & 15]);
78
if (drizzled::internal::check_if_legal_tablename(to.c_str()))
85
} /* namespace util */
86
} /* namespace drizzled */