aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/utility.h
diff options
context:
space:
mode:
authorcathook <b01902109@csie.ntu.edu.tw>2014-04-19 16:21:17 +0800
committercathook <b01902109@csie.ntu.edu.tw>2014-04-19 16:21:17 +0800
commite9a16c4ef0ea782d7db8d788c455ea946eaab039 (patch)
tree5728aa2076a13079f0ff7f162cfd4cab95e1db91 /meowpp/utility.h
downloadmeow-e9a16c4ef0ea782d7db8d788c455ea946eaab039.tar
meow-e9a16c4ef0ea782d7db8d788c455ea946eaab039.tar.gz
meow-e9a16c4ef0ea782d7db8d788c455ea946eaab039.tar.bz2
meow-e9a16c4ef0ea782d7db8d788c455ea946eaab039.tar.lz
meow-e9a16c4ef0ea782d7db8d788c455ea946eaab039.tar.xz
meow-e9a16c4ef0ea782d7db8d788c455ea946eaab039.tar.zst
meow-e9a16c4ef0ea782d7db8d788c455ea946eaab039.zip
init
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_