summaryrefslogtreecommitdiff
path: root/src/dpl/core/include/cchecker/dpl
diff options
context:
space:
mode:
Diffstat (limited to 'src/dpl/core/include/cchecker/dpl')
-rw-r--r--src/dpl/core/include/cchecker/dpl/assert.h43
-rw-r--r--src/dpl/core/include/cchecker/dpl/availability.h30
-rw-r--r--src/dpl/core/include/cchecker/dpl/char_traits.h39
-rw-r--r--src/dpl/core/include/cchecker/dpl/colors.h74
-rw-r--r--src/dpl/core/include/cchecker/dpl/errno_string.h36
-rw-r--r--src/dpl/core/include/cchecker/dpl/exception.h385
-rw-r--r--src/dpl/core/include/cchecker/dpl/noncopyable.h38
-rw-r--r--src/dpl/core/include/cchecker/dpl/noreturn.h27
-rw-r--r--src/dpl/core/include/cchecker/dpl/optional.h175
-rw-r--r--src/dpl/core/include/cchecker/dpl/scoped_array.h65
-rw-r--r--src/dpl/core/include/cchecker/dpl/scoped_free.h57
-rw-r--r--src/dpl/core/include/cchecker/dpl/scoped_resource.h80
-rw-r--r--src/dpl/core/include/cchecker/dpl/string.h141
13 files changed, 1190 insertions, 0 deletions
diff --git a/src/dpl/core/include/cchecker/dpl/assert.h b/src/dpl/core/include/cchecker/dpl/assert.h
new file mode 100644
index 0000000..03dd7d0
--- /dev/null
+++ b/src/dpl/core/include/cchecker/dpl/assert.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+/*
+ * @file assert.h
+ * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version 1.0
+ * @brief This file is the implementation file of assert
+ */
+#ifndef CCHECKER_ASSERT_H
+#define CCHECKER_ASSERT_H
+
+#include <cchecker/dpl/noreturn.h>
+
+namespace CCHECKER {
+// Assertion handler procedure
+// Do not call directly
+// Always use Assert macro
+CCHECKER_NORETURN void AssertProc(const char *condition,
+ const char *file,
+ int line,
+ const char *function);
+} // namespace CCHECKER
+
+#define Assert(Condition) do { if (!(Condition)) { CCHECKER::AssertProc(#Condition, \
+ __FILE__, \
+ __LINE__, \
+ __FUNCTION__); \
+ } } while (0)
+
+#endif // CCHECKER_ASSERT_H
diff --git a/src/dpl/core/include/cchecker/dpl/availability.h b/src/dpl/core/include/cchecker/dpl/availability.h
new file mode 100644
index 0000000..b1cb894
--- /dev/null
+++ b/src/dpl/core/include/cchecker/dpl/availability.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+/*
+ * @file availability.h
+ * @author Jihoon Chung (jihoon.chung@samsung.com)
+ * @version 1.0
+ */
+#ifndef CCHECKER_AVAILABILITY_H
+#define CCHECKER_AVAILABILITY_H
+
+#define CCHECKER_DEPRECATED __attribute__((deprecated))
+#define CCHECKER_DEPRECATED_WITH_MESSAGE(msg) __attribute__((deprecated(msg)))
+
+#define CCHECKER_UNUSED __attribute__((unused))
+#define CCHECKER_UNUSED_PARAM(variable) (void)variable
+
+#endif // CCHECKER_AVAILABILITY_H
diff --git a/src/dpl/core/include/cchecker/dpl/char_traits.h b/src/dpl/core/include/cchecker/dpl/char_traits.h
new file mode 100644
index 0000000..06e2840
--- /dev/null
+++ b/src/dpl/core/include/cchecker/dpl/char_traits.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+/*
+ * @file char_traits.h
+ * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
+ * @version 1.0
+ * @brief Char traits are used to create basic_string extended with
+ * additional features
+ * Current char traits could be extended in feature to boost
+ * performance
+ */
+#ifndef CCHECKER_CHAR_TRAITS
+#define CCHECKER_CHAR_TRAITS
+
+#include <cstring>
+#include <string>
+#include <ostream>
+#include <algorithm>
+
+#include <cchecker/dpl/exception.h>
+
+namespace CCHECKER {
+typedef std::char_traits<wchar_t> CharTraits;
+} // namespace CCHECKER
+
+#endif // CCHECKER_CHAR_TRAITS
diff --git a/src/dpl/core/include/cchecker/dpl/colors.h b/src/dpl/core/include/cchecker/dpl/colors.h
new file mode 100644
index 0000000..d652f5b
--- /dev/null
+++ b/src/dpl/core/include/cchecker/dpl/colors.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+/*
+ * @file colors.h
+ * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
+ * @version 1.0
+ * @brief Some constants with definition of colors for Console
+ * and html output
+ */
+
+#ifndef CCHECKER_COLORS_H
+#define CCHECKER_COLORS_H
+
+namespace CCHECKER {
+namespace Colors {
+namespace Text {
+extern const char* BOLD_GREEN_BEGIN;
+extern const char* BOLD_GREEN_END;
+extern const char* PURPLE_BEGIN;
+extern const char* PURPLE_END;
+extern const char* RED_BEGIN;
+extern const char* RED_END;
+extern const char* GREEN_BEGIN;
+extern const char* GREEN_END;
+extern const char* CYAN_BEGIN;
+extern const char* CYAN_END;
+extern const char* BOLD_RED_BEGIN;
+extern const char* BOLD_RED_END;
+extern const char* BOLD_YELLOW_BEGIN;
+extern const char* BOLD_YELLOW_END;
+extern const char* BOLD_GOLD_BEGIN;
+extern const char* BOLD_GOLD_END;
+extern const char* BOLD_WHITE_BEGIN;
+extern const char* BOLD_WHITE_END;
+extern const char* COLOR_END;
+} //namespace Text
+
+namespace Html {
+extern const char* BOLD_GREEN_BEGIN;
+extern const char* BOLD_GREEN_END;
+extern const char* PURPLE_BEGIN;
+extern const char* PURPLE_END;
+extern const char* RED_BEGIN;
+extern const char* RED_END;
+extern const char* GREEN_BEGIN;
+extern const char* GREEN_END;
+extern const char* CYAN_BEGIN;
+extern const char* CYAN_END;
+extern const char* BOLD_RED_BEGIN;
+extern const char* BOLD_RED_END;
+extern const char* BOLD_YELLOW_BEGIN;
+extern const char* BOLD_YELLOW_END;
+extern const char* BOLD_GOLD_BEGIN;
+extern const char* BOLD_GOLD_END;
+extern const char* BOLD_WHITE_BEGIN;
+extern const char* BOLD_WHITE_END;
+} //namespace Html
+} //namespace Colors
+} //namespace CCHECKER
+
+#endif /* CCHECKER_COLORS_H */
diff --git a/src/dpl/core/include/cchecker/dpl/errno_string.h b/src/dpl/core/include/cchecker/dpl/errno_string.h
new file mode 100644
index 0000000..c98eba3
--- /dev/null
+++ b/src/dpl/core/include/cchecker/dpl/errno_string.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+/*
+ * @file errno_string.h
+ * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version 1.0
+ * @brief This file is the implementation file of errno string
+ */
+#ifndef CCHECKER_ERRNO_STRING_H
+#define CCHECKER_ERRNO_STRING_H
+
+#include <string>
+#include <cerrno>
+
+#include <cchecker/dpl/exception.h>
+
+namespace CCHECKER {
+DECLARE_EXCEPTION_TYPE(CCHECKER::Exception, InvalidErrnoValue)
+
+std::string GetErrnoString(int error = errno);
+} // namespace CCHECKER
+
+#endif // CCHECKER_ERRNO_STRING_H
diff --git a/src/dpl/core/include/cchecker/dpl/exception.h b/src/dpl/core/include/cchecker/dpl/exception.h
new file mode 100644
index 0000000..f7b9afc
--- /dev/null
+++ b/src/dpl/core/include/cchecker/dpl/exception.h
@@ -0,0 +1,385 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+/*
+ * @file exception.h
+ * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version 1.0
+ * @brief Header file for base exception
+ */
+#ifndef CCHECKER_EXCEPTION_H
+#define CCHECKER_EXCEPTION_H
+
+#include <string>
+#include <cstring>
+#include <cstdio>
+#include <exception>
+#include <cstdlib>
+#include <sstream>
+
+namespace CCHECKER {
+void LogUnhandledException(const std::string &str);
+void LogUnhandledException(const std::string &str,
+ const char *filename,
+ int line,
+ const char *function);
+}
+
+namespace CCHECKER {
+class Exception
+{
+ private:
+ static unsigned int m_exceptionCount;
+ static Exception* m_lastException;
+ static void (*m_terminateHandler)();
+
+ static void AddRef(Exception* exception)
+ {
+ if (!m_exceptionCount) {
+ m_terminateHandler = std::set_terminate(&TerminateHandler);
+ }
+
+ ++m_exceptionCount;
+ m_lastException = exception;
+ }
+
+ static void UnRef(Exception* e)
+ {
+ if (m_lastException == e) {
+ m_lastException = NULL;
+ }
+
+ --m_exceptionCount;
+
+ if (!m_exceptionCount) {
+ std::set_terminate(m_terminateHandler);
+ m_terminateHandler = NULL;
+ }
+ }
+
+ static void TerminateHandler()
+ {
+ if (m_lastException != NULL) {
+ DisplayKnownException(*m_lastException);
+ abort();
+ } else {
+ DisplayUnknownException();
+ abort();
+ }
+ }
+
+ Exception *m_reason;
+ std::string m_path;
+ std::string m_function;
+ int m_line;
+
+ protected:
+ std::string m_message;
+ std::string m_className;
+
+ public:
+ static std::string KnownExceptionToString(const Exception &e)
+ {
+ std::ostringstream message;
+ message <<
+ "\033[1;5;31m\n=== Unhandled CCHECKER exception occurred ===\033[m\n\n";
+ message << "\033[1;33mException trace:\033[m\n\n";
+ message << e.DumpToString();
+ message << "\033[1;31m\n=== Will now abort ===\033[m\n";
+
+ return message.str();
+ }
+
+ static std::string UnknownExceptionToString()
+ {
+ std::ostringstream message;
+ message <<
+ "\033[1;5;31m\n=== Unhandled non-CCHECKER exception occurred ===\033[m\n\n";
+ message << "\033[1;31m\n=== Will now abort ===\033[m\n";
+
+ return message.str();
+ }
+
+ static void DisplayKnownException(const Exception& e)
+ {
+ LogUnhandledException(KnownExceptionToString(e).c_str());
+ }
+
+ static void DisplayUnknownException()
+ {
+ LogUnhandledException(UnknownExceptionToString().c_str());
+ }
+
+ Exception(const Exception &other)
+ {
+ // Deep copy
+ if (other.m_reason != NULL) {
+ m_reason = new Exception(*other.m_reason);
+ } else {
+ m_reason = NULL;
+ }
+
+ m_message = other.m_message;
+ m_path = other.m_path;
+ m_function = other.m_function;
+ m_line = other.m_line;
+
+ m_className = other.m_className;
+
+ AddRef(this);
+ }
+
+ const Exception &operator =(const Exception &other)
+ {
+ if (this == &other) {
+ return *this;
+ }
+
+ // Deep copy
+ if (other.m_reason != NULL) {
+ m_reason = new Exception(*other.m_reason);
+ } else {
+ m_reason = NULL;
+ }
+
+ m_message = other.m_message;
+ m_path = other.m_path;
+ m_function = other.m_function;
+ m_line = other.m_line;
+
+ m_className = other.m_className;
+
+ AddRef(this);
+
+ return *this;
+ }
+
+ Exception(const char *path,
+ const char *function,
+ int line,
+ const std::string &message) :
+ m_reason(NULL),
+ m_path(path),
+ m_function(function),
+ m_line(line),
+ m_message(message)
+ {
+ AddRef(this);
+ }
+
+ Exception(const char *path,
+ const char *function,
+ int line,
+ const Exception &reason,
+ const std::string &message) :
+ m_reason(new Exception(reason)),
+ m_path(path),
+ m_function(function),
+ m_line(line),
+ m_message(message)
+ {
+ AddRef(this);
+ }
+
+ virtual ~Exception() throw()
+ {
+ if (m_reason != NULL) {
+ delete m_reason;
+ m_reason = NULL;
+ }
+
+ UnRef(this);
+ }
+
+ void Dump() const
+ {
+ // Show reason first
+ if (m_reason != NULL) {
+ m_reason->Dump();
+ }
+
+ // Afterward, dump exception
+ const char *file = strchr(m_path.c_str(), '/');
+
+ if (file == NULL) {
+ file = m_path.c_str();
+ } else {
+ ++file;
+ }
+
+ printf("\033[0;36m[%s:%i]\033[m %s() \033[4;35m%s\033[m: %s\033[m\n",
+ file, m_line,
+ m_function.c_str(),
+ m_className.c_str(),
+ m_message.empty() ? "<EMPTY>" : m_message.c_str());
+ }
+
+ std::string DumpToString() const
+ {
+ std::string ret;
+ if (m_reason != NULL) {
+ ret = m_reason->DumpToString();
+ }
+
+ const char *file = strchr(m_path.c_str(), '/');
+
+ if (file == NULL) {
+ file = m_path.c_str();
+ } else {
+ ++file;
+ }
+
+ char buf[1024];
+ snprintf(buf,
+ sizeof(buf),
+ "\033[0;36m[%s:%i]\033[m %s() \033[4;35m%s\033[m: %s\033[m\n",
+ file,
+ m_line,
+ m_function.c_str(),
+ m_className.c_str(),
+ m_message.empty() ? "<EMPTY>" : m_message.c_str());
+
+ buf[sizeof(buf) - 1] = '\n';
+ ret += buf;
+
+ return ret;
+ }
+
+ Exception *GetReason() const
+ {
+ return m_reason;
+ }
+
+ std::string GetPath() const
+ {
+ return m_path;
+ }
+
+ std::string GetFunction() const
+ {
+ return m_function;
+ }
+
+ int GetLine() const
+ {
+ return m_line;
+ }
+
+ std::string GetMessage() const
+ {
+ return m_message;
+ }
+
+ std::string GetClassName() const
+ {
+ return m_className;
+ }
+};
+} // namespace CCHECKER
+
+#define Try try
+
+#define Throw(ClassName) \
+ throw ClassName(__FILE__, __FUNCTION__, __LINE__)
+
+#define ThrowMsg(ClassName, Message) \
+ do \
+ { \
+ std::ostringstream dplLoggingStream; \
+ dplLoggingStream << Message; \
+ throw ClassName(__FILE__, __FUNCTION__, __LINE__, dplLoggingStream.str()); \
+ } while (0)
+
+#define ReThrow(ClassName) \
+ throw ClassName(__FILE__, __FUNCTION__, __LINE__, _rethrown_exception)
+
+#define ReThrowMsg(ClassName, Message) \
+ throw ClassName(__FILE__, \
+ __FUNCTION__, \
+ __LINE__, \
+ _rethrown_exception, \
+ Message)
+
+#define Catch(ClassName) \
+ catch (const ClassName &_rethrown_exception)
+
+#define DECLARE_EXCEPTION_TYPE(BaseClass, Class) \
+ class Class : \
+ public BaseClass \
+ { \
+ public: \
+ Class(const char *path, \
+ const char *function, \
+ int line, \
+ const std::string & message = std::string()) : \
+ BaseClass(path, function, line, message) \
+ { \
+ BaseClass::m_className = #Class; \
+ } \
+ \
+ Class(const char *path, \
+ const char *function, \
+ int line, \
+ const CCHECKER::Exception & reason, \
+ const std::string & message = std::string()) : \
+ BaseClass(path, function, line, reason, message) \
+ { \
+ BaseClass::m_className = #Class; \
+ } \
+ };
+
+#define UNHANDLED_EXCEPTION_HANDLER_BEGIN try
+
+#define UNHANDLED_EXCEPTION_HANDLER_END \
+ catch (const CCHECKER::Exception &exception) \
+ { \
+ std::ostringstream msg; \
+ msg << CCHECKER::Exception::KnownExceptionToString(exception); \
+ CCHECKER::LogUnhandledException(msg.str(), __FILE__, __LINE__, __FUNCTION__); \
+ abort(); \
+ } \
+ catch (std::exception& e) \
+ { \
+ std::ostringstream msg; \
+ msg << e.what(); \
+ msg << "\n"; \
+ msg << CCHECKER::Exception::UnknownExceptionToString(); \
+ CCHECKER::LogUnhandledException(msg.str(), __FILE__, __LINE__, __FUNCTION__); \
+ abort(); \
+ } \
+ catch (...) \
+ { \
+ std::ostringstream msg; \
+ msg << CCHECKER::Exception::UnknownExceptionToString(); \
+ CCHECKER::LogUnhandledException(msg.str(), __FILE__, __LINE__, __FUNCTION__); \
+ abort(); \
+ }
+
+namespace CCHECKER {
+namespace CommonException {
+/**
+ * Internal exception definitions
+ *
+ * These should normally not happen.
+ * Usually, exception trace with internal error includes
+ * important messages.
+ */
+DECLARE_EXCEPTION_TYPE(Exception, InternalError) ///< Unexpected error from
+ // underlying libraries or
+ // kernel
+}
+}
+
+#endif // CCHECKER_EXCEPTION_H
diff --git a/src/dpl/core/include/cchecker/dpl/noncopyable.h b/src/dpl/core/include/cchecker/dpl/noncopyable.h
new file mode 100644
index 0000000..747299c
--- /dev/null
+++ b/src/dpl/core/include/cchecker/dpl/noncopyable.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+/*
+ * @file noncopyable
+ * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version 1.0
+ * @brief This file is the implementation file of noncopyable
+ */
+#ifndef CCHECKER_NONCOPYABLE_H
+#define CCHECKER_NONCOPYABLE_H
+
+namespace CCHECKER {
+class Noncopyable
+{
+ private:
+ Noncopyable(const Noncopyable &);
+ const Noncopyable &operator=(const Noncopyable &);
+
+ public:
+ Noncopyable();
+ virtual ~Noncopyable();
+};
+} // namespace CCHECKER
+
+#endif // CCHECKER_NONCOPYABLE_H
diff --git a/src/dpl/core/include/cchecker/dpl/noreturn.h b/src/dpl/core/include/cchecker/dpl/noreturn.h
new file mode 100644
index 0000000..6eaaa64
--- /dev/null
+++ b/src/dpl/core/include/cchecker/dpl/noreturn.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+/*
+ * @file noreturn.h
+ * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version 1.0
+ * @brief This file is the implementation file of noreturn
+ */
+#ifndef CCHECKER_NORETURN_H
+#define CCHECKER_NORETURN_H
+
+#define CCHECKER_NORETURN __attribute__((__noreturn__))
+
+#endif // CCHECKER_NORETURN_H
diff --git a/src/dpl/core/include/cchecker/dpl/optional.h b/src/dpl/core/include/cchecker/dpl/optional.h
new file mode 100644
index 0000000..42d1bd4
--- /dev/null
+++ b/src/dpl/core/include/cchecker/dpl/optional.h
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+/*
+ * @file optional_value.h
+ * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
+ * @version 1.0
+ */
+
+#ifndef CCHECKER_OPTIONAL_H
+#define CCHECKER_OPTIONAL_H
+
+#include <cchecker/dpl/exception.h>
+
+namespace CCHECKER {
+template <typename Type>
+class Optional
+{
+ class Exception
+ {
+ public:
+ DECLARE_EXCEPTION_TYPE(CCHECKER::Exception, Base)
+ DECLARE_EXCEPTION_TYPE(Base, NullReference)
+ };
+
+ public:
+ Optional() :
+ m_null(true),
+ m_value()
+ {}
+
+ Optional(const Type& t) :
+ m_null(false),
+ m_value(t)
+ {}
+
+ bool IsNull() const
+ {
+ return m_null;
+ }
+
+ Type& operator*()
+ {
+ if (m_null) {
+ Throw(typename Exception::NullReference);
+ }
+ return m_value;
+ }
+
+ const Type& operator*() const
+ {
+ if (m_null) {
+ Throw(typename Exception::NullReference);
+ }
+ return m_value;
+ }
+
+ const Type* operator->() const
+ {
+ if (m_null) {
+ Throw(typename Exception::NullReference);
+ }
+ return &m_value;
+ }
+
+ Type* operator->()
+ {
+ if (m_null) {
+ Throw(typename Exception::NullReference);
+ }
+ return &m_value;
+ }
+
+ bool operator!() const
+ {
+ return m_null;
+ }
+
+ Optional<Type>& operator=(const Type& other)
+ {
+ m_null = false;
+ m_value = other;
+ return *this;
+ }
+
+ bool operator==(const Optional<Type>& aSecond) const
+ {
+ return LogicalOperator<true>(*this, aSecond,
+ std::equal_to<Type>(), std::equal_to<bool>());
+ }
+
+ bool operator==(const Type& aSecond) const
+ {
+ return Optional<Type>(aSecond) == *this;
+ }
+
+ bool operator!=(const Optional<Type>& aSecond) const
+ {
+ return !(*this == aSecond);
+ }
+
+ bool operator<(const Optional<Type>& aSecond) const
+ {
+ return LogicalOperator<false>(*this, aSecond,
+ std::less<Type>(), std::less<bool>());
+ }
+
+ bool operator>(const Optional<Type>& aSecond) const
+ {
+ return LogicalOperator<false>(*this, aSecond,
+ std::greater<Type>(), std::greater<bool>());
+ }
+
+ bool operator<=(const Optional<Type>& aSecond) const
+ {
+ return *this == aSecond || *this < aSecond;
+ }
+
+ bool operator>=(const Optional<Type>& aSecond) const
+ {
+ return *this == aSecond || *this > aSecond;
+ }
+
+ static Optional<Type> Null;
+
+ private:
+ bool m_null;
+ Type m_value;
+
+ template <bool taEquality, typename taComparator, typename taNullComparator>
+ static bool LogicalOperator(const Optional<Type>& aFirst,
+ const Optional<Type>& aSecond,
+ taComparator aComparator,
+ taNullComparator aNullComparator)
+ {
+ if (aFirst.m_null == aSecond.m_null) {
+ if (aFirst.m_null) {
+ return taEquality;
+ } else {
+ return aComparator(aFirst.m_value, aSecond.m_value);
+ }
+ } else {
+ return aNullComparator(aFirst.m_null, aSecond.m_null);
+ }
+ }
+};
+
+template<typename Type>
+Optional<Type> Optional<Type>::Null = Optional<Type>();
+} //namespace CCHECKER
+
+template<typename Type>
+std::ostream& operator<<(std::ostream& aStream,
+ const CCHECKER::Optional<Type>& aOptional)
+{
+ if (aOptional.IsNull()) {
+ return aStream << "null optional";
+ } else {
+ return aStream << *aOptional;
+ }
+}
+
+#endif // CCHECKER_OPTIONAL_VALUE_H
diff --git a/src/dpl/core/include/cchecker/dpl/scoped_array.h b/src/dpl/core/include/cchecker/dpl/scoped_array.h
new file mode 100644
index 0000000..54c0c80
--- /dev/null
+++ b/src/dpl/core/include/cchecker/dpl/scoped_array.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+/*!
+ * @file scoped_ptr.h
+ * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version 1.0
+ * @brief This file is the implementation file of scoped array RAII
+ */
+#ifndef CCHECKER_SCOPED_ARRAY_H
+#define CCHECKER_SCOPED_ARRAY_H
+
+#include <cstddef>
+
+#include <cchecker/dpl/assert.h>
+#include <cchecker/dpl/scoped_resource.h>
+
+namespace CCHECKER {
+template<typename Class>
+struct ScopedArrayPolicy
+{
+ typedef Class* Type;
+ static Type NullValue()
+ {
+ return NULL;
+ }
+ static void Destroy(Type ptr)
+ {
+ delete[] ptr;
+ }
+};
+
+template<typename Class>
+class ScopedArray : public ScopedResource<ScopedArrayPolicy<Class> >
+{
+ typedef ScopedArrayPolicy<Class> Policy;
+ typedef ScopedResource<Policy> BaseType;
+
+ public:
+ explicit ScopedArray(Class *ptr = Policy::NullValue()) : BaseType(ptr) { }
+
+ Class &operator [](std::ptrdiff_t k) const
+ {
+ Assert(this->m_value != Policy::NullValue() &&
+ "Dereference of scoped NULL array!");
+ Assert(k >= 0 && "Negative array index");
+
+ return this->m_value[k];
+ }
+};
+} // namespace CCHECKER
+
+#endif // CCHECKER_SCOPED_PTR_H
diff --git a/src/dpl/core/include/cchecker/dpl/scoped_free.h b/src/dpl/core/include/cchecker/dpl/scoped_free.h
new file mode 100644
index 0000000..d8fee50
--- /dev/null
+++ b/src/dpl/core/include/cchecker/dpl/scoped_free.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+/*!
+ * @file scoped_free.h
+ * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @version 1.0
+ * @brief This file is the implementation file of scoped free RAII
+ */
+
+#ifndef CCHECKER_SCOPED_FREE_H
+#define CCHECKER_SCOPED_FREE_H
+
+#include <malloc.h>
+#include <cstddef>
+
+#include <cchecker/dpl/scoped_resource.h>
+
+namespace CCHECKER {
+template<typename Class>
+struct ScopedFreePolicy
+{
+ typedef Class* Type;
+ static Type NullValue()
+ {
+ return NULL;
+ }
+ static void Destroy(Type ptr)
+ {
+ free(ptr);
+ }
+};
+
+template<typename Memory>
+class ScopedFree : public ScopedResource<ScopedFreePolicy<Memory> >
+{
+ typedef ScopedFreePolicy<Memory> Policy;
+ typedef ScopedResource<Policy> BaseType;
+
+ public:
+ explicit ScopedFree(Memory *ptr = Policy::NullValue()) : BaseType(ptr) { }
+};
+} // namespace CCHECKER
+
+#endif // CCHECKER_SCOPED_FREE_H
diff --git a/src/dpl/core/include/cchecker/dpl/scoped_resource.h b/src/dpl/core/include/cchecker/dpl/scoped_resource.h
new file mode 100644
index 0000000..2b3c72d
--- /dev/null
+++ b/src/dpl/core/include/cchecker/dpl/scoped_resource.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+/*
+ * @file scoped_resource.h
+ * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
+ * @version 1.0
+ * @brief This file is the implementation file of scoped resource pattern
+ */
+#ifndef CCHECKER_SCOPED_RESOURCE_H
+#define CCHECKER_SCOPED_RESOURCE_H
+
+#include <cchecker/dpl/noncopyable.h>
+
+namespace CCHECKER {
+template<typename ClassPolicy>
+class ScopedResource :
+ private Noncopyable
+{
+ public:
+ typedef typename ClassPolicy::Type ValueType;
+ typedef ScopedResource<ClassPolicy> ThisType;
+
+ protected:
+ ValueType m_value;
+
+ public:
+ explicit ScopedResource(ValueType value) : m_value(value) { }
+
+ ~ScopedResource()
+ {
+ ClassPolicy::Destroy(m_value);
+ }
+
+ ValueType Get() const
+ {
+ return m_value;
+ }
+
+ void Reset(ValueType value = ClassPolicy::NullValue())
+ {
+ ClassPolicy::Destroy(m_value);
+ m_value = value;
+ }
+
+ ValueType Release()
+ {
+ ValueType value = m_value;
+ m_value = ClassPolicy::NullValue();
+ return value;
+ }
+ typedef ValueType ThisType::*UnknownBoolType;
+
+ operator UnknownBoolType() const
+ {
+ return m_value == ClassPolicy::NullValue() ?
+ 0 : //0 is valid here because it converts to false
+ &ThisType::m_value; //it converts to true
+ }
+
+ bool operator !() const
+ {
+ return m_value == ClassPolicy::NullValue();
+ }
+};
+} // namespace CCHECKER
+
+#endif // CCHECKER_SCOPED_RESOURCE_H
diff --git a/src/dpl/core/include/cchecker/dpl/string.h b/src/dpl/core/include/cchecker/dpl/string.h
new file mode 100644
index 0000000..d9c3bbd
--- /dev/null
+++ b/src/dpl/core/include/cchecker/dpl/string.h
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+/*
+ * @file string.h
+ * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
+ * @version 1.0
+ */
+#ifndef CCHECKER_STRING
+#define CCHECKER_STRING
+
+#include <string>
+#include <ostream>
+#include <numeric>
+
+#include <cchecker/dpl/exception.h>
+#include <cchecker/dpl/char_traits.h>
+
+namespace CCHECKER {
+// @brief CCHECKER string
+typedef std::basic_string<wchar_t, CharTraits> String;
+
+// @brief String exception class
+class StringException
+{
+ public:
+ DECLARE_EXCEPTION_TYPE(CCHECKER::Exception, Base)
+
+ // @brief Invalid init for UTF8 to UTF32 converter
+ DECLARE_EXCEPTION_TYPE(Base, IconvInitErrorUTF8ToUTF32)
+
+ // @brief Invalid taStdContainerinit for UTF32 to UTF32 converter
+ DECLARE_EXCEPTION_TYPE(Base, IconvInitErrorUTF32ToUTF8)
+
+ // @brief Invalid conversion for UTF8 to UTF32 converter
+ DECLARE_EXCEPTION_TYPE(Base, IconvConvertErrorUTF8ToUTF32)
+
+ // @brief Invalid conversion for UTF8 to UTF32 converter
+ DECLARE_EXCEPTION_TYPE(Base, IconvConvertErrorUTF32ToUTF8)
+
+ // @brief Invalid ASCII character detected in FromASCII
+ DECLARE_EXCEPTION_TYPE(Base, InvalidASCIICharacter)
+
+ // @brief Invalid ASCII character detected in FromASCII
+ DECLARE_EXCEPTION_TYPE(Base, ICUInvalidCharacterFound)
+};
+
+//!\brief convert ASCII string to CCHECKER::String
+String FromASCIIString(const std::string& aString);
+
+//!\brief convert UTF32 string to CCHECKER::String
+String FromUTF32String(const std::wstring& aString);
+
+//@brief Returns String object created from UTF8 string
+//@param[in] aString input UTF-8 string
+String FromUTF8String(const std::string& aString);
+
+//@brief Returns String content as std::string
+std::string ToUTF8String(const String& aString);
+
+//@brief Compare two unicode strings
+int StringCompare(const String &left,
+ const String &right,
+ bool caseInsensitive = false);
+
+//@brief Splits the string into substrings.
+//@param[in] str Input string
+//@param[in] delimiters array or string containing a sequence of substring
+// delimiters. Can be also a single delimiter character.
+//@param[in] it InserterIterator that is used to save the generated substrings.
+template<typename StringType, typename Delimiters, typename InserterIterator>
+void Tokenize(const StringType& str,
+ const Delimiters& delimiters,
+ InserterIterator it,
+ bool ignoreEmpty = false)
+{
+ typename StringType::size_type nextSearchStart = 0;
+ typename StringType::size_type pos;
+ typename StringType::size_type length;
+
+ while (true) {
+ pos = str.find_first_of(delimiters, nextSearchStart);
+ length =
+ ((pos == StringType::npos) ? str.length() : pos) - nextSearchStart;
+
+ if (!ignoreEmpty || length > 0) {
+ *it = str.substr(nextSearchStart, length);
+ it++;
+ }
+
+ if (pos == StringType::npos) {
+ return;
+ }
+
+ nextSearchStart = pos + 1;
+ }
+}
+
+namespace Utils {
+
+template<typename T> class ConcatFunc : public std::binary_function<T, T, T>
+{
+public:
+ explicit ConcatFunc(const T & val) : m_delim(val) {}
+ T operator()(const T & arg1, const T & arg2) const
+ {
+ return arg1 + m_delim + arg2;
+ }
+private:
+ T m_delim;
+};
+
+}
+
+template<typename ForwardIterator>
+typename ForwardIterator::value_type Join(ForwardIterator begin, ForwardIterator end, typename ForwardIterator::value_type delim)
+{
+ typedef typename ForwardIterator::value_type value;
+ if(begin == end) return value();
+ Utils::ConcatFunc<value> func(delim);
+ ForwardIterator init = begin;
+ return std::accumulate(++begin, end, *init, func);
+}
+
+} //namespace CCHECKER
+
+std::ostream& operator<<(std::ostream& aStream, const CCHECKER::String& aString);
+
+#endif // CCHECKER_STRING