RDK Documentation (Open Sourced RDK Components)
Assert.hpp
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 
21 
22 /**
23 * @defgroup hdmicec
24 * @{
25 * @defgroup ccec
26 * @{
27 **/
28 
29 
30 #ifndef HDMI_CCEC_ASSERT_HPP_
31 #define HDMI_CCEC_ASSERT_HPP_
32 #include "CCEC.hpp"
33 
34 #include <assert.h>
35 #include <cstdio>
36 #include <stdexcept>
37 
38 CCEC_BEGIN_NAMESPACE
39 
40 #if 0
41 class Assert {
42 public:
43  Assert(bool isTrue) : cond(isTrue) {
44  if (!isTrue) {
45  assert(isTrue);
46  }
47  }
48 private:
49  const bool cond;
50 };
51 #else
52 
53 #define Assert(expr) do{\
54  if (!(expr)) printf("[%s] failed at [%s][%d]\r\n", "Assert ", __FILE__, __LINE__);\
55  assert(expr);\
56 } while (0)
57 #endif
58 
59 CCEC_END_NAMESPACE
60 #endif
61 
62 
63 /** @} */
64 /** @} */