SpectMorph
smutils.hh
1 // Licensed GNU LGPL v3 or later: http://www.gnu.org/licenses/lgpl.html
2 
3 #ifndef SPECTMORPH_UTIL_HH
4 #define SPECTMORPH_UTIL_HH
5 
6 #include <string>
7 
8 namespace SpectMorph
9 {
10 
11 /* integer types */
12 typedef uint8_t uint8;
13 typedef int64_t int64;
14 typedef uint64_t uint64;
15 
16 #define SPECTMORPH_CLASS_NON_COPYABLE(Class) private: Class (const Class&); Class& operator= (const Class&);
17 #define SPECTMORPH_PRINTF(format_idx, arg_idx) __attribute__ ((__format__ (__printf__, format_idx, arg_idx)))
18 
19 std::string string_printf (const char *format, ...) SPECTMORPH_PRINTF (1, 2);
20 std::string string_vprintf (const char *format, va_list vargs);
21 
22 std::string string_locale_printf (const char *format, ...) SPECTMORPH_PRINTF (1, 2);
23 
24 void sm_printf (const char *format, ...) SPECTMORPH_PRINTF (1, 2);
25 
26 enum InstallDir
27 {
28  INSTALL_DIR_TEMPLATES,
29  INSTALL_DIR_INSTRUMENTS
30 };
31 
32 std::string sm_get_install_dir (InstallDir p);
33 
34 enum UserDir
35 {
36  USER_DIR_INSTRUMENTS
37 };
38 
39 std::string sm_get_user_dir (UserDir p);
40 std::string sm_get_default_plan();
41 
42 enum class Error
43 {
44  NONE = 0,
45  FILE_NOT_FOUND,
46  FORMAT_INVALID,
47  PARSE_ERROR,
48 };
49 
50 // convenience: provide comparision: (error == 0), (error != 0)
51 bool constexpr operator== (Error v, int64_t n) { return int64_t (v) == n; }
52 bool constexpr operator== (int64_t n, Error v) { return n == int64_t (v); }
53 bool constexpr operator!= (Error v, int64_t n) { return int64_t (v) != n; }
54 bool constexpr operator!= (int64_t n, Error v) { return n != int64_t (v); }
55 
56 const char *sm_error_blurb (Error error);
57 
58 } // namespace SpectMorph
59 
60 #endif
STL namespace.
Definition: smalignedarray.cc:7