RDK Documentation (Open Sourced RDK Components)
Util.h
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 * @defgroup trm
23 * @{
24 * @defgroup common
25 * @{
26 **/
27 
28 
29 #ifndef TRM_UTIL_H_
30 #define TRM_UTIL_H_
31 
32 #include <iostream>
33 #include <map>
34 #include "trm/TRM.h"
35 
36 TRM_BEGIN_NAMESPACE
37 
38 const std::string IntToString(int i);
39 const std::string IntToString(int i, int j);
40 
41 class SpecVersion {
42 
43 public:
44  SpecVersion(int major_, int minor_) : major_(major_), minor_(minor_) {
45  Assert(major_ < 1000);
46  Assert(minor_ < 1000);
47  }
48  const std::string toString() const {
49  return IntToString(major_, minor_);
50  }
51 
52  bool operator > (const SpecVersion &that) const {
53  return this->toInt() > that.toInt();
54  }
55 
56 private:
57  int toInt(void) const {
58  return ((major_ << 16) | minor_);
59  }
60  int major_;
61  int minor_;
62 };
63 
64 const std::string GenerateUUID(void);
65 void HexDump(const std::vector<uint8_t> &in);
66 uint64_t GetCurrentEpoch(void);
67 std::ostream & Timestamp (std::ostream &os);
68 std::ostream & Log (void);
69 std::string GetAuthToken(const char *generateTokenRequest);
70 const SpecVersion &GetSpecVersion(void);
71 TRM_END_NAMESPACE
72 
73 #endif
74 
75 
76 /** @} */
77 /** @} */
SpecVersion
Definition: Util.h:41