3 #ifndef SPECTMORPH_UTIL_HH
4 #define SPECTMORPH_UTIL_HH
17 #error "unsupported platform"
26 #error "unsupported compiler"
33 typedef uint8_t uint8;
34 typedef uint32_t uint32;
35 typedef int64_t int64;
36 typedef uint64_t uint64;
37 typedef unsigned int uint;
39 #define SPECTMORPH_CLASS_NON_COPYABLE(Class) private: Class (const Class&); Class& operator= (const Class&);
42 #define SPECTMORPH_PRINTF(format_idx, arg_idx) __attribute__ ((__format__ (gnu_printf, format_idx, arg_idx)))
44 #define SPECTMORPH_PRINTF(format_idx, arg_idx) __attribute__ ((__format__ (__printf__, format_idx, arg_idx)))
47 std::string string_printf (
const char *format, ...) SPECTMORPH_PRINTF (1, 2);
48 std::
string string_vprintf (const
char *format, va_list vargs);
50 std::
string string_locale_printf (const
char *format, ...) SPECTMORPH_PRINTF (1, 2);
52 void sm_printf (const
char *format, ...) SPECTMORPH_PRINTF (1, 2);
57 INSTALL_DIR_TEMPLATES,
58 INSTALL_DIR_INSTRUMENTS,
62 std::string sm_get_install_dir (InstallDir p);
65 void sm_set_pkg_data_dir (
const std::string& data_dir);
74 std::string sm_get_user_dir (UserDir p);
75 std::string sm_get_default_plan();
76 std::string sm_get_cache_dir();
79 std::string sm_mac_documents_dir();
80 std::string sm_mac_application_support_dir();
85 DOCUMENTS_DIR_INSTRUMENTS
88 std::string sm_get_documents_dir (DocumentsDir p);
110 case Code::FILE_NOT_FOUND:
111 m_message =
"No such file, device or directory";
114 case Code::FORMAT_INVALID:
115 m_message =
"Invalid format";
118 case Code::PARSE_ERROR:
119 m_message =
"Parsing error";
123 m_message =
"Unknown error";
127 Error (
const std::string& message) :
141 return m_message.c_str();
145 return m_code != Code::NONE;
149 std::string m_message;
153 std::string sm_resolve_link (
const std::string& link_file);
156 std::string sha1_hash (
const unsigned char *data,
size_t len);
157 std::string sha1_hash (
const std::string& str);
161 std::string to_utf8 (
const std::u32string& str);
162 std::u32string to_utf32 (
const std::string& utf8);
164 Error read_dir (
const std::string& dirname, std::vector<std::string>& files);
165 bool file_exists (
const std::string& filename);
166 bool dir_exists (
const std::string& dirname);
171 #include "smdebug.hh"