diff options
author | David Robillard <d@drobilla.net> | 2012-08-14 04:22:07 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-08-14 04:22:07 +0000 |
commit | 2a429ca76b97cca197f105b665271360b74f6917 (patch) | |
tree | d25d206910bd4a84050918693816240c26d7d0ae /src/Symbol.cpp | |
parent | 8bf87dc2367caf9d82dbda0382363cda400971dc (diff) | |
download | raul-2a429ca76b97cca197f105b665271360b74f6917.tar.gz raul-2a429ca76b97cca197f105b665271360b74f6917.tar.bz2 raul-2a429ca76b97cca197f105b665271360b74f6917.zip |
Remove glib dependency.
Make Symbol, URI, and Path simpler derivatives of std::string.
100% test coverage by line for Symbol, URI, Path, AtomicInt, and AtomicPtr.
Add Raul::Exception.
git-svn-id: http://svn.drobilla.net/lad/trunk/raul@4686 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/Symbol.cpp')
-rw-r--r-- | src/Symbol.cpp | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/src/Symbol.cpp b/src/Symbol.cpp deleted file mode 100644 index 4fe049e..0000000 --- a/src/Symbol.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - This file is part of Raul. - Copyright 2007-2012 David Robillard <http://drobilla.net> - - Raul is free software: you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation, either version 3 of the License, or any later version. - - Raul is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Raul. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include <string> - -#include "raul/Symbol.hpp" -#include "raul/Path.hpp" - -using std::string; - -namespace Raul { - -bool -Symbol::is_valid(const std::basic_string<char>& symbol) -{ - if (symbol.length() == 0) - return false; - - // Slash not allowed - if (symbol.find("/") != string::npos) - return false; - - // All characters must be _, a-z, A-Z, 0-9 - for (size_t i=0; i < symbol.length(); ++i) - if (symbol[i] != '_' - && (symbol[i] < 'a' || symbol[i] > 'z') - && (symbol[i] < 'A' || symbol[i] > 'Z') - && (symbol[i] < '0' || symbol[i] > '9') ) - return false; - - // First character must not be a number - if (std::isdigit(symbol[0])) - return false; - - return true; -} - -/** Convert a string to a valid symbol. - * - * This will make a best effort at turning @a str into a complete, valid - * Symbol, and will always return one. - */ -Raul::Symbol -Symbol::symbolify(const std::basic_string<char>& str) -{ - string symbol = str; - - Path::replace_invalid_chars(symbol, 0, true); - - return Raul::Symbol(symbol.empty() ? "_" : symbol); -} - -} // namespace Raul - |