RAUL  0.5.1
Symbol.hpp
1 /* This file is part of Raul.
2  * Copyright (C) 2008 Dave Robillard <http://drobilla.net>
3  *
4  * Raul is free software; you can redistribute it and/or modify it under the
5  * terms of the GNU General Public License as published by the Free Software
6  * Foundation; either version 2 of the License, or (at your option) any later
7  * version.
8  *
9  * Raul is distributed in the hope that it will be useful, but WITHOUT ANY
10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16  */
17 
18 #ifndef RAUL_SYMBOL_HPP
19 #define RAUL_SYMBOL_HPP
20 
21 #include <iostream>
22 #include <cctype>
23 #include <string>
24 #include <cstring>
25 #include <cassert>
26 
27 namespace Raul {
28 
29 
36 class Symbol : public std::basic_string<char> {
37 public:
38 
44  Symbol(const std::basic_string<char>& symbol)
45  : std::basic_string<char>(symbol)
46  {
47  assert(is_valid(symbol));
48  }
49 
50 
56  Symbol(const char* csymbol)
57  : std::basic_string<char>(csymbol)
58  {
59  assert(is_valid(csymbol));
60  }
61 
62  static bool is_valid(const std::basic_string<char>& path);
63 
64  static std::string symbolify(const std::basic_string<char>& str);
65 };
66 
67 
68 } // namespace Raul
69 
70 #endif // RAUL_SYMBOL_HPP
Definition: Array.hpp:26
Symbol(const char *csymbol)
Construct a Symbol from a C string.
Definition: Symbol.hpp:56
Symbol(const std::basic_string< char > &symbol)
Construct a Symbol from an std::string.
Definition: Symbol.hpp:44
A restricted string (C identifier, which is a component of a path).
Definition: Symbol.hpp:36