-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconf.hh
More file actions
45 lines (38 loc) · 791 Bytes
/
conf.hh
File metadata and controls
45 lines (38 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef _XT_CONF_H_
#define _XT_CONF_H_
#include <unistd.h>
#include <stdint.h>
#include <string>
#include <vector>
#include <unordered_map>
typedef char byte;
typedef unsigned char ubyte;
typedef unsigned char xt_byte;
enum class Type : unsigned char {
Nil,
Boolean,
Number,
Pointer,
Char,
Other
};
struct TypeInfo {
std::string name;
};
template<typename T>
int index_of(const std::vector<T>& v, const T& val) {
int idx = 0;
for (typename std::vector<T>::const_iterator it = v.cbegin(); it != v.cend(); ++it) {
if (*it == val) return idx;
idx++;
}
return -1;
}
template<typename K, typename V>
bool has_key(const std::unordered_map<K, V> m, const K& k) {
for (auto it = m.begin(); it != m.end(); ++it) {
if (k == it->first) return true;
}
return false;
}
#endif