aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/utility.h
diff options
context:
space:
mode:
Diffstat (limited to 'meowpp/utility.h')
-rw-r--r--meowpp/utility.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/meowpp/utility.h b/meowpp/utility.h
new file mode 100644
index 0000000..156971a
--- /dev/null
+++ b/meowpp/utility.h
@@ -0,0 +1,47 @@
+#ifndef UTILITY_H_
+#define UTILITY_H_
+
+#include <string>
+#include <stack>
+#include <cctype>
+
+namespace meow{
+
+ inline std::string stringPrintf(char const * fmt, ...);
+ inline std::string stringReplace(std::string str,
+ std::string const& from,
+ std::string const& to);
+ inline bool cstringEndWith(char const* str, int n, ...);
+#define debugPrintf(...) \
+ meow::debugPrintf_(\
+ __FILE__,\
+ __PRETTY_FUNCTION__,\
+ __LINE__,\
+ meow::stringPrintf(__VA_ARGS__).c_str())
+ inline void debugPrintf_(char const* file,
+ char const* func,
+ size_t line,
+ char const* msg);
+ inline void messagePrintf(int level_change, char const* fmt, ...);
+
+ static const double PI = 3.14159265358979323846264338327950288;
+
+ inline double noEPS(double value, double eps = 1e-9);
+ inline double normalize(double lower, double upper, double value);
+ inline double denormalize(double lower, double upper, double ratio);
+ inline double ratioMapping(double l1, double u1, double m1,
+ double l2, double u2);
+ template<class T>
+ inline T inRange(T const& mn, T const& mx, T const& v);
+ template<class T>
+ inline T squ(T const& x);
+
+ template<class T>
+ inline double average(T const& beg, T const& end, double sigs);
+ template<class T>
+ inline double average(T const& beg, T const& end, T const& p, double sigs);
+}
+
+#include "utility.hpp"
+
+#endif // UTILITY_H_