Initialize Tizen 2.3
[framework/web/wrt-plugins-common.git] / src_mobile / Commons / StaticAssert.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /**
17  * @file        StaticAssert.h
18  * @author      Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
19  * @author      Grzegorz Krawczyk (g.krawczyk@samsung.com)
20  * @version     0.1
21  */
22
23 #ifndef WRTDEVICEAPIS_COMMONS_STATIC_ASSERT_H
24 #define WRTDEVICEAPIS_COMMONS_STATIC_ASSERT_H
25
26 namespace WrtDeviceApis {
27 namespace Commons {
28 template<bool>
29 struct CompileTimeChecker
30 {
31     CompileTimeChecker(...);
32 };
33
34 template<>
35 struct CompileTimeChecker<false> {};
36
37 #define STATIC_CHECK(expr, msg) \
38     { \
39         class ERROR_##msg {}; \
40         CompileTimeChecker<(expr) != 0>((ERROR_##msg())); \
41     }
42
43 /**
44  * Define used to inform about errors in compilation time
45  * useful in templates
46  * @param msg - message to be displayed,
47  * msg have to be a valid C++ identifier,
48  * other way reported errors will be meaningless
49  * @param C - instance of object which caused problem
50  * error generated by compiler display type of C
51  * */
52 #define STATIC_ERROR(msg, C) \
53     { \
54         C->_##msg(); \
55     }
56 }
57 } // WrtDeviceApisCommon
58
59 #endif // WRTDEVICEAPIS_COMMONS_STATIC_ASSERT_H