omw  0.2.0
utility.h
1 /*
2 author Oliver Blaser
3 date 25.01.2022
4 copyright MIT - Copyright (c) 2022 Oliver Blaser
5 */
6 
7 #ifndef IG_OMW_UTILITY_H
8 #define IG_OMW_UTILITY_H
9 
10 #include <cstddef>
11 #include <cstdint>
12 #include <string>
13 #include <vector>
14 
15 namespace omw
16 {
21  void shiftLeftAssign(int8_t& value, unsigned int n);
22  void shiftLeftAssign(int16_t& value, unsigned int n);
23  void shiftLeftAssign(int32_t& value, unsigned int n);
24  void shiftLeftAssign(int64_t& value, unsigned int n);
25  void shiftLeftAssign(uint8_t& value, unsigned int n);
26  void shiftLeftAssign(uint16_t& value, unsigned int n);
27  void shiftLeftAssign(uint32_t& value, unsigned int n);
28  void shiftLeftAssign(uint64_t& value, unsigned int n);
29  void shiftRightAssign(int8_t& value, unsigned int n);
30  void shiftRightAssign(int16_t& value, unsigned int n);
31  void shiftRightAssign(int32_t& value, unsigned int n);
32  void shiftRightAssign(int64_t& value, unsigned int n);
33  void shiftRightAssign(uint8_t& value, unsigned int n);
34  void shiftRightAssign(uint16_t& value, unsigned int n);
35  void shiftRightAssign(uint32_t& value, unsigned int n);
36  void shiftRightAssign(uint64_t& value, unsigned int n);
37  int8_t shiftLeft(int8_t value, unsigned int n);
38  int16_t shiftLeft(int16_t value, unsigned int n);
39  int32_t shiftLeft(int32_t value, unsigned int n);
40  int64_t shiftLeft(int64_t value, unsigned int n);
41  uint8_t shiftLeft(uint8_t value, unsigned int n);
42  uint16_t shiftLeft(uint16_t value, unsigned int n);
43  uint32_t shiftLeft(uint32_t value, unsigned int n);
44  uint64_t shiftLeft(uint64_t value, unsigned int n);
45  int8_t shiftRight(int8_t value, unsigned int n);
46  int16_t shiftRight(int16_t value, unsigned int n);
47  int32_t shiftRight(int32_t value, unsigned int n);
48  int64_t shiftRight(int64_t value, unsigned int n);
49  uint8_t shiftRight(uint8_t value, unsigned int n);
50  uint16_t shiftRight(uint16_t value, unsigned int n);
51  uint32_t shiftRight(uint32_t value, unsigned int n);
52  uint64_t shiftRight(uint64_t value, unsigned int n);
53 
54  // grp_utility_langSupport
63  inline void toggle(bool& value) { value = !value; }
64  inline void toggle(int& value) { value = (value ? 0 : 1); }
65 
66  template <class Type>
67  bool vectorContains(const std::vector<Type>& v, const Type& item)
68  {
69  bool r = false;
70  for (size_t i = 0; (i < v.size()) && !r; ++i)
71  if (v[i] == item) r = true;
72  return r;
73  }
74 
75  // grp_utility_gpUtil
77 }
78 
79 #endif // IG_OMW_UTILITY_H
omw
Main namespace.