Merge branch 'master' of https://github.com/google/flatbuffers into grpc2
authorWouter van Oortmerssen <wvo@google.com>
Thu, 21 Jul 2016 00:41:36 +0000 (17:41 -0700)
committerWouter van Oortmerssen <wvo@google.com>
Thu, 21 Jul 2016 00:41:36 +0000 (17:41 -0700)
1  2 
.gitignore
docs/source/Tutorial.md
include/flatbuffers/flatbuffers.h
src/idl_gen_cpp.cpp
tests/test.cpp

diff --cc .gitignore
Simple merge
Simple merge
Simple merge
@@@ -289,45 -273,16 +285,44 @@@ class CppGenerator : public BaseGenerat
    // Return a C++ type for any type (scalar/pointer) that reflects its
    // serialized size.
    std::string GenTypeSize(const Type &type) {
-     return IsScalar(type.base_type)
-                ? GenTypeBasic(type, false)
-                : IsStruct(type) ? GenTypePointer(type)
-                                 : "flatbuffers::uoffset_t";
+     return IsScalar(type.base_type) ? GenTypeBasic(type, false)
+                                     : IsStruct(type) ? GenTypePointer(type)
+                                                      : "flatbuffers::uoffset_t";
    }
  
 +  // TODO(wvo): make this configurable.
 +  std::string NativeName(const std::string &name) { return name + "T"; }
 +
 +  std::string GenTypeNative(const Type &type, bool invector) {
 +    switch (type.base_type) {
 +      case BASE_TYPE_STRING:
 +        return "std::string";
 +      case BASE_TYPE_VECTOR:
 +        return "std::vector<" + GenTypeNative(type.VectorType(), true) + ">";
 +      case BASE_TYPE_STRUCT:
 +        if (IsStruct(type)) {
 +          if (invector) {
 +            return WrapInNameSpace(*type.struct_def);
 +          } else {
 +            return "std::unique_ptr<" +
 +                   WrapInNameSpace(*type.struct_def) + ">";
 +          }
 +        } else {
 +          return "std::unique_ptr<" +
 +                 NativeName(WrapInNameSpace(*type.struct_def)) + ">";
 +        }
 +      case BASE_TYPE_UNION:
 +        return type.enum_def->name + "Union";
 +      default:
 +        return GenTypeBasic(type, true);
 +    }
 +  }
 +
    // Return a C++ type for any type (scalar/pointer) specifically for
    // using a flatbuffer.
-   std::string GenTypeGet(const Type &type,
-                          const char *afterbasic, const char *beforeptr,
-                          const char *afterptr, bool user_facing_type) {
+   std::string GenTypeGet(const Type &type, const char *afterbasic,
+                          const char *beforeptr, const char *afterptr,
+                          bool user_facing_type) {
      return IsScalar(type.base_type)
                 ? GenTypeBasic(type, user_facing_type) + afterbasic
                 : beforeptr + GenTypePointer(type) + afterptr;
diff --cc tests/test.cpp
Simple merge