mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-11 15:37:27 +00:00
C++ Add new type vector_bool flexbuffers (#4410)
* Add new type vector_bool * Update stl_emulation.h Fix Is same typo * Update stl_emulation.h
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
b4e91091ec
commit
76744a4345
@@ -77,16 +77,17 @@ enum Type {
|
||||
TYPE_VECTOR_FLOAT4 = 24,
|
||||
TYPE_BLOB = 25,
|
||||
TYPE_BOOL = 26,
|
||||
TYPE_VECTOR_BOOL = 36, // To Allow the same type of conversion of type to vector type
|
||||
};
|
||||
|
||||
inline bool IsInline(Type t) { return t <= TYPE_FLOAT || t == TYPE_BOOL; }
|
||||
|
||||
inline bool IsTypedVectorElementType(Type t) {
|
||||
return t >= TYPE_INT && t <= TYPE_STRING;
|
||||
return (t >= TYPE_INT && t <= TYPE_STRING) || t == TYPE_BOOL;
|
||||
}
|
||||
|
||||
inline bool IsTypedVector(Type t) {
|
||||
return t >= TYPE_VECTOR_INT && t <= TYPE_VECTOR_STRING;
|
||||
return (t >= TYPE_VECTOR_INT && t <= TYPE_VECTOR_STRING) || t == TYPE_VECTOR_BOOL;
|
||||
}
|
||||
|
||||
inline bool IsFixedTypedVector(Type t) {
|
||||
@@ -1240,7 +1241,8 @@ class Builder FLATBUFFERS_FINAL_CLASS {
|
||||
assert(flatbuffers::is_scalar<T>::value);
|
||||
return flatbuffers::is_floating_point<T>::value
|
||||
? TYPE_FLOAT
|
||||
: (flatbuffers::is_unsigned<T>::value ? TYPE_UINT : TYPE_INT);
|
||||
: flatbuffers::is_same<T, bool>::value ? TYPE_BOOL
|
||||
: (flatbuffers::is_unsigned<T>::value ? TYPE_UINT : TYPE_INT);
|
||||
}
|
||||
|
||||
struct Value {
|
||||
|
||||
@@ -91,11 +91,13 @@ inline void vector_emplace_back(std::vector<T> *vector, V &&data) {
|
||||
#if !(defined(_MSC_VER) && _MSC_VER <= 1700 /* MSVC2012 */)
|
||||
#ifndef FLATBUFFERS_CPP98_STL
|
||||
template <typename T> using is_scalar = std::is_scalar<T>;
|
||||
template <typename T, typename U> using is_same = std::is_same<T,U>;
|
||||
template <typename T> using is_floating_point = std::is_floating_point<T>;
|
||||
template <typename T> using is_unsigned = std::is_unsigned<T>;
|
||||
#else
|
||||
// Map C++ TR1 templates defined by stlport.
|
||||
template <typename T> using is_scalar = std::tr1::is_scalar<T>;
|
||||
template <typename T, typename U> using is_same = std::tr1::is_same<T,U>;
|
||||
template <typename T> using is_floating_point =
|
||||
std::tr1::is_floating_point<T>;
|
||||
template <typename T> using is_unsigned = std::tr1::is_unsigned<T>;
|
||||
@@ -103,6 +105,7 @@ inline void vector_emplace_back(std::vector<T> *vector, V &&data) {
|
||||
#else
|
||||
// MSVC 2010 doesn't support C++11 aliases.
|
||||
template <typename T> struct is_scalar : public std::is_scalar<T> {};
|
||||
template <typename T, typename U> struct is_same : public std::is_same<T,U> {};
|
||||
template <typename T> struct is_floating_point :
|
||||
public std::is_floating_point<T> {};
|
||||
template <typename T> struct is_unsigned : public std::is_unsigned<T> {};
|
||||
|
||||
Reference in New Issue
Block a user