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