Reflection for RapidJSON
0.0.17
Reflection for serializing/deserializing with RapidJSON
Toggle main menu visibility
Loading...
Searching...
No Matches
clangversionabstraction.h
Go to the documentation of this file.
1
// this file is based on clangversionabstraction.h from https://github.com/woboq/moc-ng
2
3
#ifndef REFLECTIVE_RAPIDJSON_CLANG_VERSION_ABSTRACTION_H
4
#define REFLECTIVE_RAPIDJSON_CLANG_VERSION_ABSTRACTION_H
5
6
#include <clang/Basic/SourceLocation.h>
7
#include <clang/Basic/Version.h>
8
9
#include <memory>
10
11
namespace
ReflectiveRapidJSON
{
12
17
template
<
typename
T>
struct
MaybeUnique
{
18
T *
val
;
19
operator
T *()
20
{
21
return
val
;
22
}
23
template
<
typename
X>
operator
std::unique_ptr<X>() &&
24
{
25
return
std::unique_ptr<X>(
val
);
26
}
27
};
28
template
<
typename
T>
MaybeUnique<T>
maybe_unique
(T *val)
29
{
30
return
{ val };
31
}
32
template
<
typename
T>
MaybeUnique<T>
maybe_unique
(std::unique_ptr<T> val)
33
{
34
return
{ val.release() };
35
}
36
41
42
#if CLANG_VERSION_MAJOR == 3 && CLANG_VERSION_MINOR <= 5
43
#define REFLECTIVE_RAPIDJSON_MAYBE_UNIQUE(t) t *
44
#else
45
#define REFLECTIVE_RAPIDJSON_MAYBE_UNIQUE(t) std::unique_ptr<t>
46
#endif
47
51
template
<
typename
T>
bool
startsStrRefWith
(T stringRef1, T stringRef2)
52
{
53
#if CLANG_VERSION_MAJOR >= 16
54
return
stringRef1.starts_with(stringRef2);
55
#else
56
return
stringRef1.startswith(stringRef2);
57
#endif
58
}
59
60
}
// namespace ReflectiveRapidJSON
61
62
#endif
// REFLECTIVE_RAPIDJSON_CLANG_VERSION_ABSTRACTION_H
ReflectiveRapidJSON
Definition
codegenerator.h:15
ReflectiveRapidJSON::startsStrRefWith
bool startsStrRefWith(T stringRef1, T stringRef2)
Tests whether an llvm::StringRef starts with another llvm::StringRef.
Definition
clangversionabstraction.h:51
ReflectiveRapidJSON::maybe_unique
MaybeUnique< T > maybe_unique(T *val)
Definition
clangversionabstraction.h:28
ReflectiveRapidJSON::MaybeUnique
The MaybeUnique class represents either a std::unique_ptr or a raw pointer.
Definition
clangversionabstraction.h:17
ReflectiveRapidJSON::MaybeUnique::val
T * val
Definition
clangversionabstraction.h:18
Generated on
for Reflection for RapidJSON by
1.18.0