summaryrefslogtreecommitdiff
path: root/ext/Log4Qt/src/helpers/optionconverter.h
diff options
context:
space:
mode:
authorTomasz Sterna <tomek@xiaoka.com>2014-07-11 21:06:39 +0200
committerTomasz Sterna <tomek@xiaoka.com>2014-07-11 21:06:39 +0200
commitefb33d6494d88c27c8766553b6a963ddf2654458 (patch)
tree76dd5e56b79191074998c0fb6bf7b81276116a4b /ext/Log4Qt/src/helpers/optionconverter.h
parent072da88eee57e5d16f0b75c7b90c8a0bc6a60cb3 (diff)
Included Log4Qt in project
Diffstat (limited to 'ext/Log4Qt/src/helpers/optionconverter.h')
-rwxr-xr-xext/Log4Qt/src/helpers/optionconverter.h141
1 files changed, 141 insertions, 0 deletions
diff --git a/ext/Log4Qt/src/helpers/optionconverter.h b/ext/Log4Qt/src/helpers/optionconverter.h
new file mode 100755
index 0000000..ebdd567
--- /dev/null
+++ b/ext/Log4Qt/src/helpers/optionconverter.h
@@ -0,0 +1,141 @@
+/******************************************************************************
+ *
+ * package: Log4Qt
+ * file: optionconverter.h
+ * created: September 2007
+ * author: Martin Heinrich
+ *
+ *
+ * Copyright 2007 Martin Heinrich
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+#ifndef LOG4QT_OPTIONCONVERTER_H
+#define LOG4QT_OPTIONCONVERTER_H
+#include "../log4qtshared.h"
+
+/******************************************************************************
+ * Dependencies
+ ******************************************************************************/
+
+#include <QtCore/QString>
+#include "level.h"
+
+namespace Log4Qt
+{
+ class Properties;
+
+ /*!
+ * \brief The class OptionConverter provides functions to convert strings
+ * to property values.
+ */
+ class LOG4QT_EXPORT OptionConverter
+ {
+ private:
+ OptionConverter();
+ OptionConverter(const OptionConverter &rOther); // Not implemented
+ // virtual ~OptionConverter(); // Use compiler default
+ OptionConverter &operator=(const OptionConverter &rOther); // Not implemented
+
+ public:
+ static QString findAndSubst(const Properties &rProperties,
+ const QString &rKey);
+
+ /*!
+ * Returns the JAVA class name \a rClassName as C++ class name by
+ * replacing all . characters with ::.
+ */
+ static QString classNameJavaToCpp(const QString &rClassName);
+
+ /*!
+ * Converts the option \a rOption to a boolean value. Valid strings
+ * for true are "true", "enabled" and "1". Valid strings
+ * for false are "false", "disabled" and "0". If the conversion is
+ * successful, the target is returned and \a p_ok is set to true.
+ * Otherwise an error is written to the log, \a p_ok is set to false
+ * and false is returned.
+ */
+ static bool toBoolean(const QString &rOption,
+ bool *p_ok = 0);
+
+ static bool toBoolean(const QString &rOption,
+ bool default_value);
+
+ /*!
+ * Converts the option string \a rOption to a file size. The string can
+ * be a positive integer followed by an optional unit suffix "KB", "MB"
+ * or "GB". If a unit suffix is specified the the integer is
+ * interpreted as kilobytes, megabytes or gigabytes. If the conversion
+ * is successful, the size is returned and \a p_ok is set to true.
+ * Otherwise an error is written to the log, \a p_ok is set to false
+ * and 0 is returned.
+ */
+ static qint64 toFileSize(const QString &rOption,
+ bool *p_ok = 0);
+
+ /*!
+ * Converts the option \a rOption to a integer value using
+ * QString::toInt(). If the conversion is successful, the integer is
+ * returned and \a p_ok is set to true. Otherwise an error is written
+ * to the log, \a p_ok is set to false and 0 is returned.
+ */
+ static int toInt(const QString &rOption,
+ bool *p_ok = 0);
+
+ /*!
+ * Converts the option \a rOption to a level value using
+ * Level::fromString(). If the conversion is successful, the level
+ * is returned and \a p_ok is set to true. Otherwise an error is
+ * written to the log, \a p_ok is set to false and a level with
+ * the value Level::NULL_INT is returned.
+ *
+ * \sa Level::fromString()
+ */
+ static Level toLevel(const QString &rOption,
+ bool *p_ok = 0);
+
+ static Level toLevel(const QString &rOption,
+ const Level &rDefaultValue);
+
+ /*!
+ * Converts the option \a rOption to a ConsoleAppender::Target value.
+ * Valid strings for \a rOption are "System.out", "STDOUT_TARGET",
+ * "System.err" and "STDERR_TARGET". If the conversion is successful,
+ * the target is returned and \a p_ok is set to true. Otherwise an
+ * error is written to the log, \a p_ok is set to false and
+ * ConsoleAppender::STDOUT_TARGET is returned.
+ */
+ static int toTarget(const QString &rOption,
+ bool *p_ok = 0);
+ };
+
+
+ /**************************************************************************
+ * Operators, Helper
+ **************************************************************************/
+
+
+ /**************************************************************************
+ * Inline
+ **************************************************************************/
+
+
+} // namespace Log4Qt
+
+
+Q_DECLARE_TYPEINFO(Log4Qt::OptionConverter, Q_MOVABLE_TYPE);
+
+
+#endif // LOG4QT_OPTIONCONVERTER_H