summaryrefslogtreecommitdiff
path: root/muggle-plugin/mg_tools.h
diff options
context:
space:
mode:
authorLarsAC <LarsAC@e10066b5-e1e2-0310-b819-94efdf66514b>2005-03-22 06:47:53 +0000
committerLarsAC <LarsAC@e10066b5-e1e2-0310-b819-94efdf66514b>2005-03-22 06:47:53 +0000
commite2de0c5ed7bbbe4b236246e8bfd71cc87c8d974f (patch)
tree616f2f0a482597e3968e281ccf8adcfd04f45bbc /muggle-plugin/mg_tools.h
parent101360901576c7e91196de60e2e6ebd6a4b145dd (diff)
downloadvdr-plugin-muggle-0.1.6-BETA.tar.gz
vdr-plugin-muggle-0.1.6-BETA.tar.bz2
Added 0.1.6 beta tag0.1.6-BETA
git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/tags/0.1.6-BETA@586 e10066b5-e1e2-0310-b819-94efdf66514b
Diffstat (limited to 'muggle-plugin/mg_tools.h')
-rw-r--r--muggle-plugin/mg_tools.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/muggle-plugin/mg_tools.h b/muggle-plugin/mg_tools.h
new file mode 100644
index 0000000..65ba262
--- /dev/null
+++ b/muggle-plugin/mg_tools.h
@@ -0,0 +1,89 @@
+/*! \file mg_tools.h
+ * \ingroup muggle
+ * \brief A few utility functions for standalone and plugin messaging for the vdr muggle plugindatabase
+ *
+ * \version $Revision: 1.4 $
+ * \date $Date$
+ * \author Ralf Klueber, Lars von Wedel, Andreas Kellner
+ * \author file owner: $Author$
+ *
+ */
+
+/* makes sure we don't use the same declarations twice */
+#ifndef _MUGGLE_TOOLS_H
+#define _MUGGLE_TOOLS_H
+
+#include <iostream>
+#include <string>
+#include <mysql.h>
+
+#define STANDALONE 1 // what's this?
+
+/*!
+ * \brief Logging utilities
+ *
+ * \todo these could be static members in the mgLog class
+ * \todo code of these functions should be compiled conditionally
+ */
+//@{
+void mgSetDebugLevel (int new_level);
+void mgDebug (int level, const char *fmt, ...);
+void mgDebug (const char *fmt, ...);
+void mgWarning (const char *fmt, ...);
+//! \todo mgError should display the message on the OSD. How?
+void mgError (const char *fmt, ...);
+//@}
+
+#ifdef DEBUG
+#define MGLOG(x) mgLog __thelog(x)
+#else
+#define MGLOG(x) {}
+#endif
+
+#ifdef DEBUG
+#define MGLOGSTREAM __thelog.getStream()
+#else
+#define MGLOGSTREAM __thelog.getStream()
+#endif
+
+/*! \brief simplified logging class
+ * \ingroup muggle
+ *
+ * Create a local instance at the beginning of the method
+ * and entering/leaving the function will be logged
+ * as constructors/destructors are called.
+ */
+class mgLog
+{
+ public:
+ enum
+ {
+ LOG, WARNING, ERROR, FATAL
+ } mgLogLevel;
+
+ std::ostream & getStream ()
+ {
+ return std::cout;
+ }
+
+ mgLog (std::string methodname):m_methodname (methodname)
+ {
+ getStream () << m_methodname << " entered" << std::endl;
+ };
+
+ ~mgLog ()
+ {
+ getStream () << m_methodname << " terminated" << std::endl;
+ }
+
+ private:
+
+ std::string m_methodname;
+
+};
+
+std::string trim(std::string const& source, char const* delims = " \t\r\n");
+
+char *SeparateFolders(const char *filename, char * folders[],unsigned int fcount);
+
+#endif /* _MUGGLE_TOOLS_H */